2 * Copyright (C) 2015 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef RENDERSTATE_GLOPBUILDER_H
17 #define RENDERSTATE_GLOPBUILDER_H
20 #include "OpenGLRenderer.h"
22 #include "renderstate/Blend.h"
23 #include "utils/Macros.h"
29 namespace uirenderer {
37 namespace TextureFillFlags {
40 IsAlphaMaskTexture = 1 << 0,
46 PREVENT_COPY_AND_ASSIGN(GlopBuilder);
48 GlopBuilder(RenderState& renderState, Caches& caches, Glop* outGlop);
50 GlopBuilder& setMeshTexturedIndexedVbo(GLuint vbo, GLsizei elementCount);
51 GlopBuilder& setMeshUnitQuad();
52 GlopBuilder& setMeshTexturedUnitQuad(const UvMapper* uvMapper);
53 GlopBuilder& setMeshTexturedUvQuad(const UvMapper* uvMapper, const Rect uvs);
54 GlopBuilder& setMeshVertexBuffer(const VertexBuffer& vertexBuffer);
55 GlopBuilder& setMeshIndexedQuads(Vertex* vertexData, int quadCount);
56 GlopBuilder& setMeshTexturedMesh(TextureVertex* vertexData, int elementCount); // TODO: delete
57 GlopBuilder& setMeshColoredTexturedMesh(ColorTextureVertex* vertexData, int elementCount); // TODO: use indexed quads
58 GlopBuilder& setMeshTexturedIndexedQuads(TextureVertex* vertexData, int elementCount); // TODO: take quadCount
59 GlopBuilder& setMeshPatchQuads(const Patch& patch);
61 GlopBuilder& setFillPaint(const SkPaint& paint, float alphaScale, bool shadowInterp = false); // TODO: avoid boolean with default
62 GlopBuilder& setFillTexturePaint(Texture& texture, const int textureFillFlags,
63 const SkPaint* paint, float alphaScale);
64 GlopBuilder& setFillPathTexturePaint(PathTexture& texture,
65 const SkPaint& paint, float alphaScale);
66 GlopBuilder& setFillShadowTexturePaint(ShadowTexture& texture, int shadowColor,
67 const SkPaint& paint, float alphaScale);
68 GlopBuilder& setFillBlack();
69 GlopBuilder& setFillClear();
70 GlopBuilder& setFillLayer(Texture& texture, const SkColorFilter* colorFilter,
71 float alpha, SkXfermode::Mode mode, Blend::ModeOrderSwap modeUsage);
72 GlopBuilder& setFillTextureLayer(Layer& layer, float alpha);
73 // TODO: Texture should probably know and own its target.
74 // setFillLayer() forces it to GL_TEXTURE which isn't always correct.
75 // Similarly setFillLayer normally forces its own wrap & filter mode
76 GlopBuilder& setFillExternalTexture(Texture& texture, Matrix4& textureTransform);
78 GlopBuilder& setTransform(const Snapshot& snapshot, const int transformFlags) {
79 return setTransform(*snapshot.transform, transformFlags);
81 GlopBuilder& setTransform(const Matrix4& canvas, const int transformFlags);
83 GlopBuilder& setModelViewMapUnitToRect(const Rect destination);
84 GlopBuilder& setModelViewMapUnitToRectSnap(const Rect destination);
85 GlopBuilder& setModelViewMapUnitToRectOptionalSnap(bool snap, const Rect& destination) {
87 return setModelViewMapUnitToRectSnap(destination);
89 return setModelViewMapUnitToRect(destination);
92 GlopBuilder& setModelViewOffsetRect(float offsetX, float offsetY, const Rect source);
93 GlopBuilder& setModelViewOffsetRectSnap(float offsetX, float offsetY, const Rect source);
94 GlopBuilder& setModelViewOffsetRectOptionalSnap(bool snap,
95 float offsetX, float offsetY, const Rect& source) {
97 return setModelViewOffsetRectSnap(offsetX, offsetY, source);
99 return setModelViewOffsetRect(offsetX, offsetY, source);
102 GlopBuilder& setModelViewIdentityEmptyBounds() {
103 // pass empty rect since not needed for damage / snap
104 return setModelViewOffsetRect(0, 0, Rect());
107 GlopBuilder& setRoundRectClipState(const RoundRectClipState* roundRectClipState);
111 static void dump(const Glop& glop);
113 void setFill(int color, float alphaScale,
114 SkXfermode::Mode mode, Blend::ModeOrderSwap modeUsage,
115 const SkShader* shader, const SkColorFilter* colorFilter);
120 kTransformStage = 1 << 1,
121 kModelViewStage = 1 << 2,
123 kRoundRectClipStage = 1 << 4,
124 kAllStages = kMeshStage | kFillStage | kTransformStage | kModelViewStage | kRoundRectClipStage,
127 ProgramDescription mDescription;
128 RenderState& mRenderState;
130 const SkShader* mShader;
134 } /* namespace uirenderer */
135 } /* namespace android */
137 #endif // RENDERSTATE_GLOPBUILDER_H