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_Ganesh_DEFINED 9 #define SkSurface_Ganesh_DEFINED 10 11 #include "include/core/SkTypes.h" 12 13 #include "include/core/SkImageInfo.h" 14 #include "include/core/SkRefCnt.h" 15 #include "include/core/SkSamplingOptions.h" 16 #include "include/core/SkScalar.h" 17 #include "include/gpu/ganesh/GrBackendSurface.h" 18 #include "src/image/SkSurface_Base.h" 19 20 class GrBackendSemaphore; 21 class GrDeferredDisplayList; 22 class GrRecordingContext; 23 class GrSurfaceCharacterization; 24 class SkCanvas; 25 class SkCapabilities; 26 class SkColorSpace; 27 class SkImage; 28 class SkPaint; 29 class SkPixmap; 30 class SkSurface; 31 enum GrSurfaceOrigin : int; 32 namespace skgpu { 33 namespace ganesh { 34 class Device; 35 } 36 } // namespace skgpu 37 struct SkIRect; 38 struct SkISize; 39 40 class SkSurface_Ganesh : public SkSurface_Base { 41 public: 42 SkSurface_Ganesh(sk_sp<skgpu::ganesh::Device>); 43 ~SkSurface_Ganesh() override; 44 45 // From SkSurface.h 46 SkImageInfo imageInfo() const override; 47 bool replaceBackendTexture(const GrBackendTexture&, 48 GrSurfaceOrigin, 49 ContentChangeMode, 50 TextureReleaseProc, 51 ReleaseContext) override; 52 53 // From SkSurface_Base.h type()54 SkSurface_Base::Type type() const override { return SkSurface_Base::Type::kGanesh; } 55 56 GrRecordingContext* onGetRecordingContext() const override; 57 58 SkCanvas* onNewCanvas() override; 59 sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override; 60 sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override; 61 void onWritePixels(const SkPixmap&, int x, int y) override; 62 void onAsyncRescaleAndReadPixels(const SkImageInfo& info, 63 SkIRect srcRect, 64 RescaleGamma rescaleGamma, 65 RescaleMode, 66 ReadPixelsCallback callback, 67 ReadPixelsContext context) override; 68 void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, 69 bool readAlpha, 70 sk_sp<SkColorSpace> dstColorSpace, 71 SkIRect srcRect, 72 SkISize dstSize, 73 RescaleGamma rescaleGamma, 74 RescaleMode, 75 ReadPixelsCallback callback, 76 ReadPixelsContext context) override; 77 bool onCopyOnWrite(ContentChangeMode) override; 78 void onDiscard() override; 79 bool onWait(int numSemaphores, 80 const GrBackendSemaphore* waitSemaphores, 81 bool deleteSemaphoresAfterWait) override; 82 bool onCharacterize(GrSurfaceCharacterization*) const override; 83 bool onIsCompatible(const GrSurfaceCharacterization&) const override; 84 void onDraw(SkCanvas* canvas, 85 SkScalar x, 86 SkScalar y, 87 const SkSamplingOptions&, 88 const SkPaint* paint) override; 89 90 sk_sp<const SkCapabilities> onCapabilities() override; 91 92 skgpu::ganesh::Device* getDevice(); 93 GrBackendTexture getBackendTexture(BackendHandleAccess); 94 GrBackendRenderTarget getBackendRenderTarget(BackendHandleAccess); 95 void resolveMSAA(); 96 bool draw(sk_sp<const GrDeferredDisplayList>); 97 98 private: 99 sk_sp<skgpu::ganesh::Device> fDevice; 100 101 using INHERITED = SkSurface_Base; 102 }; 103 104 #endif // SkSurface_Ganesh_DEFINED 105