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