SkSurface_Gpu.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef SkSurface_Gpu_DEFINED
  8. #define SkSurface_Gpu_DEFINED
  9. #include "include/private/GrTypesPriv.h"
  10. #include "src/image/SkSurface_Base.h"
  11. #if SK_SUPPORT_GPU
  12. class GrBackendFormat;
  13. class SkGpuDevice;
  14. class SkSurface_Gpu : public SkSurface_Base {
  15. public:
  16. SkSurface_Gpu(sk_sp<SkGpuDevice>);
  17. ~SkSurface_Gpu() override;
  18. // This is an internal-only factory
  19. static sk_sp<SkSurface> MakeWrappedRenderTarget(GrContext*, sk_sp<GrRenderTargetContext>);
  20. GrBackendTexture onGetBackendTexture(BackendHandleAccess) override;
  21. GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess) override;
  22. bool onReplaceBackendTexture(const GrBackendTexture&, GrSurfaceOrigin, TextureReleaseProc,
  23. ReleaseContext) override;
  24. SkCanvas* onNewCanvas() override;
  25. sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override;
  26. sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override;
  27. void onWritePixels(const SkPixmap&, int x, int y) override;
  28. void onAsyncRescaleAndReadPixels(const SkImageInfo& info, const SkIRect& srcRect,
  29. RescaleGamma rescaleGamma, SkFilterQuality rescaleQuality,
  30. ReadPixelsCallback callback,
  31. ReadPixelsContext context) override;
  32. void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
  33. sk_sp<SkColorSpace> dstColorSpace,
  34. const SkIRect& srcRect, int dstW, int dstH,
  35. RescaleGamma rescaleGamma,
  36. SkFilterQuality rescaleQuality,
  37. ReadPixelsCallbackYUV420 callback,
  38. ReadPixelsContext context) override;
  39. void onCopyOnWrite(ContentChangeMode) override;
  40. void onDiscard() override;
  41. GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, const GrFlushInfo& info) override;
  42. bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) override;
  43. bool onCharacterize(SkSurfaceCharacterization*) const override;
  44. bool onIsCompatible(const SkSurfaceCharacterization&) const override;
  45. void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) override;
  46. bool onDraw(const SkDeferredDisplayList*) override;
  47. SkGpuDevice* getDevice() { return fDevice.get(); }
  48. static bool Valid(const GrCaps*, const GrBackendFormat&);
  49. private:
  50. sk_sp<SkGpuDevice> fDevice;
  51. typedef SkSurface_Base INHERITED;
  52. };
  53. #endif // SK_SUPPORT_GPU
  54. #endif // SkSurface_Gpu_DEFINED