tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
 
#ifndef GrTextureMaker_DEFINED
#define GrTextureMaker_DEFINED
 
#include "GrTextureProducer.h"
 
/**
 * Base class for sources that start out as something other than a texture (encoded image,
 * picture, ...).
 */
class GrTextureMaker : public GrTextureProducer {
public:
    enum class AllowedTexGenType : bool { kCheap, kAny };
 
    std::unique_ptr<GrFragmentProcessor> createFragmentProcessor(
            const SkMatrix& textureMatrix,
            const SkRect& constraintRect,
            FilterConstraint filterConstraint,
            bool coordsLimitedToConstraintRect,
            const GrSamplerState::Filter* filterOrNullForBicubic) override;
 
protected:
    GrTextureMaker(GrContext* context, int width, int height, bool isAlphaOnly)
        : INHERITED(context, width, height, isAlphaOnly) {}
 
    /**
     *  Return the maker's "original" texture. It is the responsibility of the maker to handle any
     *  caching of the original if desired.
     *  If "genType" argument equals AllowedTexGenType::kCheap and the texture is not trivial to
     *  construct then refOriginalTextureProxy should return nullptr (for example if texture is made
     *  by drawing into a render target).
     */
    virtual sk_sp<GrTextureProxy> refOriginalTextureProxy(bool willBeMipped,
                                                          AllowedTexGenType genType) = 0;
 
    GrContext* context() const { return fContext; }
 
private:
    sk_sp<GrTextureProxy> onRefTextureProxyForParams(const GrSamplerState&,
                                                     bool willBeMipped,
                                                     SkScalar scaleAdjust[2]) override;
 
    typedef GrTextureProducer INHERITED;
};
 
#endif