blob: 6fc8bce50ed49fe2cfb2560b41f8520651ac70d7 [file] [log] [blame]
John Reckacb6f072014-03-12 16:11:23 -07001/*
2 * Copyright (C) 2014 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 */
Chris Craikb49f4462014-03-20 12:44:20 -070016#ifndef RENDERNODEPROPERTIES_H
17#define RENDERNODEPROPERTIES_H
John Reckacb6f072014-03-12 16:11:23 -070018
John Recke45b1fd2014-04-15 09:50:16 -070019#include <algorithm>
John Reckacb6f072014-03-12 16:11:23 -070020#include <stddef.h>
John Recke45b1fd2014-04-15 09:50:16 -070021#include <vector>
John Reckacb6f072014-03-12 16:11:23 -070022#include <cutils/compiler.h>
23#include <androidfw/ResourceTypes.h>
24
25#include <SkCamera.h>
26#include <SkMatrix.h>
Chris Craik8c271ca2014-03-25 10:33:01 -070027#include <SkRegion.h>
Chris Craikb49f4462014-03-20 12:44:20 -070028
John Recke45b1fd2014-04-15 09:50:16 -070029#include "Animator.h"
Chris Craikb49f4462014-03-20 12:44:20 -070030#include "Rect.h"
Chris Craik8c271ca2014-03-25 10:33:01 -070031#include "RevealClip.h"
Chris Craikb49f4462014-03-20 12:44:20 -070032#include "Outline.h"
John Reckacb6f072014-03-12 16:11:23 -070033
John Reckacb6f072014-03-12 16:11:23 -070034class SkBitmap;
35class SkPaint;
John Reckacb6f072014-03-12 16:11:23 -070036
37namespace android {
38namespace uirenderer {
39
40class Matrix4;
41class RenderNode;
42
43/*
44 * Data structure that holds the properties for a RenderNode
45 */
46class RenderProperties {
47public:
48 RenderProperties();
49 virtual ~RenderProperties();
50
John Reckd0a0b2a2014-03-20 16:28:56 -070051 RenderProperties& operator=(const RenderProperties& other);
52
John Reckacb6f072014-03-12 16:11:23 -070053 void setClipToBounds(bool clipToBounds) {
John Reckd0a0b2a2014-03-20 16:28:56 -070054 mPrimitiveFields.mClipToBounds = clipToBounds;
John Reckacb6f072014-03-12 16:11:23 -070055 }
56
John Reckacb6f072014-03-12 16:11:23 -070057 void setProjectBackwards(bool shouldProject) {
John Reckd0a0b2a2014-03-20 16:28:56 -070058 mPrimitiveFields.mProjectBackwards = shouldProject;
John Reckacb6f072014-03-12 16:11:23 -070059 }
60
61 void setProjectionReceiver(bool shouldRecieve) {
John Reckd0a0b2a2014-03-20 16:28:56 -070062 mPrimitiveFields.mProjectionReceiver = shouldRecieve;
John Reckacb6f072014-03-12 16:11:23 -070063 }
64
John Reckd0a0b2a2014-03-20 16:28:56 -070065 bool isProjectionReceiver() const {
66 return mPrimitiveFields.mProjectionReceiver;
John Reckacb6f072014-03-12 16:11:23 -070067 }
68
John Reckd0a0b2a2014-03-20 16:28:56 -070069 void setStaticMatrix(const SkMatrix* matrix) {
John Reckacb6f072014-03-12 16:11:23 -070070 delete mStaticMatrix;
John Reckd0a0b2a2014-03-20 16:28:56 -070071 if (matrix) {
72 mStaticMatrix = new SkMatrix(*matrix);
73 } else {
74 mStaticMatrix = NULL;
75 }
John Reckacb6f072014-03-12 16:11:23 -070076 }
77
78 // Can return NULL
John Reckd0a0b2a2014-03-20 16:28:56 -070079 const SkMatrix* getStaticMatrix() const {
John Reckacb6f072014-03-12 16:11:23 -070080 return mStaticMatrix;
81 }
82
John Reckd0a0b2a2014-03-20 16:28:56 -070083 void setAnimationMatrix(const SkMatrix* matrix) {
John Reckacb6f072014-03-12 16:11:23 -070084 delete mAnimationMatrix;
85 if (matrix) {
86 mAnimationMatrix = new SkMatrix(*matrix);
87 } else {
88 mAnimationMatrix = NULL;
89 }
90 }
91
92 void setAlpha(float alpha) {
93 alpha = fminf(1.0f, fmaxf(0.0f, alpha));
John Reckd0a0b2a2014-03-20 16:28:56 -070094 if (alpha != mPrimitiveFields.mAlpha) {
95 mPrimitiveFields.mAlpha = alpha;
John Reckacb6f072014-03-12 16:11:23 -070096 }
97 }
98
99 float getAlpha() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700100 return mPrimitiveFields.mAlpha;
John Reckacb6f072014-03-12 16:11:23 -0700101 }
102
103 void setHasOverlappingRendering(bool hasOverlappingRendering) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700104 mPrimitiveFields.mHasOverlappingRendering = hasOverlappingRendering;
John Reckacb6f072014-03-12 16:11:23 -0700105 }
106
107 bool hasOverlappingRendering() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700108 return mPrimitiveFields.mHasOverlappingRendering;
John Reckacb6f072014-03-12 16:11:23 -0700109 }
110
Chris Craikcc39e162014-04-25 18:34:11 -0700111 void setElevation(float elevation) {
112 if (elevation != mPrimitiveFields.mElevation) {
113 mPrimitiveFields.mElevation = elevation;
114 // mMatrixOrPivotDirty not set, since matrix doesn't respect Z
115 }
116 }
117
118 float getElevation() const {
119 return mPrimitiveFields.mElevation;
120 }
121
John Reckacb6f072014-03-12 16:11:23 -0700122 void setTranslationX(float translationX) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700123 if (translationX != mPrimitiveFields.mTranslationX) {
124 mPrimitiveFields.mTranslationX = translationX;
John Reckf7483e32014-04-11 08:54:47 -0700125 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700126 }
127 }
128
129 float getTranslationX() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700130 return mPrimitiveFields.mTranslationX;
John Reckacb6f072014-03-12 16:11:23 -0700131 }
132
133 void setTranslationY(float translationY) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700134 if (translationY != mPrimitiveFields.mTranslationY) {
135 mPrimitiveFields.mTranslationY = translationY;
John Reckf7483e32014-04-11 08:54:47 -0700136 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700137 }
138 }
139
140 float getTranslationY() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700141 return mPrimitiveFields.mTranslationY;
John Reckacb6f072014-03-12 16:11:23 -0700142 }
143
144 void setTranslationZ(float translationZ) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700145 if (translationZ != mPrimitiveFields.mTranslationZ) {
146 mPrimitiveFields.mTranslationZ = translationZ;
Chris Craikcc39e162014-04-25 18:34:11 -0700147 // mMatrixOrPivotDirty not set, since matrix doesn't respect Z
John Reckacb6f072014-03-12 16:11:23 -0700148 }
149 }
150
151 float getTranslationZ() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700152 return mPrimitiveFields.mTranslationZ;
John Reckacb6f072014-03-12 16:11:23 -0700153 }
154
John Recke45b1fd2014-04-15 09:50:16 -0700155 // Animation helper
156 void setX(float value) {
157 setTranslationX(value - getLeft());
158 }
159
160 // Animation helper
161 float getX() const {
162 return getLeft() + getTranslationX();
163 }
164
165 // Animation helper
166 void setY(float value) {
167 setTranslationY(value - getTop());
168 }
169
170 // Animation helper
171 float getY() const {
172 return getTop() + getTranslationY();
173 }
174
175 // Animation helper
176 void setZ(float value) {
177 setTranslationZ(value - getElevation());
178 }
179
Chris Craikcc39e162014-04-25 18:34:11 -0700180 float getZ() const {
181 return getElevation() + getTranslationZ();
182 }
183
John Reckacb6f072014-03-12 16:11:23 -0700184 void setRotation(float rotation) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700185 if (rotation != mPrimitiveFields.mRotation) {
186 mPrimitiveFields.mRotation = rotation;
John Reckf7483e32014-04-11 08:54:47 -0700187 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700188 }
189 }
190
191 float getRotation() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700192 return mPrimitiveFields.mRotation;
John Reckacb6f072014-03-12 16:11:23 -0700193 }
194
195 void setRotationX(float rotationX) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700196 if (rotationX != mPrimitiveFields.mRotationX) {
197 mPrimitiveFields.mRotationX = rotationX;
John Reckf7483e32014-04-11 08:54:47 -0700198 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700199 }
200 }
201
202 float getRotationX() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700203 return mPrimitiveFields.mRotationX;
John Reckacb6f072014-03-12 16:11:23 -0700204 }
205
206 void setRotationY(float rotationY) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700207 if (rotationY != mPrimitiveFields.mRotationY) {
208 mPrimitiveFields.mRotationY = rotationY;
John Reckf7483e32014-04-11 08:54:47 -0700209 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700210 }
211 }
212
213 float getRotationY() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700214 return mPrimitiveFields.mRotationY;
John Reckacb6f072014-03-12 16:11:23 -0700215 }
216
217 void setScaleX(float scaleX) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700218 if (scaleX != mPrimitiveFields.mScaleX) {
219 mPrimitiveFields.mScaleX = scaleX;
John Reckf7483e32014-04-11 08:54:47 -0700220 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700221 }
222 }
223
224 float getScaleX() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700225 return mPrimitiveFields.mScaleX;
John Reckacb6f072014-03-12 16:11:23 -0700226 }
227
228 void setScaleY(float scaleY) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700229 if (scaleY != mPrimitiveFields.mScaleY) {
230 mPrimitiveFields.mScaleY = scaleY;
John Reckf7483e32014-04-11 08:54:47 -0700231 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700232 }
233 }
234
235 float getScaleY() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700236 return mPrimitiveFields.mScaleY;
John Reckacb6f072014-03-12 16:11:23 -0700237 }
238
239 void setPivotX(float pivotX) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700240 mPrimitiveFields.mPivotX = pivotX;
John Reckf7483e32014-04-11 08:54:47 -0700241 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckd0a0b2a2014-03-20 16:28:56 -0700242 mPrimitiveFields.mPivotExplicitlySet = true;
John Reckacb6f072014-03-12 16:11:23 -0700243 }
244
John Reckd0a0b2a2014-03-20 16:28:56 -0700245 /* Note that getPivotX and getPivotY are adjusted by updateMatrix(),
246 * so the value returned mPrimitiveFields.may be stale if the RenderProperties has been
247 * mPrimitiveFields.modified since the last call to updateMatrix()
248 */
249 float getPivotX() const {
250 return mPrimitiveFields.mPivotX;
251 }
John Reckacb6f072014-03-12 16:11:23 -0700252
253 void setPivotY(float pivotY) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700254 mPrimitiveFields.mPivotY = pivotY;
John Reckf7483e32014-04-11 08:54:47 -0700255 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckd0a0b2a2014-03-20 16:28:56 -0700256 mPrimitiveFields.mPivotExplicitlySet = true;
John Reckacb6f072014-03-12 16:11:23 -0700257 }
258
John Reckd0a0b2a2014-03-20 16:28:56 -0700259 float getPivotY() const {
260 return mPrimitiveFields.mPivotY;
261 }
John Reckacb6f072014-03-12 16:11:23 -0700262
Chris Craik49e6c732014-03-31 12:34:11 -0700263 bool isPivotExplicitlySet() const {
264 return mPrimitiveFields.mPivotExplicitlySet;
265 }
266
John Reckacb6f072014-03-12 16:11:23 -0700267 void setCameraDistance(float distance) {
Chris Craik49e6c732014-03-31 12:34:11 -0700268 if (distance != getCameraDistance()) {
John Reckf7483e32014-04-11 08:54:47 -0700269 mPrimitiveFields.mMatrixOrPivotDirty = true;
Chris Craik49e6c732014-03-31 12:34:11 -0700270 mComputedFields.mTransformCamera.setCameraLocation(0, 0, distance);
John Reckacb6f072014-03-12 16:11:23 -0700271 }
272 }
273
274 float getCameraDistance() const {
Chris Craik49e6c732014-03-31 12:34:11 -0700275 // TODO: update getCameraLocationZ() to be const
276 return const_cast<Sk3DView*>(&mComputedFields.mTransformCamera)->getCameraLocationZ();
John Reckacb6f072014-03-12 16:11:23 -0700277 }
278
279 void setLeft(int left) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700280 if (left != mPrimitiveFields.mLeft) {
281 mPrimitiveFields.mLeft = left;
282 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
John Reckf7483e32014-04-11 08:54:47 -0700283 if (!mPrimitiveFields.mPivotExplicitlySet) {
284 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700285 }
286 }
287 }
288
289 float getLeft() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700290 return mPrimitiveFields.mLeft;
John Reckacb6f072014-03-12 16:11:23 -0700291 }
292
293 void setTop(int top) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700294 if (top != mPrimitiveFields.mTop) {
295 mPrimitiveFields.mTop = top;
296 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
John Reckf7483e32014-04-11 08:54:47 -0700297 if (!mPrimitiveFields.mPivotExplicitlySet) {
298 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700299 }
300 }
301 }
302
303 float getTop() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700304 return mPrimitiveFields.mTop;
John Reckacb6f072014-03-12 16:11:23 -0700305 }
306
307 void setRight(int right) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700308 if (right != mPrimitiveFields.mRight) {
309 mPrimitiveFields.mRight = right;
310 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
John Reckf7483e32014-04-11 08:54:47 -0700311 if (!mPrimitiveFields.mPivotExplicitlySet) {
312 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700313 }
314 }
315 }
316
317 float getRight() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700318 return mPrimitiveFields.mRight;
John Reckacb6f072014-03-12 16:11:23 -0700319 }
320
321 void setBottom(int bottom) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700322 if (bottom != mPrimitiveFields.mBottom) {
323 mPrimitiveFields.mBottom = bottom;
324 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
John Reckf7483e32014-04-11 08:54:47 -0700325 if (!mPrimitiveFields.mPivotExplicitlySet) {
326 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700327 }
328 }
329 }
330
331 float getBottom() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700332 return mPrimitiveFields.mBottom;
John Reckacb6f072014-03-12 16:11:23 -0700333 }
334
335 void setLeftTop(int left, int top) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700336 if (left != mPrimitiveFields.mLeft || top != mPrimitiveFields.mTop) {
337 mPrimitiveFields.mLeft = left;
338 mPrimitiveFields.mTop = top;
339 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
340 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
John Reckf7483e32014-04-11 08:54:47 -0700341 if (!mPrimitiveFields.mPivotExplicitlySet) {
342 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700343 }
344 }
345 }
346
347 void setLeftTopRightBottom(int left, int top, int right, int bottom) {
Chris Craikcc39e162014-04-25 18:34:11 -0700348 if (left != mPrimitiveFields.mLeft || top != mPrimitiveFields.mTop
349 || right != mPrimitiveFields.mRight || bottom != mPrimitiveFields.mBottom) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700350 mPrimitiveFields.mLeft = left;
351 mPrimitiveFields.mTop = top;
352 mPrimitiveFields.mRight = right;
353 mPrimitiveFields.mBottom = bottom;
354 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
355 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
John Reckf7483e32014-04-11 08:54:47 -0700356 if (!mPrimitiveFields.mPivotExplicitlySet) {
357 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700358 }
359 }
360 }
361
362 void offsetLeftRight(float offset) {
363 if (offset != 0) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700364 mPrimitiveFields.mLeft += offset;
365 mPrimitiveFields.mRight += offset;
John Reckf7483e32014-04-11 08:54:47 -0700366 if (!mPrimitiveFields.mPivotExplicitlySet) {
367 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700368 }
369 }
370 }
371
372 void offsetTopBottom(float offset) {
373 if (offset != 0) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700374 mPrimitiveFields.mTop += offset;
375 mPrimitiveFields.mBottom += offset;
John Reckf7483e32014-04-11 08:54:47 -0700376 if (!mPrimitiveFields.mPivotExplicitlySet) {
377 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700378 }
379 }
380 }
381
382 void setCaching(bool caching) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700383 mPrimitiveFields.mCaching = caching;
John Reckacb6f072014-03-12 16:11:23 -0700384 }
385
Chris Craikb49f4462014-03-20 12:44:20 -0700386 int getWidth() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700387 return mPrimitiveFields.mWidth;
John Reckacb6f072014-03-12 16:11:23 -0700388 }
389
Chris Craikb49f4462014-03-20 12:44:20 -0700390 int getHeight() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700391 return mPrimitiveFields.mHeight;
John Reckacb6f072014-03-12 16:11:23 -0700392 }
393
John Reckd0a0b2a2014-03-20 16:28:56 -0700394 const SkMatrix* getAnimationMatrix() const {
395 return mAnimationMatrix;
396 }
397
John Reckf7483e32014-04-11 08:54:47 -0700398 bool hasTransformMatrix() const {
399 return getTransformMatrix() && !getTransformMatrix()->isIdentity();
400 }
401
402 // May only call this if hasTransformMatrix() is true
403 bool isTransformTranslateOnly() const {
404 return getTransformMatrix()->getType() == SkMatrix::kTranslate_Mask;
John Reckd0a0b2a2014-03-20 16:28:56 -0700405 }
406
Chris Craik49e6c732014-03-31 12:34:11 -0700407 const SkMatrix* getTransformMatrix() const {
John Reckf7483e32014-04-11 08:54:47 -0700408 LOG_ALWAYS_FATAL_IF(mPrimitiveFields.mMatrixOrPivotDirty, "Cannot get a dirty matrix!");
John Reckd0a0b2a2014-03-20 16:28:56 -0700409 return mComputedFields.mTransformMatrix;
410 }
411
412 bool getCaching() const {
413 return mPrimitiveFields.mCaching;
414 }
415
416 bool getClipToBounds() const {
417 return mPrimitiveFields.mClipToBounds;
418 }
419
420 bool getHasOverlappingRendering() const {
421 return mPrimitiveFields.mHasOverlappingRendering;
422 }
423
424 const Outline& getOutline() const {
425 return mPrimitiveFields.mOutline;
426 }
427
Chris Craik8c271ca2014-03-25 10:33:01 -0700428 const RevealClip& getRevealClip() const {
429 return mPrimitiveFields.mRevealClip;
430 }
431
John Reckd0a0b2a2014-03-20 16:28:56 -0700432 bool getProjectBackwards() const {
433 return mPrimitiveFields.mProjectBackwards;
434 }
435
436 void debugOutputProperties(const int level) const;
437
438 ANDROID_API void updateMatrix();
439
Chris Craik8c271ca2014-03-25 10:33:01 -0700440 ANDROID_API void updateClipPath();
441
442 // signals that mComputedFields.mClipPath is up to date, and should be used for clipping
443 bool hasClippingPath() const {
444 return mPrimitiveFields.mOutline.willClip() || mPrimitiveFields.mRevealClip.willClip();
445 }
446
447 const SkPath* getClippingPath() const {
448 return hasClippingPath() ? mComputedFields.mClipPath : NULL;
449 }
450
451 SkRegion::Op getClippingPathOp() const {
452 return mComputedFields.mClipPathOp;
453 }
454
John Reckd0a0b2a2014-03-20 16:28:56 -0700455 Outline& mutableOutline() {
456 return mPrimitiveFields.mOutline;
Chris Craikb49f4462014-03-20 12:44:20 -0700457 }
458
Chris Craik8c271ca2014-03-25 10:33:01 -0700459 RevealClip& mutableRevealClip() {
460 return mPrimitiveFields.mRevealClip;
461 }
462
John Reckacb6f072014-03-12 16:11:23 -0700463private:
John Reckacb6f072014-03-12 16:11:23 -0700464
John Reckacb6f072014-03-12 16:11:23 -0700465 // Rendering properties
John Reckd0a0b2a2014-03-20 16:28:56 -0700466 struct PrimitiveFields {
467 PrimitiveFields();
John Reckacb6f072014-03-12 16:11:23 -0700468
John Reckd0a0b2a2014-03-20 16:28:56 -0700469 Outline mOutline;
Chris Craik8c271ca2014-03-25 10:33:01 -0700470 RevealClip mRevealClip;
John Reckd0a0b2a2014-03-20 16:28:56 -0700471 bool mClipToBounds;
472 bool mProjectBackwards;
473 bool mProjectionReceiver;
474 float mAlpha;
475 bool mHasOverlappingRendering;
Chris Craikcc39e162014-04-25 18:34:11 -0700476 float mElevation;
John Reckd0a0b2a2014-03-20 16:28:56 -0700477 float mTranslationX, mTranslationY, mTranslationZ;
478 float mRotation, mRotationX, mRotationY;
479 float mScaleX, mScaleY;
480 float mPivotX, mPivotY;
481 int mLeft, mTop, mRight, mBottom;
482 int mWidth, mHeight;
John Reckd0a0b2a2014-03-20 16:28:56 -0700483 bool mPivotExplicitlySet;
John Reckf7483e32014-04-11 08:54:47 -0700484 bool mMatrixOrPivotDirty;
John Reckd0a0b2a2014-03-20 16:28:56 -0700485 bool mCaching;
486 } mPrimitiveFields;
487
John Reckacb6f072014-03-12 16:11:23 -0700488 SkMatrix* mStaticMatrix;
489 SkMatrix* mAnimationMatrix;
John Reckacb6f072014-03-12 16:11:23 -0700490
John Reckd0a0b2a2014-03-20 16:28:56 -0700491 /**
492 * These fields are all generated from other properties and are not set directly.
493 */
494 struct ComputedFields {
495 ComputedFields();
496 ~ComputedFields();
497
498 /**
499 * Stores the total transformation of the DisplayList based upon its scalar
500 * translate/rotate/scale properties.
501 *
Chris Craik49e6c732014-03-31 12:34:11 -0700502 * In the common translation-only case, the matrix isn't necessarily allocated,
503 * and the mTranslation properties are used directly.
John Reckd0a0b2a2014-03-20 16:28:56 -0700504 */
Chris Craik49e6c732014-03-31 12:34:11 -0700505 SkMatrix* mTransformMatrix;
506
507 Sk3DView mTransformCamera;
Chris Craik8c271ca2014-03-25 10:33:01 -0700508 SkPath* mClipPath; // TODO: remove this, create new ops for efficient/special case clipping
509 SkRegion::Op mClipPathOp;
John Reckd0a0b2a2014-03-20 16:28:56 -0700510 } mComputedFields;
John Reckacb6f072014-03-12 16:11:23 -0700511};
512
513} /* namespace uirenderer */
514} /* namespace android */
515
Chris Craikb49f4462014-03-20 12:44:20 -0700516#endif /* RENDERNODEPROPERTIES_H */