blob: 248e92f7c97b9b672da7887bfd9ce2908b76853c [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#include "GlopBuilder.h"
17
18#include "Caches.h"
Greg Daniel8cd3edf2017-01-09 14:15:41 -050019#include "GlLayer.h"
Chris Craik03188872015-02-02 18:39:33 -080020#include "Glop.h"
Chris Craik5e00c7c2016-07-06 16:10:09 -070021#include "Layer.h"
Chris Craik03188872015-02-02 18:39:33 -080022#include "Matrix.h"
Chris Craik0556d902015-03-03 09:54:14 -080023#include "Patch.h"
Chris Craik5e00c7c2016-07-06 16:10:09 -070024#include "PathCache.h"
Chris Craik03188872015-02-02 18:39:33 -080025#include "renderstate/MeshState.h"
26#include "renderstate/RenderState.h"
Chris Craik117bdbc2015-02-05 10:12:38 -080027#include "SkiaShader.h"
28#include "Texture.h"
Chris Craik03188872015-02-02 18:39:33 -080029#include "utils/PaintUtils.h"
Chris Craik117bdbc2015-02-05 10:12:38 -080030#include "VertexBuffer.h"
Chris Craik03188872015-02-02 18:39:33 -080031
32#include <GLES2/gl2.h>
33#include <SkPaint.h>
34
Chris Craikb1f990d2015-06-12 11:28:52 -070035#define DEBUG_GLOP_BUILDER 0
36
37#if DEBUG_GLOP_BUILDER
Chris Craik03188872015-02-02 18:39:33 -080038
Chris Craik117bdbc2015-02-05 10:12:38 -080039#define TRIGGER_STAGE(stageFlag) \
Chris Craik14100ac2015-02-24 13:46:29 -080040 LOG_ALWAYS_FATAL_IF((stageFlag) & mStageFlags, "Stage %d cannot be run twice", (stageFlag)); \
Chris Craik0519c812015-02-11 13:17:06 -080041 mStageFlags = static_cast<StageFlags>(mStageFlags | (stageFlag))
Chris Craik117bdbc2015-02-05 10:12:38 -080042
Chris Craik08fa43f2015-02-09 18:58:32 -080043#define REQUIRE_STAGES(requiredFlags) \
Chris Craik0519c812015-02-11 13:17:06 -080044 LOG_ALWAYS_FATAL_IF((mStageFlags & (requiredFlags)) != (requiredFlags), \
Chris Craik08fa43f2015-02-09 18:58:32 -080045 "not prepared for current stage")
46
Chris Craikb1f990d2015-06-12 11:28:52 -070047#else
48
49#define TRIGGER_STAGE(stageFlag) ((void)0)
50#define REQUIRE_STAGES(requiredFlags) ((void)0)
51
52#endif
53
54namespace android {
55namespace uirenderer {
56
Chris Craik922d3a72015-02-13 17:47:21 -080057static void setUnitQuadTextureCoords(Rect uvs, TextureVertex* quadVertex) {
Chris Craik14100ac2015-02-24 13:46:29 -080058 quadVertex[0] = {0, 0, uvs.left, uvs.top};
59 quadVertex[1] = {1, 0, uvs.right, uvs.top};
60 quadVertex[2] = {0, 1, uvs.left, uvs.bottom};
61 quadVertex[3] = {1, 1, uvs.right, uvs.bottom};
Chris Craik0519c812015-02-11 13:17:06 -080062}
63
Chris Craik03188872015-02-02 18:39:33 -080064GlopBuilder::GlopBuilder(RenderState& renderState, Caches& caches, Glop* outGlop)
65 : mRenderState(renderState)
66 , mCaches(caches)
Chris Craik922d3a72015-02-13 17:47:21 -080067 , mShader(nullptr)
Chris Craik0519c812015-02-11 13:17:06 -080068 , mOutGlop(outGlop) {
Chris Craik117bdbc2015-02-05 10:12:38 -080069 mStageFlags = kInitialStage;
70}
71
Chris Craik0519c812015-02-11 13:17:06 -080072////////////////////////////////////////////////////////////////////////////////
73// Mesh
74////////////////////////////////////////////////////////////////////////////////
75
Chris Craik8d2cf942015-11-02 14:52:21 -080076GlopBuilder& GlopBuilder::setMeshTexturedIndexedVbo(GLuint vbo, GLsizei elementCount) {
77 TRIGGER_STAGE(kMeshStage);
78
79 mOutGlop->mesh.primitiveMode = GL_TRIANGLES;
80 mOutGlop->mesh.indices = { mRenderState.meshState().getQuadListIBO(), nullptr };
81 mOutGlop->mesh.vertices = {
82 vbo,
83 VertexAttribFlags::TextureCoord,
Chris Craike5b50192016-01-04 15:09:19 -080084 nullptr, (const void*) kMeshTextureOffset, nullptr,
Chris Craik8d2cf942015-11-02 14:52:21 -080085 kTextureVertexStride };
86 mOutGlop->mesh.elementCount = elementCount;
87 return *this;
88}
89
Chris Craik0519c812015-02-11 13:17:06 -080090GlopBuilder& GlopBuilder::setMeshUnitQuad() {
91 TRIGGER_STAGE(kMeshStage);
92
Chris Craik0519c812015-02-11 13:17:06 -080093 mOutGlop->mesh.primitiveMode = GL_TRIANGLE_STRIP;
Chris Craikef250742015-02-25 17:16:16 -080094 mOutGlop->mesh.indices = { 0, nullptr };
95 mOutGlop->mesh.vertices = {
96 mRenderState.meshState().getUnitQuadVBO(),
Chris Craik53e51e42015-06-01 10:35:35 -070097 VertexAttribFlags::None,
Chris Craikef250742015-02-25 17:16:16 -080098 nullptr, nullptr, nullptr,
99 kTextureVertexStride };
Chris Craik0519c812015-02-11 13:17:06 -0800100 mOutGlop->mesh.elementCount = 4;
Chris Craik0519c812015-02-11 13:17:06 -0800101 return *this;
102}
103
Chris Craikf27133d2015-02-19 09:51:53 -0800104GlopBuilder& GlopBuilder::setMeshTexturedUnitQuad(const UvMapper* uvMapper) {
Chris Craik14100ac2015-02-24 13:46:29 -0800105 if (uvMapper) {
106 // can't use unit quad VBO, so build UV vertices manually
Chris Craik5430ab22015-12-10 16:28:16 -0800107 return setMeshTexturedUvQuad(uvMapper, Rect(1, 1));
Chris Craik14100ac2015-02-24 13:46:29 -0800108 }
109
110 TRIGGER_STAGE(kMeshStage);
111
Chris Craik14100ac2015-02-24 13:46:29 -0800112 mOutGlop->mesh.primitiveMode = GL_TRIANGLE_STRIP;
Chris Craikef250742015-02-25 17:16:16 -0800113 mOutGlop->mesh.indices = { 0, nullptr };
114 mOutGlop->mesh.vertices = {
115 mRenderState.meshState().getUnitQuadVBO(),
Chris Craik53e51e42015-06-01 10:35:35 -0700116 VertexAttribFlags::TextureCoord,
Chris Craikef250742015-02-25 17:16:16 -0800117 nullptr, (const void*) kMeshTextureOffset, nullptr,
118 kTextureVertexStride };
Chris Craik14100ac2015-02-24 13:46:29 -0800119 mOutGlop->mesh.elementCount = 4;
Chris Craik14100ac2015-02-24 13:46:29 -0800120 return *this;
121}
122
123GlopBuilder& GlopBuilder::setMeshTexturedUvQuad(const UvMapper* uvMapper, Rect uvs) {
Chris Craik0519c812015-02-11 13:17:06 -0800124 TRIGGER_STAGE(kMeshStage);
125
Chris Craik0519c812015-02-11 13:17:06 -0800126 if (CC_UNLIKELY(uvMapper)) {
Chris Craik0519c812015-02-11 13:17:06 -0800127 uvMapper->map(uvs);
Chris Craik0519c812015-02-11 13:17:06 -0800128 }
Chris Craik14100ac2015-02-24 13:46:29 -0800129 setUnitQuadTextureCoords(uvs, &mOutGlop->mesh.mappedVertices[0]);
130
Chris Craikef250742015-02-25 17:16:16 -0800131 const TextureVertex* textureVertex = mOutGlop->mesh.mappedVertices;
132 mOutGlop->mesh.primitiveMode = GL_TRIANGLE_STRIP;
133 mOutGlop->mesh.indices = { 0, nullptr };
134 mOutGlop->mesh.vertices = {
135 0,
Chris Craik53e51e42015-06-01 10:35:35 -0700136 VertexAttribFlags::TextureCoord,
Chris Craikef250742015-02-25 17:16:16 -0800137 &textureVertex[0].x, &textureVertex[0].u, nullptr,
138 kTextureVertexStride };
Chris Craik0519c812015-02-11 13:17:06 -0800139 mOutGlop->mesh.elementCount = 4;
Chris Craik0519c812015-02-11 13:17:06 -0800140 return *this;
141}
142
Chris Craikef250742015-02-25 17:16:16 -0800143GlopBuilder& GlopBuilder::setMeshIndexedQuads(Vertex* vertexData, int quadCount) {
Chris Craik0519c812015-02-11 13:17:06 -0800144 TRIGGER_STAGE(kMeshStage);
145
Chris Craik0519c812015-02-11 13:17:06 -0800146 mOutGlop->mesh.primitiveMode = GL_TRIANGLES;
Chris Craikef250742015-02-25 17:16:16 -0800147 mOutGlop->mesh.indices = { mRenderState.meshState().getQuadListIBO(), nullptr };
148 mOutGlop->mesh.vertices = {
149 0,
Chris Craik53e51e42015-06-01 10:35:35 -0700150 VertexAttribFlags::None,
Chris Craikef250742015-02-25 17:16:16 -0800151 vertexData, nullptr, nullptr,
152 kVertexStride };
Chris Craik0519c812015-02-11 13:17:06 -0800153 mOutGlop->mesh.elementCount = 6 * quadCount;
Chris Craik0519c812015-02-11 13:17:06 -0800154 return *this;
155}
156
Chris Craikf27133d2015-02-19 09:51:53 -0800157GlopBuilder& GlopBuilder::setMeshTexturedIndexedQuads(TextureVertex* vertexData, int elementCount) {
158 TRIGGER_STAGE(kMeshStage);
159
Chris Craikf27133d2015-02-19 09:51:53 -0800160 mOutGlop->mesh.primitiveMode = GL_TRIANGLES;
Chris Craikef250742015-02-25 17:16:16 -0800161 mOutGlop->mesh.indices = { mRenderState.meshState().getQuadListIBO(), nullptr };
162 mOutGlop->mesh.vertices = {
163 0,
Chris Craik53e51e42015-06-01 10:35:35 -0700164 VertexAttribFlags::TextureCoord,
Chris Craikef250742015-02-25 17:16:16 -0800165 &vertexData[0].x, &vertexData[0].u, nullptr,
166 kTextureVertexStride };
Chris Craikf27133d2015-02-19 09:51:53 -0800167 mOutGlop->mesh.elementCount = elementCount;
Chris Craikef250742015-02-25 17:16:16 -0800168 return *this;
169}
170
171GlopBuilder& GlopBuilder::setMeshColoredTexturedMesh(ColorTextureVertex* vertexData, int elementCount) {
172 TRIGGER_STAGE(kMeshStage);
173
174 mOutGlop->mesh.primitiveMode = GL_TRIANGLES;
175 mOutGlop->mesh.indices = { 0, nullptr };
176 mOutGlop->mesh.vertices = {
177 0,
Chris Craik53e51e42015-06-01 10:35:35 -0700178 VertexAttribFlags::TextureCoord | VertexAttribFlags::Color,
Chris Craikef250742015-02-25 17:16:16 -0800179 &vertexData[0].x, &vertexData[0].u, &vertexData[0].r,
180 kColorTextureVertexStride };
181 mOutGlop->mesh.elementCount = elementCount;
Chris Craikf27133d2015-02-19 09:51:53 -0800182 return *this;
183}
184
Chris Craik138c21f2016-04-28 16:59:42 -0700185GlopBuilder& GlopBuilder::setMeshVertexBuffer(const VertexBuffer& vertexBuffer) {
Chris Craik117bdbc2015-02-05 10:12:38 -0800186 TRIGGER_STAGE(kMeshStage);
187
188 const VertexBuffer::MeshFeatureFlags flags = vertexBuffer.getMeshFeatureFlags();
189
190 bool alphaVertex = flags & VertexBuffer::kAlpha;
191 bool indices = flags & VertexBuffer::kIndices;
Chris Craik117bdbc2015-02-05 10:12:38 -0800192
Chris Craikef250742015-02-25 17:16:16 -0800193 mOutGlop->mesh.primitiveMode = GL_TRIANGLE_STRIP;
194 mOutGlop->mesh.indices = { 0, vertexBuffer.getIndices() };
195 mOutGlop->mesh.vertices = {
196 0,
Chris Craik53e51e42015-06-01 10:35:35 -0700197 alphaVertex ? VertexAttribFlags::Alpha : VertexAttribFlags::None,
Chris Craikef250742015-02-25 17:16:16 -0800198 vertexBuffer.getBuffer(), nullptr, nullptr,
199 alphaVertex ? kAlphaVertexStride : kVertexStride };
200 mOutGlop->mesh.elementCount = indices
201 ? vertexBuffer.getIndexCount() : vertexBuffer.getVertexCount();
Chris Craik117bdbc2015-02-05 10:12:38 -0800202 return *this;
Chris Craik03188872015-02-02 18:39:33 -0800203}
204
Chris Craik0556d902015-03-03 09:54:14 -0800205GlopBuilder& GlopBuilder::setMeshPatchQuads(const Patch& patch) {
206 TRIGGER_STAGE(kMeshStage);
207
208 mOutGlop->mesh.primitiveMode = GL_TRIANGLES;
209 mOutGlop->mesh.indices = { mRenderState.meshState().getQuadListIBO(), nullptr };
210 mOutGlop->mesh.vertices = {
211 mCaches.patchCache.getMeshBuffer(),
Chris Craik53e51e42015-06-01 10:35:35 -0700212 VertexAttribFlags::TextureCoord,
Chris Craik8820fd12015-03-03 14:20:47 -0800213 (void*)patch.positionOffset, (void*)patch.textureOffset, nullptr,
Chris Craik0556d902015-03-03 09:54:14 -0800214 kTextureVertexStride };
215 mOutGlop->mesh.elementCount = patch.indexCount;
216 return *this;
217}
218
Chris Craik0519c812015-02-11 13:17:06 -0800219////////////////////////////////////////////////////////////////////////////////
220// Fill
221////////////////////////////////////////////////////////////////////////////////
Chris Craik117bdbc2015-02-05 10:12:38 -0800222
Chris Craik182952f2015-03-09 14:17:29 -0700223void GlopBuilder::setFill(int color, float alphaScale,
Mike Reed260ab722016-10-07 15:59:20 -0400224 SkBlendMode mode, Blend::ModeOrderSwap modeUsage,
Chris Craik0519c812015-02-11 13:17:06 -0800225 const SkShader* shader, const SkColorFilter* colorFilter) {
Mike Reed260ab722016-10-07 15:59:20 -0400226 if (mode != SkBlendMode::kClear) {
Chris Craik117bdbc2015-02-05 10:12:38 -0800227 if (!shader) {
Romain Guy253f2c22016-09-28 17:34:42 -0700228 FloatColor c;
229 c.set(color);
230 c.r *= alphaScale;
231 c.g *= alphaScale;
232 c.b *= alphaScale;
233 c.a *= alphaScale;
234 mOutGlop->fill.color = c;
Chris Craik117bdbc2015-02-05 10:12:38 -0800235 } else {
Romain Guy253f2c22016-09-28 17:34:42 -0700236 float alpha = (SkColorGetA(color) / 255.0f) * alphaScale;
Chris Craik0519c812015-02-11 13:17:06 -0800237 mOutGlop->fill.color = { 1, 1, 1, alpha };
Chris Craik03188872015-02-02 18:39:33 -0800238 }
Chris Craik03188872015-02-02 18:39:33 -0800239 } else {
Chris Craik0519c812015-02-11 13:17:06 -0800240 mOutGlop->fill.color = { 0, 0, 0, 1 };
Chris Craik03188872015-02-02 18:39:33 -0800241 }
Chris Craik03188872015-02-02 18:39:33 -0800242
Chris Craik117bdbc2015-02-05 10:12:38 -0800243 mOutGlop->blend = { GL_ZERO, GL_ZERO };
Chris Craik03188872015-02-02 18:39:33 -0800244 if (mOutGlop->fill.color.a < 1.0f
Chris Craik53e51e42015-06-01 10:35:35 -0700245 || (mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::Alpha)
Chris Craikf27133d2015-02-19 09:51:53 -0800246 || (mOutGlop->fill.texture.texture && mOutGlop->fill.texture.texture->blend)
Chris Craik0519c812015-02-11 13:17:06 -0800247 || mOutGlop->roundRectClipState
Chris Craik117bdbc2015-02-05 10:12:38 -0800248 || PaintUtils::isBlendedShader(shader)
Chris Craik03188872015-02-02 18:39:33 -0800249 || PaintUtils::isBlendedColorFilter(colorFilter)
Mike Reed260ab722016-10-07 15:59:20 -0400250 || mode != SkBlendMode::kSrcOver) {
251 if (CC_LIKELY(mode <= SkBlendMode::kScreen)) {
Chris Craik182952f2015-03-09 14:17:29 -0700252 Blend::getFactors(mode, modeUsage,
Chris Craik03188872015-02-02 18:39:33 -0800253 &mOutGlop->blend.src, &mOutGlop->blend.dst);
254 } else {
255 // These blend modes are not supported by OpenGL directly and have
256 // to be implemented using shaders. Since the shader will perform
257 // the blending, don't enable GL blending off here
258 // If the blend mode cannot be implemented using shaders, fall
259 // back to the default SrcOver blend mode instead
Chris Craik117bdbc2015-02-05 10:12:38 -0800260 if (CC_UNLIKELY(mCaches.extensions().hasFramebufferFetch())) {
Mike Reedc2f31df2016-10-28 17:21:45 -0400261 mDescription.framebufferMode = mode;
Chris Craik182952f2015-03-09 14:17:29 -0700262 mDescription.swapSrcDst = (modeUsage == Blend::ModeOrderSwap::Swap);
Chris Craik03188872015-02-02 18:39:33 -0800263 // blending in shader, don't enable
264 } else {
265 // unsupported
Mike Reed260ab722016-10-07 15:59:20 -0400266 Blend::getFactors(SkBlendMode::kSrcOver, modeUsage,
Chris Craik03188872015-02-02 18:39:33 -0800267 &mOutGlop->blend.src, &mOutGlop->blend.dst);
268 }
269 }
270 }
Chris Craik922d3a72015-02-13 17:47:21 -0800271 mShader = shader; // shader resolved in ::build()
Chris Craik03188872015-02-02 18:39:33 -0800272
Chris Craik117bdbc2015-02-05 10:12:38 -0800273 if (colorFilter) {
274 SkColor color;
Mike Reedc2f31df2016-10-28 17:21:45 -0400275 SkBlendMode bmode;
Chris Craik117bdbc2015-02-05 10:12:38 -0800276 SkScalar srcColorMatrix[20];
Mike Reedc2f31df2016-10-28 17:21:45 -0400277 if (colorFilter->asColorMode(&color, &bmode)) {
Chris Craikb9ce116d2015-08-20 15:14:06 -0700278 mOutGlop->fill.filterMode = mDescription.colorOp = ProgramDescription::ColorFilterMode::Blend;
Mike Reedc2f31df2016-10-28 17:21:45 -0400279 mDescription.colorMode = bmode;
Romain Guy253f2c22016-09-28 17:34:42 -0700280 mOutGlop->fill.filter.color.set(color);
Chris Craik117bdbc2015-02-05 10:12:38 -0800281 } else if (colorFilter->asColorMatrix(srcColorMatrix)) {
Chris Craikb9ce116d2015-08-20 15:14:06 -0700282 mOutGlop->fill.filterMode = mDescription.colorOp = ProgramDescription::ColorFilterMode::Matrix;
Chris Craik117bdbc2015-02-05 10:12:38 -0800283
284 float* colorMatrix = mOutGlop->fill.filter.matrix.matrix;
285 memcpy(colorMatrix, srcColorMatrix, 4 * sizeof(float));
286 memcpy(&colorMatrix[4], &srcColorMatrix[5], 4 * sizeof(float));
287 memcpy(&colorMatrix[8], &srcColorMatrix[10], 4 * sizeof(float));
288 memcpy(&colorMatrix[12], &srcColorMatrix[15], 4 * sizeof(float));
289
290 // Skia uses the range [0..255] for the addition vector, but we need
291 // the [0..1] range to apply the vector in GLSL
292 float* colorVector = mOutGlop->fill.filter.matrix.vector;
Romain Guy8762e332016-10-12 12:14:07 -0700293 colorVector[0] = EOCF(srcColorMatrix[4] / 255.0f);
294 colorVector[1] = EOCF(srcColorMatrix[9] / 255.0f);
295 colorVector[2] = EOCF(srcColorMatrix[14] / 255.0f);
296 colorVector[3] = srcColorMatrix[19] / 255.0f; // alpha is linear
Chris Craik2ab95d72015-02-06 15:25:51 -0800297 } else {
298 LOG_ALWAYS_FATAL("unsupported ColorFilter");
Chris Craik117bdbc2015-02-05 10:12:38 -0800299 }
300 } else {
Chris Craikb9ce116d2015-08-20 15:14:06 -0700301 mOutGlop->fill.filterMode = ProgramDescription::ColorFilterMode::None;
Chris Craik117bdbc2015-02-05 10:12:38 -0800302 }
Chris Craik0519c812015-02-11 13:17:06 -0800303}
Chris Craik117bdbc2015-02-05 10:12:38 -0800304
Chris Craik53e51e42015-06-01 10:35:35 -0700305GlopBuilder& GlopBuilder::setFillTexturePaint(Texture& texture,
306 const int textureFillFlags, const SkPaint* paint, float alphaScale) {
Chris Craik0519c812015-02-11 13:17:06 -0800307 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700308 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik0519c812015-02-11 13:17:06 -0800309
Chris Craik53e51e42015-06-01 10:35:35 -0700310 GLenum filter = (textureFillFlags & TextureFillFlags::ForceFilter)
Chris Craika6b52192015-02-27 17:43:02 -0800311 ? GL_LINEAR : PaintUtils::getFilter(paint);
sergeyv2a38c422016-10-25 15:21:50 -0700312 mOutGlop->fill.texture = { &texture, filter, GL_CLAMP_TO_EDGE, nullptr };
Chris Craik0519c812015-02-11 13:17:06 -0800313
314 if (paint) {
315 int color = paint->getColor();
316 SkShader* shader = paint->getShader();
317
Chris Craik53e51e42015-06-01 10:35:35 -0700318 if (!(textureFillFlags & TextureFillFlags::IsAlphaMaskTexture)) {
Chris Craik0519c812015-02-11 13:17:06 -0800319 // Texture defines color, so disable shaders, and reset all non-alpha color channels
320 color |= 0x00FFFFFF;
321 shader = nullptr;
322 }
Chris Craik182952f2015-03-09 14:17:29 -0700323 setFill(color, alphaScale,
Mike Reed260ab722016-10-07 15:59:20 -0400324 paint->getBlendMode(), Blend::ModeOrderSwap::NoSwap,
Chris Craik0519c812015-02-11 13:17:06 -0800325 shader, paint->getColorFilter());
326 } else {
327 mOutGlop->fill.color = { alphaScale, alphaScale, alphaScale, alphaScale };
328
Chris Craik0519c812015-02-11 13:17:06 -0800329 if (alphaScale < 1.0f
Chris Craik53e51e42015-06-01 10:35:35 -0700330 || (mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::Alpha)
Chris Craik0519c812015-02-11 13:17:06 -0800331 || texture.blend
332 || mOutGlop->roundRectClipState) {
Mike Reed260ab722016-10-07 15:59:20 -0400333 Blend::getFactors(SkBlendMode::kSrcOver, Blend::ModeOrderSwap::NoSwap,
Chris Craik0519c812015-02-11 13:17:06 -0800334 &mOutGlop->blend.src, &mOutGlop->blend.dst);
335 } else {
336 mOutGlop->blend = { GL_ZERO, GL_ZERO };
337 }
338 }
339
Chris Craik53e51e42015-06-01 10:35:35 -0700340 if (textureFillFlags & TextureFillFlags::IsAlphaMaskTexture) {
Chris Craik2bb8f562015-02-17 16:42:02 -0800341 mDescription.modulate = mOutGlop->fill.color.isNotBlack();
Chris Craika6b52192015-02-27 17:43:02 -0800342 mDescription.hasAlpha8Texture = true;
Chris Craik0519c812015-02-11 13:17:06 -0800343 } else {
344 mDescription.modulate = mOutGlop->fill.color.a < 1.0f;
345 }
Chris Craik03188872015-02-02 18:39:33 -0800346 return *this;
347}
348
Chris Craik138c21f2016-04-28 16:59:42 -0700349GlopBuilder& GlopBuilder::setFillPaint(const SkPaint& paint, float alphaScale, bool shadowInterp) {
Chris Craik0519c812015-02-11 13:17:06 -0800350 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700351 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik0519c812015-02-11 13:17:06 -0800352
Chris Craik138c21f2016-04-28 16:59:42 -0700353 if (CC_LIKELY(!shadowInterp)) {
354 mOutGlop->fill.texture = {
sergeyv2a38c422016-10-25 15:21:50 -0700355 nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
Chris Craik138c21f2016-04-28 16:59:42 -0700356 } else {
357 mOutGlop->fill.texture = {
sergeyv2a38c422016-10-25 15:21:50 -0700358 mCaches.textureState().getShadowLutTexture(),
Chris Craik138c21f2016-04-28 16:59:42 -0700359 GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
360 }
Chris Craik0519c812015-02-11 13:17:06 -0800361
Chris Craik182952f2015-03-09 14:17:29 -0700362 setFill(paint.getColor(), alphaScale,
Mike Reed260ab722016-10-07 15:59:20 -0400363 paint.getBlendMode(), Blend::ModeOrderSwap::NoSwap,
Chris Craik0519c812015-02-11 13:17:06 -0800364 paint.getShader(), paint.getColorFilter());
Chris Craik138c21f2016-04-28 16:59:42 -0700365 mDescription.useShadowAlphaInterp = shadowInterp;
Chris Craik0519c812015-02-11 13:17:06 -0800366 mDescription.modulate = mOutGlop->fill.color.a < 1.0f;
367 return *this;
368}
369
Chris Craik2bb8f562015-02-17 16:42:02 -0800370GlopBuilder& GlopBuilder::setFillPathTexturePaint(PathTexture& texture,
Chris Craik30036092015-02-12 10:41:39 -0800371 const SkPaint& paint, float alphaScale) {
372 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700373 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik30036092015-02-12 10:41:39 -0800374
Chris Craikf27133d2015-02-19 09:51:53 -0800375 //specify invalid filter/clamp, since these are always static for PathTextures
sergeyv2a38c422016-10-25 15:21:50 -0700376 mOutGlop->fill.texture = { &texture, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
Chris Craik30036092015-02-12 10:41:39 -0800377
Chris Craik182952f2015-03-09 14:17:29 -0700378 setFill(paint.getColor(), alphaScale,
Mike Reed260ab722016-10-07 15:59:20 -0400379 paint.getBlendMode(), Blend::ModeOrderSwap::NoSwap,
Chris Craik30036092015-02-12 10:41:39 -0800380 paint.getShader(), paint.getColorFilter());
381
Chris Craikf27133d2015-02-19 09:51:53 -0800382 mDescription.hasAlpha8Texture = true;
Chris Craik2bb8f562015-02-17 16:42:02 -0800383 mDescription.modulate = mOutGlop->fill.color.isNotBlack();
Chris Craik30036092015-02-12 10:41:39 -0800384 return *this;
385}
386
Chris Craik2bb8f562015-02-17 16:42:02 -0800387GlopBuilder& GlopBuilder::setFillShadowTexturePaint(ShadowTexture& texture, int shadowColor,
388 const SkPaint& paint, float alphaScale) {
389 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700390 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik2bb8f562015-02-17 16:42:02 -0800391
Chris Craikf27133d2015-02-19 09:51:53 -0800392 //specify invalid filter/clamp, since these are always static for ShadowTextures
sergeyv2a38c422016-10-25 15:21:50 -0700393 mOutGlop->fill.texture = { &texture, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
Chris Craik2bb8f562015-02-17 16:42:02 -0800394
395 const int ALPHA_BITMASK = SK_ColorBLACK;
396 const int COLOR_BITMASK = ~ALPHA_BITMASK;
397 if ((shadowColor & ALPHA_BITMASK) == ALPHA_BITMASK) {
398 // shadow color is fully opaque: override its alpha with that of paint
399 shadowColor &= paint.getColor() | COLOR_BITMASK;
400 }
401
Chris Craik182952f2015-03-09 14:17:29 -0700402 setFill(shadowColor, alphaScale,
Mike Reed260ab722016-10-07 15:59:20 -0400403 paint.getBlendMode(), Blend::ModeOrderSwap::NoSwap,
Chris Craik2bb8f562015-02-17 16:42:02 -0800404 paint.getShader(), paint.getColorFilter());
405
Chris Craikf27133d2015-02-19 09:51:53 -0800406 mDescription.hasAlpha8Texture = true;
Chris Craik2bb8f562015-02-17 16:42:02 -0800407 mDescription.modulate = mOutGlop->fill.color.isNotBlack();
408 return *this;
409}
410
411GlopBuilder& GlopBuilder::setFillBlack() {
412 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700413 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik2bb8f562015-02-17 16:42:02 -0800414
sergeyv2a38c422016-10-25 15:21:50 -0700415 mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
Mike Reed260ab722016-10-07 15:59:20 -0400416 setFill(SK_ColorBLACK, 1.0f, SkBlendMode::kSrcOver, Blend::ModeOrderSwap::NoSwap,
Chris Craik182952f2015-03-09 14:17:29 -0700417 nullptr, nullptr);
Chris Craik2bb8f562015-02-17 16:42:02 -0800418 return *this;
419}
420
421GlopBuilder& GlopBuilder::setFillClear() {
422 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700423 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik2bb8f562015-02-17 16:42:02 -0800424
sergeyv2a38c422016-10-25 15:21:50 -0700425 mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
Mike Reed260ab722016-10-07 15:59:20 -0400426 setFill(SK_ColorBLACK, 1.0f, SkBlendMode::kClear, Blend::ModeOrderSwap::NoSwap,
Chris Craik182952f2015-03-09 14:17:29 -0700427 nullptr, nullptr);
Chris Craik2bb8f562015-02-17 16:42:02 -0800428 return *this;
429}
Chris Craikf27133d2015-02-19 09:51:53 -0800430
431GlopBuilder& GlopBuilder::setFillLayer(Texture& texture, const SkColorFilter* colorFilter,
Mike Reed260ab722016-10-07 15:59:20 -0400432 float alpha, SkBlendMode mode, Blend::ModeOrderSwap modeUsage) {
Chris Craikf27133d2015-02-19 09:51:53 -0800433 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700434 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craikf27133d2015-02-19 09:51:53 -0800435
sergeyv2a38c422016-10-25 15:21:50 -0700436 mOutGlop->fill.texture = { &texture, GL_LINEAR, GL_CLAMP_TO_EDGE, nullptr };
Chris Craikf27133d2015-02-19 09:51:53 -0800437
Chris Craik182952f2015-03-09 14:17:29 -0700438 setFill(SK_ColorWHITE, alpha, mode, modeUsage, nullptr, colorFilter);
Chris Craikf27133d2015-02-19 09:51:53 -0800439
440 mDescription.modulate = mOutGlop->fill.color.a < 1.0f;
441 return *this;
442}
443
Greg Daniel8cd3edf2017-01-09 14:15:41 -0500444GlopBuilder& GlopBuilder::setFillTextureLayer(GlLayer& layer, float alpha) {
Chris Craik26bf3422015-02-26 16:28:17 -0800445 TRIGGER_STAGE(kFillStage);
Chris Craikb1f990d2015-06-12 11:28:52 -0700446 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
Chris Craik26bf3422015-02-26 16:28:17 -0800447
448 mOutGlop->fill.texture = { &(layer.getTexture()),
sergeyv2a38c422016-10-25 15:21:50 -0700449 GL_LINEAR, GL_CLAMP_TO_EDGE, &layer.getTexTransform() };
Chris Craik26bf3422015-02-26 16:28:17 -0800450
Chris Craik182952f2015-03-09 14:17:29 -0700451 setFill(SK_ColorWHITE, alpha, layer.getMode(), Blend::ModeOrderSwap::NoSwap,
452 nullptr, layer.getColorFilter());
Chris Craik26bf3422015-02-26 16:28:17 -0800453
454 mDescription.modulate = mOutGlop->fill.color.a < 1.0f;
455 mDescription.hasTextureTransform = true;
456 return *this;
457}
458
John Reck7bf96a02017-06-28 11:08:07 -0700459GlopBuilder& GlopBuilder::setFillExternalTexture(Texture& texture, Matrix4& textureTransform,
460 bool requiresFilter) {
John Reck2f783272016-04-19 07:51:13 -0700461 TRIGGER_STAGE(kFillStage);
462 REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);
463
John Reck7bf96a02017-06-28 11:08:07 -0700464 GLenum filter = requiresFilter ? GL_LINEAR : GL_NEAREST;
465 mOutGlop->fill.texture = { &texture, filter, GL_CLAMP_TO_EDGE, &textureTransform };
John Reck2f783272016-04-19 07:51:13 -0700466
Mike Reed260ab722016-10-07 15:59:20 -0400467 setFill(SK_ColorWHITE, 1.0f, SkBlendMode::kSrc, Blend::ModeOrderSwap::NoSwap,
John Reck2f783272016-04-19 07:51:13 -0700468 nullptr, nullptr);
469
470 mDescription.modulate = mOutGlop->fill.color.a < 1.0f;
John Reck2f69d6d2016-04-28 13:18:51 -0700471 mDescription.hasTextureTransform = true;
John Reck2f783272016-04-19 07:51:13 -0700472 return *this;
473}
474
Romain Guy253f2c22016-09-28 17:34:42 -0700475GlopBuilder& GlopBuilder::setGammaCorrection(bool enabled) {
476 REQUIRE_STAGES(kFillStage);
477
478 mDescription.hasGammaCorrection = enabled;
479 return *this;
480}
481
Chris Craik0519c812015-02-11 13:17:06 -0800482////////////////////////////////////////////////////////////////////////////////
483// Transform
484////////////////////////////////////////////////////////////////////////////////
485
Chris Craikb565df12015-10-05 13:00:52 -0700486GlopBuilder& GlopBuilder::setTransform(const Matrix4& canvas, const int transformFlags) {
Chris Craik0519c812015-02-11 13:17:06 -0800487 TRIGGER_STAGE(kTransformStage);
488
Chris Craik7c85c542015-08-19 15:10:24 -0700489 mOutGlop->transform.canvas = canvas;
Chris Craik53e51e42015-06-01 10:35:35 -0700490 mOutGlop->transform.transformFlags = transformFlags;
Chris Craikb565df12015-10-05 13:00:52 -0700491 return *this;
Chris Craik0519c812015-02-11 13:17:06 -0800492}
493
Chris Craik0519c812015-02-11 13:17:06 -0800494////////////////////////////////////////////////////////////////////////////////
495// ModelView
496////////////////////////////////////////////////////////////////////////////////
497
498GlopBuilder& GlopBuilder::setModelViewMapUnitToRect(const Rect destination) {
499 TRIGGER_STAGE(kModelViewStage);
500
501 mOutGlop->transform.modelView.loadTranslate(destination.left, destination.top, 0.0f);
502 mOutGlop->transform.modelView.scale(destination.getWidth(), destination.getHeight(), 1.0f);
Chris Craik0519c812015-02-11 13:17:06 -0800503 return *this;
504}
505
506GlopBuilder& GlopBuilder::setModelViewMapUnitToRectSnap(const Rect destination) {
507 TRIGGER_STAGE(kModelViewStage);
508 REQUIRE_STAGES(kTransformStage | kFillStage);
509
510 float left = destination.left;
511 float top = destination.top;
512
Chris Craik53e51e42015-06-01 10:35:35 -0700513 const Matrix4& meshTransform = mOutGlop->transform.meshTransform();
514 if (CC_LIKELY(meshTransform.isPureTranslate())) {
Chris Craikf27133d2015-02-19 09:51:53 -0800515 // snap by adjusting the model view matrix
Chris Craik53e51e42015-06-01 10:35:35 -0700516 const float translateX = meshTransform.getTranslateX();
517 const float translateY = meshTransform.getTranslateY();
Chris Craik0519c812015-02-11 13:17:06 -0800518
519 left = (int) floorf(left + translateX + 0.5f) - translateX;
520 top = (int) floorf(top + translateY + 0.5f) - translateY;
Chris Craikf27133d2015-02-19 09:51:53 -0800521 mOutGlop->fill.texture.filter = GL_NEAREST;
Chris Craik0519c812015-02-11 13:17:06 -0800522 }
523
524 mOutGlop->transform.modelView.loadTranslate(left, top, 0.0f);
525 mOutGlop->transform.modelView.scale(destination.getWidth(), destination.getHeight(), 1.0f);
Chris Craik0519c812015-02-11 13:17:06 -0800526 return *this;
527}
528
529GlopBuilder& GlopBuilder::setModelViewOffsetRect(float offsetX, float offsetY, const Rect source) {
530 TRIGGER_STAGE(kModelViewStage);
531
532 mOutGlop->transform.modelView.loadTranslate(offsetX, offsetY, 0.0f);
Chris Craik0519c812015-02-11 13:17:06 -0800533 return *this;
534}
535
Chris Craikf27133d2015-02-19 09:51:53 -0800536GlopBuilder& GlopBuilder::setModelViewOffsetRectSnap(float offsetX, float offsetY, const Rect source) {
537 TRIGGER_STAGE(kModelViewStage);
538 REQUIRE_STAGES(kTransformStage | kFillStage);
539
Chris Craik53e51e42015-06-01 10:35:35 -0700540 const Matrix4& meshTransform = mOutGlop->transform.meshTransform();
541 if (CC_LIKELY(meshTransform.isPureTranslate())) {
Chris Craikf27133d2015-02-19 09:51:53 -0800542 // snap by adjusting the model view matrix
Chris Craik53e51e42015-06-01 10:35:35 -0700543 const float translateX = meshTransform.getTranslateX();
544 const float translateY = meshTransform.getTranslateY();
Chris Craikf27133d2015-02-19 09:51:53 -0800545
546 offsetX = (int) floorf(offsetX + translateX + source.left + 0.5f) - translateX - source.left;
547 offsetY = (int) floorf(offsetY + translateY + source.top + 0.5f) - translateY - source.top;
548 mOutGlop->fill.texture.filter = GL_NEAREST;
549 }
550
551 mOutGlop->transform.modelView.loadTranslate(offsetX, offsetY, 0.0f);
Chris Craikf27133d2015-02-19 09:51:53 -0800552 return *this;
553}
554
555////////////////////////////////////////////////////////////////////////////////
556// RoundRectClip
557////////////////////////////////////////////////////////////////////////////////
558
Chris Craik0519c812015-02-11 13:17:06 -0800559GlopBuilder& GlopBuilder::setRoundRectClipState(const RoundRectClipState* roundRectClipState) {
560 TRIGGER_STAGE(kRoundRectClipStage);
561
562 mOutGlop->roundRectClipState = roundRectClipState;
563 mDescription.hasRoundRectClip = roundRectClipState != nullptr;
564 return *this;
565}
566
567////////////////////////////////////////////////////////////////////////////////
568// Build
569////////////////////////////////////////////////////////////////////////////////
570
Chris Craikf27133d2015-02-19 09:51:53 -0800571void verify(const ProgramDescription& description, const Glop& glop) {
Chris Craikeb911c22015-03-06 17:30:11 -0800572 if (glop.fill.texture.texture != nullptr) {
573 LOG_ALWAYS_FATAL_IF(((description.hasTexture && description.hasExternalTexture)
Chris Craik138c21f2016-04-28 16:59:42 -0700574 || (!description.hasTexture
575 && !description.hasExternalTexture
576 && !description.useShadowAlphaInterp)
577 || ((glop.mesh.vertices.attribFlags & VertexAttribFlags::TextureCoord) == 0
578 && !description.useShadowAlphaInterp)),
Chris Craikeb911c22015-03-06 17:30:11 -0800579 "Texture %p, hT%d, hET %d, attribFlags %x",
580 glop.fill.texture.texture,
581 description.hasTexture, description.hasExternalTexture,
582 glop.mesh.vertices.attribFlags);
583 } else {
584 LOG_ALWAYS_FATAL_IF((description.hasTexture
585 || description.hasExternalTexture
Chris Craik53e51e42015-06-01 10:35:35 -0700586 || ((glop.mesh.vertices.attribFlags & VertexAttribFlags::TextureCoord) != 0)),
Chris Craikeb911c22015-03-06 17:30:11 -0800587 "No texture, hT%d, hET %d, attribFlags %x",
588 description.hasTexture, description.hasExternalTexture,
589 glop.mesh.vertices.attribFlags);
590 }
Chris Craikef250742015-02-25 17:16:16 -0800591
Chris Craik53e51e42015-06-01 10:35:35 -0700592 if ((glop.mesh.vertices.attribFlags & VertexAttribFlags::Alpha)
Chris Craikeb911c22015-03-06 17:30:11 -0800593 && glop.mesh.vertices.bufferObject) {
Chris Craikef250742015-02-25 17:16:16 -0800594 LOG_ALWAYS_FATAL("VBO and alpha attributes are not currently compatible");
595 }
Chris Craik26bf3422015-02-26 16:28:17 -0800596
597 if (description.hasTextureTransform != (glop.fill.texture.textureTransform != nullptr)) {
598 LOG_ALWAYS_FATAL("Texture transform incorrectly specified");
599 }
Chris Craikf27133d2015-02-19 09:51:53 -0800600}
601
Chris Craik03188872015-02-02 18:39:33 -0800602void GlopBuilder::build() {
Chris Craik08fa43f2015-02-09 18:58:32 -0800603 REQUIRE_STAGES(kAllStages);
Chris Craik53e51e42015-06-01 10:35:35 -0700604 if (mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::TextureCoord) {
Romain Guy55455182017-04-15 21:41:22 -0700605 Texture* texture = mOutGlop->fill.texture.texture;
606 if (texture->target() == GL_TEXTURE_2D) {
Chris Craik48f650c2015-03-10 11:03:39 -0700607 mDescription.hasTexture = true;
608 } else {
609 mDescription.hasExternalTexture = true;
610 }
Romain Guycaaaa662017-03-27 00:40:21 -0700611 mDescription.hasLinearTexture = texture->isLinear();
612 mDescription.hasColorSpaceConversion = texture->hasColorSpaceConversion();
613 mDescription.transferFunction = texture->getTransferFunctionType();
614 mDescription.hasTranslucentConversion = texture->blend;
Chris Craik26bf3422015-02-26 16:28:17 -0800615 }
Chris Craik53e51e42015-06-01 10:35:35 -0700616
617 mDescription.hasColors = mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::Color;
618 mDescription.hasVertexAlpha = mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::Alpha;
Chris Craikef250742015-02-25 17:16:16 -0800619
Chris Craik82840732015-04-03 09:37:49 -0700620 // Enable debug highlight when what we're about to draw is tested against
621 // the stencil buffer and if stencil highlight debugging is on
Chris Craik2507c342015-05-04 14:36:49 -0700622 mDescription.hasDebugHighlight = !Properties::debugOverdraw
623 && Properties::debugStencilClip == StencilClipDebug::ShowHighlight
Chris Craik82840732015-04-03 09:37:49 -0700624 && mRenderState.stencil().isTestEnabled();
625
Chris Craik922d3a72015-02-13 17:47:21 -0800626 // serialize shader info into ShaderData
Chris Craikf27133d2015-02-19 09:51:53 -0800627 GLuint textureUnit = mOutGlop->fill.texture.texture ? 1 : 0;
Chris Craik53e51e42015-06-01 10:35:35 -0700628
629 if (CC_LIKELY(!mShader)) {
630 mOutGlop->fill.skiaShaderData.skiaShaderType = kNone_SkiaShaderType;
631 } else {
632 Matrix4 shaderMatrix;
633 if (mOutGlop->transform.transformFlags & TransformFlags::MeshIgnoresCanvasTransform) {
634 // canvas level transform was built into the modelView and geometry,
635 // so the shader matrix must reverse this
636 shaderMatrix.loadInverse(mOutGlop->transform.canvas);
637 shaderMatrix.multiply(mOutGlop->transform.modelView);
638 } else {
Chris Craik7c85c542015-08-19 15:10:24 -0700639 shaderMatrix = mOutGlop->transform.modelView;
Chris Craik53e51e42015-06-01 10:35:35 -0700640 }
641 SkiaShader::store(mCaches, *mShader, shaderMatrix,
642 &textureUnit, &mDescription, &(mOutGlop->fill.skiaShaderData));
643 }
Chris Craik922d3a72015-02-13 17:47:21 -0800644
Chris Craik0519c812015-02-11 13:17:06 -0800645 // duplicates ProgramCache's definition of color uniform presence
646 const bool singleColor = !mDescription.hasTexture
647 && !mDescription.hasExternalTexture
648 && !mDescription.hasGradient
649 && !mDescription.hasBitmap;
650 mOutGlop->fill.colorEnabled = mDescription.modulate || singleColor;
Chris Craikf27133d2015-02-19 09:51:53 -0800651
652 verify(mDescription, *mOutGlop);
Chris Craikef250742015-02-25 17:16:16 -0800653
654 // Final step: populate program and map bounds into render target space
655 mOutGlop->fill.program = mCaches.programCache.get(mDescription);
Chris Craik03188872015-02-02 18:39:33 -0800656}
657
Chris Craikb565df12015-10-05 13:00:52 -0700658void GlopBuilder::dump(const Glop& glop) {
659 ALOGD("Glop Mesh");
660 const Glop::Mesh& mesh = glop.mesh;
661 ALOGD(" primitive mode: %d", mesh.primitiveMode);
662 ALOGD(" indices: buffer obj %x, indices %p", mesh.indices.bufferObject, mesh.indices.indices);
663
664 const Glop::Mesh::Vertices& vertices = glop.mesh.vertices;
665 ALOGD(" vertices: buffer obj %x, flags %x, pos %p, tex %p, clr %p, stride %d",
666 vertices.bufferObject, vertices.attribFlags,
667 vertices.position, vertices.texCoord, vertices.color, vertices.stride);
668 ALOGD(" element count: %d", mesh.elementCount);
669
670 ALOGD("Glop Fill");
671 const Glop::Fill& fill = glop.fill;
672 ALOGD(" program %p", fill.program);
673 if (fill.texture.texture) {
674 ALOGD(" texture %p, target %d, filter %d, clamp %d",
sergeyv2a38c422016-10-25 15:21:50 -0700675 fill.texture.texture, fill.texture.texture->target(),
676 fill.texture.filter, fill.texture.clamp);
Chris Craikb565df12015-10-05 13:00:52 -0700677 if (fill.texture.textureTransform) {
678 fill.texture.textureTransform->dump("texture transform");
679 }
680 }
681 ALOGD_IF(fill.colorEnabled, " color (argb) %.2f %.2f %.2f %.2f",
682 fill.color.a, fill.color.r, fill.color.g, fill.color.b);
683 ALOGD_IF(fill.filterMode != ProgramDescription::ColorFilterMode::None,
684 " filterMode %d", (int)fill.filterMode);
685 ALOGD_IF(fill.skiaShaderData.skiaShaderType, " shader type %d",
686 fill.skiaShaderData.skiaShaderType);
687
688 ALOGD("Glop transform");
Chris Craik701b3cc2016-03-11 18:39:01 -0800689 glop.transform.modelView.dump(" model view");
690 glop.transform.canvas.dump(" canvas");
691 ALOGD_IF(glop.transform.transformFlags, " transformFlags 0x%x", glop.transform.transformFlags);
692
693 ALOGD_IF(glop.roundRectClipState, "Glop RRCS %p", glop.roundRectClipState);
Chris Craikb565df12015-10-05 13:00:52 -0700694
695 ALOGD("Glop blend %d %d", glop.blend.src, glop.blend.dst);
Chris Craikb565df12015-10-05 13:00:52 -0700696}
697
Chris Craik03188872015-02-02 18:39:33 -0800698} /* namespace uirenderer */
699} /* namespace android */