GrTextureMaker.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2016 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 GrTextureMaker_DEFINED
  8. #define GrTextureMaker_DEFINED
  9. #include "src/gpu/GrTextureProducer.h"
  10. /**
  11. * Base class for sources that start out as something other than a texture (encoded image,
  12. * picture, ...).
  13. */
  14. class GrTextureMaker : public GrTextureProducer {
  15. public:
  16. enum class AllowedTexGenType : bool { kCheap, kAny };
  17. std::unique_ptr<GrFragmentProcessor> createFragmentProcessor(
  18. const SkMatrix& textureMatrix,
  19. const SkRect& constraintRect,
  20. FilterConstraint filterConstraint,
  21. bool coordsLimitedToConstraintRect,
  22. const GrSamplerState::Filter* filterOrNullForBicubic) override;
  23. protected:
  24. GrTextureMaker(GrRecordingContext* context, int width, int height, const GrColorSpaceInfo& info,
  25. bool domainNeedsLocal)
  26. : INHERITED(context, width, height, info, domainNeedsLocal) {}
  27. /**
  28. * Return the maker's "original" texture. It is the responsibility of the maker to handle any
  29. * caching of the original if desired.
  30. * If "genType" argument equals AllowedTexGenType::kCheap and the texture is not trivial to
  31. * construct then refOriginalTextureProxy should return nullptr (for example if texture is made
  32. * by drawing into a render target).
  33. */
  34. virtual sk_sp<GrTextureProxy> refOriginalTextureProxy(bool willBeMipped,
  35. AllowedTexGenType genType) = 0;
  36. private:
  37. sk_sp<GrTextureProxy> onRefTextureProxyForParams(const GrSamplerState&,
  38. bool willBeMipped,
  39. SkScalar scaleAdjust[2]) override;
  40. typedef GrTextureProducer INHERITED;
  41. };
  42. #endif