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/core/SkTypes.h" 12 13 #if defined(SK_GANESH) 14 #include "include/core/SkImageInfo.h" 15 #include "include/core/SkRefCnt.h" 16 #include "include/core/SkSamplingOptions.h" 17 #include "include/core/SkScalar.h" 18 #include "include/gpu/GrBackendSurface.h" 19 #include "src/image/SkSurface_Base.h" 20 21 class GrBackendSemaphore; 22 class GrRecordingContext; 23 class SkCanvas; 24 class SkCapabilities; 25 class SkColorSpace; 26 class SkDeferredDisplayList; 27 class SkImage; 28 class SkPaint; 29 class SkPixmap; 30 class SkSurface; 31 class SkSurfaceCharacterization; 32 enum GrSurfaceOrigin : int; 33 enum class GrSemaphoresSubmitted : bool; 34 namespace skgpu { class MutableTextureState; } 35 namespace skgpu { namespace v1 { class Device; } } 36 struct GrFlushInfo; 37 struct SkIPoint; 38 struct SkIRect; 39 struct SkISize; 40 41 class SkSurface_Gpu : public SkSurface_Base { 42 public: 43 SkSurface_Gpu(sk_sp<skgpu::v1::Device>); 44 ~SkSurface_Gpu() override; 45 46 SkImageInfo imageInfo() const override; 47 48 GrRecordingContext* onGetRecordingContext() override; 49 50 GrBackendTexture onGetBackendTexture(BackendHandleAccess) override; 51 GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess) override; 52 bool onReplaceBackendTexture(const GrBackendTexture&, GrSurfaceOrigin, ContentChangeMode, TextureReleaseProc, 53 ReleaseContext) override; 54 55 SkCanvas* onNewCanvas() override; 56 sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override; 57 sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override; 58 void onWritePixels(const SkPixmap&, int x, int y) override; 59 void onAsyncRescaleAndReadPixels(const SkImageInfo& info, SkIRect srcRect, 60 RescaleGamma rescaleGamma, RescaleMode, 61 ReadPixelsCallback callback, 62 ReadPixelsContext context) override; 63 void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, 64 sk_sp<SkColorSpace> dstColorSpace, 65 SkIRect srcRect, 66 SkISize dstSize, 67 RescaleGamma rescaleGamma, 68 RescaleMode, 69 ReadPixelsCallback callback, 70 ReadPixelsContext context) override; 71 bool onCopyOnWrite(ContentChangeMode) override; 72 void onDiscard() override; 73 void onResolveMSAA() override; 74 GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, const GrFlushInfo& info, 75 const skgpu::MutableTextureState*) override; 76 bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores, 77 bool deleteSemaphoresAfterWait) override; 78 bool onCharacterize(SkSurfaceCharacterization*) const override; 79 bool onIsCompatible(const SkSurfaceCharacterization&) const override; 80 void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkSamplingOptions&, 81 const SkPaint* paint) override; 82 bool onDraw(sk_sp<const SkDeferredDisplayList>, SkIPoint offset) override; 83 84 sk_sp<const SkCapabilities> onCapabilities() override; 85 skgpu::v1::Device* getDevice(); 86 87 private: 88 sk_sp<skgpu::v1::Device> fDevice; 89 90 using INHERITED = SkSurface_Base; 91 }; 92 93 #endif // defined(SK_GANESH) 94 95 #endif // SkSurface_Gpu_DEFINED 96