Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / gpu / ganesh / effects / GrBitmapTextGeoProc.h
1 /*
2  * Copyright 2013 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 GrBitmapTextGeoProc_DEFINED
9 #define GrBitmapTextGeoProc_DEFINED
10
11 #include "src/core/SkArenaAlloc.h"
12 #include "src/gpu/AtlasTypes.h"
13 #include "src/gpu/ganesh/GrGeometryProcessor.h"
14 #include "src/gpu/ganesh/GrProcessor.h"
15
16 class GrGLBitmapTextGeoProc;
17 class GrInvariantOutput;
18 class GrSurfaceProxyView;
19
20 /**
21  * The output color of this effect is a modulation of the input color and a sample from a texture.
22  * It allows explicit specification of the filtering and wrap modes (GrSamplerState). The input
23  * coords are a custom attribute.
24  */
25 class GrBitmapTextGeoProc : public GrGeometryProcessor {
26 public:
27     inline static constexpr int kMaxTextures = 4;
28
29     static GrGeometryProcessor* Make(SkArenaAlloc* arena,
30                                      const GrShaderCaps& caps,
31                                      const SkPMColor4f& color,
32                                      bool wideColor,
33                                      const GrSurfaceProxyView* views,
34                                      int numActiveViews,
35                                      GrSamplerState p,
36                                      skgpu::MaskFormat format,
37                                      const SkMatrix& localMatrix,
38                                      bool usesW) {
39         return arena->make([&](void* ptr) {
40             return new (ptr) GrBitmapTextGeoProc(caps, color, wideColor, views, numActiveViews,
41                                                  p, format, localMatrix, usesW);
42         });
43     }
44
45     ~GrBitmapTextGeoProc() override {}
46
47     const char* name() const override { return "BitmapText"; }
48
49     void addNewViews(const GrSurfaceProxyView*, int numActiveViews, GrSamplerState);
50
51     void addToKey(const GrShaderCaps& caps, skgpu::KeyBuilder* b) const override;
52
53     std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps& caps) const override;
54
55 private:
56     class Impl;
57
58     GrBitmapTextGeoProc(const GrShaderCaps&, const SkPMColor4f&, bool wideColor,
59                         const GrSurfaceProxyView* views, int numViews, GrSamplerState params,
60                         skgpu::MaskFormat format, const SkMatrix& localMatrix, bool usesW);
61
62     bool hasVertexColor() const { return fInColor.isInitialized(); }
63
64     const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; }
65
66     SkPMColor4f      fColor;
67     SkMatrix         fLocalMatrix;
68     bool             fUsesW;
69     SkISize          fAtlasDimensions;  // dimensions for all textures used with fTextureSamplers[].
70     TextureSampler   fTextureSamplers[kMaxTextures];
71     Attribute        fInPosition;
72     Attribute        fInColor;
73     Attribute        fInTextureCoords;
74     skgpu::MaskFormat     fMaskFormat;
75
76     GR_DECLARE_GEOMETRY_PROCESSOR_TEST
77
78     using INHERITED = GrGeometryProcessor;
79 };
80
81 #endif