1 | /* |
2 | * Copyright 2014 Google Inc. |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #ifndef SkSurface_Gpu_DEFINED |
9 | #define SkSurface_Gpu_DEFINED |
10 | |
11 | #include "include/private/GrTypesPriv.h" |
12 | #include "src/image/SkSurface_Base.h" |
13 | |
14 | #if SK_SUPPORT_GPU |
15 | |
16 | class GrBackendFormat; |
17 | class SkGpuDevice; |
18 | |
19 | class SkSurface_Gpu : public SkSurface_Base { |
20 | public: |
21 | SkSurface_Gpu(sk_sp<SkGpuDevice>); |
22 | ~SkSurface_Gpu() override; |
23 | |
24 | // This is an internal-only factory |
25 | static sk_sp<SkSurface> MakeWrappedRenderTarget(GrRecordingContext*, |
26 | std::unique_ptr<GrRenderTargetContext>); |
27 | |
28 | GrContext* onGetContext_deprecated() override; |
29 | GrRecordingContext* onGetRecordingContext() override; |
30 | |
31 | GrBackendTexture onGetBackendTexture(BackendHandleAccess) override; |
32 | GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess) override; |
33 | bool onReplaceBackendTexture(const GrBackendTexture&, GrSurfaceOrigin, ContentChangeMode, TextureReleaseProc, |
34 | ReleaseContext) override; |
35 | |
36 | SkCanvas* onNewCanvas() override; |
37 | sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override; |
38 | sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override; |
39 | void onWritePixels(const SkPixmap&, int x, int y) override; |
40 | void onAsyncRescaleAndReadPixels(const SkImageInfo& info, const SkIRect& srcRect, |
41 | RescaleGamma rescaleGamma, SkFilterQuality rescaleQuality, |
42 | ReadPixelsCallback callback, |
43 | ReadPixelsContext context) override; |
44 | void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, |
45 | sk_sp<SkColorSpace> dstColorSpace, |
46 | const SkIRect& srcRect, |
47 | const SkISize& dstSize, |
48 | RescaleGamma rescaleGamma, |
49 | SkFilterQuality rescaleQuality, |
50 | ReadPixelsCallback callback, |
51 | ReadPixelsContext context) override; |
52 | |
53 | void onCopyOnWrite(ContentChangeMode) override; |
54 | void onDiscard() override; |
55 | GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, const GrFlushInfo& info, |
56 | const GrBackendSurfaceMutableState*) override; |
57 | bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores, |
58 | bool deleteSemaphoresAfterWait) override; |
59 | bool onCharacterize(SkSurfaceCharacterization*) const override; |
60 | bool onIsCompatible(const SkSurfaceCharacterization&) const override; |
61 | void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) override; |
62 | bool onDraw(sk_sp<const SkDeferredDisplayList>) override; |
63 | |
64 | SkGpuDevice* getDevice() { return fDevice.get(); } |
65 | |
66 | private: |
67 | sk_sp<SkGpuDevice> fDevice; |
68 | |
69 | typedef SkSurface_Base INHERITED; |
70 | }; |
71 | |
72 | #endif // SK_SUPPORT_GPU |
73 | |
74 | #endif // SkSurface_Gpu_DEFINED |
75 | |