Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 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 |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 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. |
| 15 | */ |
| 16 | #ifndef RENDERSTATE_GLOPBUILDER_H |
| 17 | #define RENDERSTATE_GLOPBUILDER_H |
| 18 | |
| 19 | #include "OpenGLRenderer.h" |
| 20 | #include "Program.h" |
| 21 | #include "utils/Macros.h" |
| 22 | |
| 23 | class SkPaint; |
Chris Craik | 922d3a7 | 2015-02-13 17:47:21 -0800 | [diff] [blame] | 24 | class SkShader; |
Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 25 | |
| 26 | namespace android { |
| 27 | namespace uirenderer { |
| 28 | |
| 29 | class Caches; |
Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 30 | class Matrix4; |
Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 31 | class RenderState; |
| 32 | class Texture; |
Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 33 | class VertexBuffer; |
Chris Craik | 922d3a7 | 2015-02-13 17:47:21 -0800 | [diff] [blame] | 34 | struct Glop; |
Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 35 | |
| 36 | class GlopBuilder { |
| 37 | PREVENT_COPY_AND_ASSIGN(GlopBuilder); |
| 38 | public: |
| 39 | GlopBuilder(RenderState& renderState, Caches& caches, Glop* outGlop); |
Chris Craik | 2ab95d7 | 2015-02-06 15:25:51 -0800 | [diff] [blame] | 40 | |
Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 41 | GlopBuilder& setMeshUnitQuad(); |
Chris Craik | f27133d | 2015-02-19 09:51:53 -0800 | [diff] [blame] | 42 | GlopBuilder& setMeshTexturedUnitQuad(const UvMapper* uvMapper); |
Chris Craik | 14100ac | 2015-02-24 13:46:29 -0800 | [diff] [blame] | 43 | GlopBuilder& setMeshTexturedUvQuad(const UvMapper* uvMapper, const Rect uvs); |
Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 44 | GlopBuilder& setMeshVertexBuffer(const VertexBuffer& vertexBuffer, bool shadowInterp); |
Chris Craik | ef25074 | 2015-02-25 17:16:16 -0800 | [diff] [blame^] | 45 | GlopBuilder& setMeshIndexedQuads(Vertex* vertexData, int quadCount); |
| 46 | GlopBuilder& setMeshColoredTexturedMesh(ColorTextureVertex* vertexData, int elementCount); |
Chris Craik | f27133d | 2015-02-19 09:51:53 -0800 | [diff] [blame] | 47 | GlopBuilder& setMeshTexturedIndexedQuads(TextureVertex* vertexData, int elementCount); // TODO: take quadCount |
Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 48 | |
Chris Craik | 0519c81 | 2015-02-11 13:17:06 -0800 | [diff] [blame] | 49 | GlopBuilder& setFillPaint(const SkPaint& paint, float alphaScale); |
| 50 | GlopBuilder& setFillTexturePaint(Texture& texture, bool isAlphaMaskTexture, |
| 51 | const SkPaint* paint, float alphaScale); |
Chris Craik | 2bb8f56 | 2015-02-17 16:42:02 -0800 | [diff] [blame] | 52 | GlopBuilder& setFillPathTexturePaint(PathTexture& texture, |
Chris Craik | 3003609 | 2015-02-12 10:41:39 -0800 | [diff] [blame] | 53 | const SkPaint& paint, float alphaScale); |
Chris Craik | 2bb8f56 | 2015-02-17 16:42:02 -0800 | [diff] [blame] | 54 | GlopBuilder& setFillShadowTexturePaint(ShadowTexture& texture, int shadowColor, |
| 55 | const SkPaint& paint, float alphaScale); |
| 56 | GlopBuilder& setFillBlack(); |
| 57 | GlopBuilder& setFillClear(); |
Chris Craik | f27133d | 2015-02-19 09:51:53 -0800 | [diff] [blame] | 58 | GlopBuilder& setFillLayer(Texture& texture, const SkColorFilter* colorFilter, |
| 59 | float alpha, SkXfermode::Mode mode); |
Chris Craik | 0519c81 | 2015-02-11 13:17:06 -0800 | [diff] [blame] | 60 | |
Chris Craik | f27133d | 2015-02-19 09:51:53 -0800 | [diff] [blame] | 61 | GlopBuilder& setTransform(const Matrix4& ortho, const Matrix4& transform, bool fudgingOffset); |
Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 62 | |
| 63 | GlopBuilder& setModelViewMapUnitToRect(const Rect destination); |
Chris Craik | 0519c81 | 2015-02-11 13:17:06 -0800 | [diff] [blame] | 64 | GlopBuilder& setModelViewMapUnitToRectSnap(const Rect destination); |
Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 65 | GlopBuilder& setModelViewOffsetRect(float offsetX, float offsetY, const Rect source); |
Chris Craik | f27133d | 2015-02-19 09:51:53 -0800 | [diff] [blame] | 66 | GlopBuilder& setModelViewOffsetRectSnap(float offsetX, float offsetY, const Rect source); |
Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 67 | |
Chris Craik | 0519c81 | 2015-02-11 13:17:06 -0800 | [diff] [blame] | 68 | GlopBuilder& setRoundRectClipState(const RoundRectClipState* roundRectClipState); |
| 69 | |
Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 70 | void build(); |
| 71 | private: |
Chris Craik | 0519c81 | 2015-02-11 13:17:06 -0800 | [diff] [blame] | 72 | void setFill(int color, float alphaScale, SkXfermode::Mode mode, |
| 73 | const SkShader* shader, const SkColorFilter* colorFilter); |
| 74 | |
Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 75 | enum StageFlags { |
| 76 | kInitialStage = 0, |
| 77 | kMeshStage = 1 << 0, |
| 78 | kTransformStage = 1 << 1, |
| 79 | kModelViewStage = 1 << 2, |
| 80 | kFillStage = 1 << 3, |
Chris Craik | 0519c81 | 2015-02-11 13:17:06 -0800 | [diff] [blame] | 81 | kRoundRectClipStage = 1 << 4, |
| 82 | kAllStages = kMeshStage | kFillStage | kTransformStage | kModelViewStage | kRoundRectClipStage, |
Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 83 | } mStageFlags; |
| 84 | |
Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 85 | ProgramDescription mDescription; |
| 86 | RenderState& mRenderState; |
| 87 | Caches& mCaches; |
Chris Craik | 922d3a7 | 2015-02-13 17:47:21 -0800 | [diff] [blame] | 88 | const SkShader* mShader; |
Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 89 | Glop* mOutGlop; |
| 90 | }; |
| 91 | |
| 92 | } /* namespace uirenderer */ |
| 93 | } /* namespace android */ |
| 94 | |
| 95 | #endif // RENDERSTATE_GLOPBUILDER_H |