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(GrContext*, 26 std::unique_ptr<GrRenderTargetContext>); 27 28 GrBackendTexture onGetBackendTexture(BackendHandleAccess) override; 29 GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess) override; 30 bool onReplaceBackendTexture(const GrBackendTexture&, GrSurfaceOrigin, ContentChangeMode, TextureReleaseProc, 31 ReleaseContext) override; 32 33 SkCanvas* onNewCanvas() override; 34 sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override; 35 sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override; 36 void onWritePixels(const SkPixmap&, int x, int y) override; 37 void onAsyncRescaleAndReadPixels(const SkImageInfo& info, const SkIRect& srcRect, 38 RescaleGamma rescaleGamma, SkFilterQuality rescaleQuality, 39 ReadPixelsCallback callback, 40 ReadPixelsContext context) override; 41 void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, 42 sk_sp<SkColorSpace> dstColorSpace, 43 const SkIRect& srcRect, 44 const SkISize& dstSize, 45 RescaleGamma rescaleGamma, 46 SkFilterQuality rescaleQuality, 47 ReadPixelsCallback callback, 48 ReadPixelsContext context) override; 49 50 void onCopyOnWrite(ContentChangeMode) override; 51 void onDiscard() override; 52 GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, const GrFlushInfo& info) override; 53 bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) override; 54 bool onCharacterize(SkSurfaceCharacterization*) const override; 55 bool onIsCompatible(const SkSurfaceCharacterization&) const override; 56 void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) override; 57 bool onDraw(const SkDeferredDisplayList*) override; 58 getDevice()59 SkGpuDevice* getDevice() { return fDevice.get(); } 60 61 private: 62 sk_sp<SkGpuDevice> fDevice; 63 64 typedef SkSurface_Base INHERITED; 65 }; 66 67 #endif // SK_SUPPORT_GPU 68 69 #endif // SkSurface_Gpu_DEFINED 70