blob: c7464cd04183c3d32961ec81f6a4dd54991d5278 [file] [log] [blame]
Chris Craik03188872015-02-02 18:39:33 -08001/*
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
23class SkPaint;
24
25namespace android {
26namespace uirenderer {
27
28class Caches;
29struct Glop;
Chris Craik117bdbc2015-02-05 10:12:38 -080030class Matrix4;
Chris Craik03188872015-02-02 18:39:33 -080031class RenderState;
32class Texture;
Chris Craik117bdbc2015-02-05 10:12:38 -080033class VertexBuffer;
Chris Craik03188872015-02-02 18:39:33 -080034
35class GlopBuilder {
36 PREVENT_COPY_AND_ASSIGN(GlopBuilder);
37public:
38 GlopBuilder(RenderState& renderState, Caches& caches, Glop* outGlop);
39 GlopBuilder& setMeshUnitQuad();
Chris Craik117bdbc2015-02-05 10:12:38 -080040 GlopBuilder& setMeshVertexBuffer(const VertexBuffer& vertexBuffer, bool shadowInterp);
41
42 GlopBuilder& setTransform(const Matrix4& ortho, const Matrix4& transform, bool fudgingOffset);
43
44 GlopBuilder& setModelViewMapUnitToRect(const Rect destination);
45 GlopBuilder& setModelViewOffsetRect(float offsetX, float offsetY, const Rect source);
46
Chris Craik03188872015-02-02 18:39:33 -080047 GlopBuilder& setPaint(const SkPaint* paint, float alphaScale);
Chris Craik03188872015-02-02 18:39:33 -080048 void build();
49private:
Chris Craik117bdbc2015-02-05 10:12:38 -080050 enum StageFlags {
51 kInitialStage = 0,
52 kMeshStage = 1 << 0,
53 kTransformStage = 1 << 1,
54 kModelViewStage = 1 << 2,
55 kFillStage = 1 << 3,
56 kAllStages = kMeshStage | kTransformStage | kModelViewStage | kFillStage,
57 } mStageFlags;
58
Chris Craik03188872015-02-02 18:39:33 -080059 ProgramDescription mDescription;
60 RenderState& mRenderState;
61 Caches& mCaches;
62 Glop* mOutGlop;
63};
64
65} /* namespace uirenderer */
66} /* namespace android */
67
68#endif // RENDERSTATE_GLOPBUILDER_H