SkImage_Gpu.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2015 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 SkImage_Gpu_DEFINED
  8. #define SkImage_Gpu_DEFINED
  9. #include "include/gpu/GrContext.h"
  10. #include "src/core/SkImagePriv.h"
  11. #include "src/gpu/GrGpuResourcePriv.h"
  12. #include "src/gpu/GrSurfaceProxyPriv.h"
  13. #include "src/gpu/SkGr.h"
  14. #include "src/image/SkImage_GpuBase.h"
  15. class GrTexture;
  16. class SkBitmap;
  17. struct SkYUVAIndex;
  18. class SkImage_Gpu : public SkImage_GpuBase {
  19. public:
  20. SkImage_Gpu(sk_sp<GrContext>, uint32_t uniqueID, SkAlphaType, sk_sp<GrTextureProxy>,
  21. sk_sp<SkColorSpace>);
  22. ~SkImage_Gpu() override;
  23. GrSemaphoresSubmitted onFlush(GrContext*, const GrFlushInfo&) override;
  24. GrTextureProxy* peekProxy() const override {
  25. return fProxy.get();
  26. }
  27. sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const override {
  28. return fProxy;
  29. }
  30. bool onIsTextureBacked() const override { return SkToBool(fProxy.get()); }
  31. sk_sp<SkImage> onMakeColorTypeAndColorSpace(GrRecordingContext*,
  32. SkColorType, sk_sp<SkColorSpace>) const final;
  33. /**
  34. * This is the implementation of SkDeferredDisplayListRecorder::makePromiseImage.
  35. */
  36. static sk_sp<SkImage> MakePromiseTexture(GrContext* context,
  37. const GrBackendFormat& backendFormat,
  38. int width,
  39. int height,
  40. GrMipMapped mipMapped,
  41. GrSurfaceOrigin origin,
  42. SkColorType colorType,
  43. SkAlphaType alphaType,
  44. sk_sp<SkColorSpace> colorSpace,
  45. PromiseImageTextureFulfillProc textureFulfillProc,
  46. PromiseImageTextureReleaseProc textureReleaseProc,
  47. PromiseImageTextureDoneProc textureDoneProc,
  48. PromiseImageTextureContext textureContext,
  49. PromiseImageApiVersion);
  50. static sk_sp<SkImage> ConvertYUVATexturesToRGB(GrContext*, SkYUVColorSpace yuvColorSpace,
  51. const GrBackendTexture yuvaTextures[],
  52. const SkYUVAIndex yuvaIndices[4],
  53. SkISize imageSize, GrSurfaceOrigin imageOrigin,
  54. GrRenderTargetContext*);
  55. private:
  56. sk_sp<GrTextureProxy> fProxy;
  57. typedef SkImage_GpuBase INHERITED;
  58. };
  59. #endif