2 * Copyright 2016 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrTextureMaker_DEFINED
9 #define GrTextureMaker_DEFINED
11 #include "GrTextureProducer.h"
14 * Base class for sources that start out as something other than a texture (encoded image,
17 class GrTextureMaker : public GrTextureProducer {
20 * Returns a texture that is safe for use with the params. If the size of the returned texture
21 * does not match width()/height() then the contents of the original must be scaled to fit
22 * the texture. Places the color space of the texture in (*texColorSpace).
24 GrTexture* refTextureForParams(const GrSamplerParams&, SkColorSpace* dstColorSpace,
25 sk_sp<SkColorSpace>* texColorSpace);
27 sk_sp<GrFragmentProcessor> createFragmentProcessor(
28 const SkMatrix& textureMatrix,
29 const SkRect& constraintRect,
30 FilterConstraint filterConstraint,
31 bool coordsLimitedToConstraintRect,
32 const GrSamplerParams::FilterMode* filterOrNullForBicubic,
33 SkColorSpace* dstColorSpace) override;
36 GrTextureMaker(GrContext* context, int width, int height, bool isAlphaOnly)
37 : INHERITED(width, height, isAlphaOnly)
38 , fContext(context) {}
41 * Return the maker's "original" texture. It is the responsibility of the maker to handle any
42 * caching of the original if desired.
44 virtual GrTexture* refOriginalTexture(bool willBeMipped, SkColorSpace* dstColorSpace) = 0;
47 * Returns the color space of the maker's "original" texture, assuming it was retrieved with
48 * the same destination color space.
50 virtual sk_sp<SkColorSpace> getColorSpace(SkColorSpace* dstColorSpace) = 0;
53 * Return a new (uncached) texture that is the stretch of the maker's original.
55 * The base-class handles general logic for this, and only needs access to the following
57 * - refOriginalTexture()
59 * Subclass may override this if they can handle creating the texture more directly than
62 virtual GrTexture* generateTextureForParams(const CopyParams&, bool willBeMipped,
63 SkColorSpace* dstColorSpace);
65 GrContext* context() const { return fContext; }
70 typedef GrTextureProducer INHERITED;