blob: dd6821059490488f44a0c702e58fdbb8c8ac7660 [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
19#include <stddef.h>
20#include <cutils/compiler.h>
21#include <androidfw/ResourceTypes.h>
22
23#include <SkCamera.h>
24#include <SkMatrix.h>
Chris Craik8c271ca2014-03-25 10:33:01 -070025#include <SkRegion.h>
Chris Craikb49f4462014-03-20 12:44:20 -070026
27#include "Rect.h"
Chris Craik8c271ca2014-03-25 10:33:01 -070028#include "RevealClip.h"
Chris Craikb49f4462014-03-20 12:44:20 -070029#include "Outline.h"
John Reckacb6f072014-03-12 16:11:23 -070030
31#define TRANSLATION 0x0001
32#define ROTATION 0x0002
33#define ROTATION_3D 0x0004
34#define SCALE 0x0008
35#define PIVOT 0x0010
36
37class SkBitmap;
38class SkPaint;
John Reckacb6f072014-03-12 16:11:23 -070039
40namespace android {
41namespace uirenderer {
42
43class Matrix4;
44class RenderNode;
45
46/*
47 * Data structure that holds the properties for a RenderNode
48 */
49class RenderProperties {
50public:
51 RenderProperties();
52 virtual ~RenderProperties();
53
John Reckd0a0b2a2014-03-20 16:28:56 -070054 RenderProperties& operator=(const RenderProperties& other);
55
John Reckacb6f072014-03-12 16:11:23 -070056 void setClipToBounds(bool clipToBounds) {
John Reckd0a0b2a2014-03-20 16:28:56 -070057 mPrimitiveFields.mClipToBounds = clipToBounds;
John Reckacb6f072014-03-12 16:11:23 -070058 }
59
John Reckacb6f072014-03-12 16:11:23 -070060 void setProjectBackwards(bool shouldProject) {
John Reckd0a0b2a2014-03-20 16:28:56 -070061 mPrimitiveFields.mProjectBackwards = shouldProject;
John Reckacb6f072014-03-12 16:11:23 -070062 }
63
64 void setProjectionReceiver(bool shouldRecieve) {
John Reckd0a0b2a2014-03-20 16:28:56 -070065 mPrimitiveFields.mProjectionReceiver = shouldRecieve;
John Reckacb6f072014-03-12 16:11:23 -070066 }
67
John Reckd0a0b2a2014-03-20 16:28:56 -070068 bool isProjectionReceiver() const {
69 return mPrimitiveFields.mProjectionReceiver;
John Reckacb6f072014-03-12 16:11:23 -070070 }
71
John Reckd0a0b2a2014-03-20 16:28:56 -070072 void setStaticMatrix(const SkMatrix* matrix) {
John Reckacb6f072014-03-12 16:11:23 -070073 delete mStaticMatrix;
John Reckd0a0b2a2014-03-20 16:28:56 -070074 if (matrix) {
75 mStaticMatrix = new SkMatrix(*matrix);
76 } else {
77 mStaticMatrix = NULL;
78 }
John Reckacb6f072014-03-12 16:11:23 -070079 }
80
81 // Can return NULL
John Reckd0a0b2a2014-03-20 16:28:56 -070082 const SkMatrix* getStaticMatrix() const {
John Reckacb6f072014-03-12 16:11:23 -070083 return mStaticMatrix;
84 }
85
John Reckd0a0b2a2014-03-20 16:28:56 -070086 void setAnimationMatrix(const SkMatrix* matrix) {
John Reckacb6f072014-03-12 16:11:23 -070087 delete mAnimationMatrix;
88 if (matrix) {
89 mAnimationMatrix = new SkMatrix(*matrix);
90 } else {
91 mAnimationMatrix = NULL;
92 }
93 }
94
95 void setAlpha(float alpha) {
96 alpha = fminf(1.0f, fmaxf(0.0f, alpha));
John Reckd0a0b2a2014-03-20 16:28:56 -070097 if (alpha != mPrimitiveFields.mAlpha) {
98 mPrimitiveFields.mAlpha = alpha;
John Reckacb6f072014-03-12 16:11:23 -070099 }
100 }
101
102 float getAlpha() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700103 return mPrimitiveFields.mAlpha;
John Reckacb6f072014-03-12 16:11:23 -0700104 }
105
106 void setHasOverlappingRendering(bool hasOverlappingRendering) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700107 mPrimitiveFields.mHasOverlappingRendering = hasOverlappingRendering;
John Reckacb6f072014-03-12 16:11:23 -0700108 }
109
110 bool hasOverlappingRendering() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700111 return mPrimitiveFields.mHasOverlappingRendering;
John Reckacb6f072014-03-12 16:11:23 -0700112 }
113
114 void setTranslationX(float translationX) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700115 if (translationX != mPrimitiveFields.mTranslationX) {
116 mPrimitiveFields.mTranslationX = translationX;
John Reckacb6f072014-03-12 16:11:23 -0700117 onTranslationUpdate();
118 }
119 }
120
121 float getTranslationX() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700122 return mPrimitiveFields.mTranslationX;
John Reckacb6f072014-03-12 16:11:23 -0700123 }
124
125 void setTranslationY(float translationY) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700126 if (translationY != mPrimitiveFields.mTranslationY) {
127 mPrimitiveFields.mTranslationY = translationY;
John Reckacb6f072014-03-12 16:11:23 -0700128 onTranslationUpdate();
129 }
130 }
131
132 float getTranslationY() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700133 return mPrimitiveFields.mTranslationY;
John Reckacb6f072014-03-12 16:11:23 -0700134 }
135
136 void setTranslationZ(float translationZ) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700137 if (translationZ != mPrimitiveFields.mTranslationZ) {
138 mPrimitiveFields.mTranslationZ = translationZ;
John Reckacb6f072014-03-12 16:11:23 -0700139 onTranslationUpdate();
140 }
141 }
142
143 float getTranslationZ() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700144 return mPrimitiveFields.mTranslationZ;
John Reckacb6f072014-03-12 16:11:23 -0700145 }
146
147 void setRotation(float rotation) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700148 if (rotation != mPrimitiveFields.mRotation) {
149 mPrimitiveFields.mRotation = rotation;
150 mPrimitiveFields.mMatrixDirty = true;
151 if (mPrimitiveFields.mRotation == 0.0f) {
152 mPrimitiveFields.mMatrixFlags &= ~ROTATION;
John Reckacb6f072014-03-12 16:11:23 -0700153 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700154 mPrimitiveFields.mMatrixFlags |= ROTATION;
John Reckacb6f072014-03-12 16:11:23 -0700155 }
156 }
157 }
158
159 float getRotation() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700160 return mPrimitiveFields.mRotation;
John Reckacb6f072014-03-12 16:11:23 -0700161 }
162
163 void setRotationX(float rotationX) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700164 if (rotationX != mPrimitiveFields.mRotationX) {
165 mPrimitiveFields.mRotationX = rotationX;
166 mPrimitiveFields.mMatrixDirty = true;
167 if (mPrimitiveFields.mRotationX == 0.0f && mPrimitiveFields.mRotationY == 0.0f) {
168 mPrimitiveFields.mMatrixFlags &= ~ROTATION_3D;
John Reckacb6f072014-03-12 16:11:23 -0700169 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700170 mPrimitiveFields.mMatrixFlags |= ROTATION_3D;
John Reckacb6f072014-03-12 16:11:23 -0700171 }
172 }
173 }
174
175 float getRotationX() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700176 return mPrimitiveFields.mRotationX;
John Reckacb6f072014-03-12 16:11:23 -0700177 }
178
179 void setRotationY(float rotationY) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700180 if (rotationY != mPrimitiveFields.mRotationY) {
181 mPrimitiveFields.mRotationY = rotationY;
182 mPrimitiveFields.mMatrixDirty = true;
183 if (mPrimitiveFields.mRotationX == 0.0f && mPrimitiveFields.mRotationY == 0.0f) {
184 mPrimitiveFields.mMatrixFlags &= ~ROTATION_3D;
John Reckacb6f072014-03-12 16:11:23 -0700185 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700186 mPrimitiveFields.mMatrixFlags |= ROTATION_3D;
John Reckacb6f072014-03-12 16:11:23 -0700187 }
188 }
189 }
190
191 float getRotationY() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700192 return mPrimitiveFields.mRotationY;
John Reckacb6f072014-03-12 16:11:23 -0700193 }
194
195 void setScaleX(float scaleX) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700196 if (scaleX != mPrimitiveFields.mScaleX) {
197 mPrimitiveFields.mScaleX = scaleX;
198 mPrimitiveFields.mMatrixDirty = true;
199 if (mPrimitiveFields.mScaleX == 1.0f && mPrimitiveFields.mScaleY == 1.0f) {
200 mPrimitiveFields.mMatrixFlags &= ~SCALE;
John Reckacb6f072014-03-12 16:11:23 -0700201 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700202 mPrimitiveFields.mMatrixFlags |= SCALE;
John Reckacb6f072014-03-12 16:11:23 -0700203 }
204 }
205 }
206
207 float getScaleX() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700208 return mPrimitiveFields.mScaleX;
John Reckacb6f072014-03-12 16:11:23 -0700209 }
210
211 void setScaleY(float scaleY) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700212 if (scaleY != mPrimitiveFields.mScaleY) {
213 mPrimitiveFields.mScaleY = scaleY;
214 mPrimitiveFields.mMatrixDirty = true;
215 if (mPrimitiveFields.mScaleX == 1.0f && mPrimitiveFields.mScaleY == 1.0f) {
216 mPrimitiveFields.mMatrixFlags &= ~SCALE;
John Reckacb6f072014-03-12 16:11:23 -0700217 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700218 mPrimitiveFields.mMatrixFlags |= SCALE;
John Reckacb6f072014-03-12 16:11:23 -0700219 }
220 }
221 }
222
223 float getScaleY() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700224 return mPrimitiveFields.mScaleY;
John Reckacb6f072014-03-12 16:11:23 -0700225 }
226
227 void setPivotX(float pivotX) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700228 mPrimitiveFields.mPivotX = pivotX;
229 mPrimitiveFields.mMatrixDirty = true;
230 if (mPrimitiveFields.mPivotX == 0.0f && mPrimitiveFields.mPivotY == 0.0f) {
231 mPrimitiveFields.mMatrixFlags &= ~PIVOT;
John Reckacb6f072014-03-12 16:11:23 -0700232 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700233 mPrimitiveFields.mMatrixFlags |= PIVOT;
John Reckacb6f072014-03-12 16:11:23 -0700234 }
John Reckd0a0b2a2014-03-20 16:28:56 -0700235 mPrimitiveFields.mPivotExplicitlySet = true;
John Reckacb6f072014-03-12 16:11:23 -0700236 }
237
John Reckd0a0b2a2014-03-20 16:28:56 -0700238 /* Note that getPivotX and getPivotY are adjusted by updateMatrix(),
239 * so the value returned mPrimitiveFields.may be stale if the RenderProperties has been
240 * mPrimitiveFields.modified since the last call to updateMatrix()
241 */
242 float getPivotX() const {
243 return mPrimitiveFields.mPivotX;
244 }
John Reckacb6f072014-03-12 16:11:23 -0700245
246 void setPivotY(float pivotY) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700247 mPrimitiveFields.mPivotY = pivotY;
248 mPrimitiveFields.mMatrixDirty = true;
249 if (mPrimitiveFields.mPivotX == 0.0f && mPrimitiveFields.mPivotY == 0.0f) {
250 mPrimitiveFields.mMatrixFlags &= ~PIVOT;
John Reckacb6f072014-03-12 16:11:23 -0700251 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700252 mPrimitiveFields.mMatrixFlags |= PIVOT;
John Reckacb6f072014-03-12 16:11:23 -0700253 }
John Reckd0a0b2a2014-03-20 16:28:56 -0700254 mPrimitiveFields.mPivotExplicitlySet = true;
John Reckacb6f072014-03-12 16:11:23 -0700255 }
256
John Reckd0a0b2a2014-03-20 16:28:56 -0700257 float getPivotY() const {
258 return mPrimitiveFields.mPivotY;
259 }
John Reckacb6f072014-03-12 16:11:23 -0700260
Chris Craik49e6c732014-03-31 12:34:11 -0700261 bool isPivotExplicitlySet() const {
262 return mPrimitiveFields.mPivotExplicitlySet;
263 }
264
John Reckacb6f072014-03-12 16:11:23 -0700265 void setCameraDistance(float distance) {
Chris Craik49e6c732014-03-31 12:34:11 -0700266 if (distance != getCameraDistance()) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700267 mPrimitiveFields.mMatrixDirty = true;
Chris Craik49e6c732014-03-31 12:34:11 -0700268 mComputedFields.mTransformCamera.setCameraLocation(0, 0, distance);
John Reckacb6f072014-03-12 16:11:23 -0700269 }
270 }
271
272 float getCameraDistance() const {
Chris Craik49e6c732014-03-31 12:34:11 -0700273 // TODO: update getCameraLocationZ() to be const
274 return const_cast<Sk3DView*>(&mComputedFields.mTransformCamera)->getCameraLocationZ();
John Reckacb6f072014-03-12 16:11:23 -0700275 }
276
277 void setLeft(int left) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700278 if (left != mPrimitiveFields.mLeft) {
279 mPrimitiveFields.mLeft = left;
280 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
281 if (mPrimitiveFields.mMatrixFlags > TRANSLATION && !mPrimitiveFields.mPivotExplicitlySet) {
282 mPrimitiveFields.mMatrixDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700283 }
284 }
285 }
286
287 float getLeft() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700288 return mPrimitiveFields.mLeft;
John Reckacb6f072014-03-12 16:11:23 -0700289 }
290
291 void setTop(int top) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700292 if (top != mPrimitiveFields.mTop) {
293 mPrimitiveFields.mTop = top;
294 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
295 if (mPrimitiveFields.mMatrixFlags > TRANSLATION && !mPrimitiveFields.mPivotExplicitlySet) {
296 mPrimitiveFields.mMatrixDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700297 }
298 }
299 }
300
301 float getTop() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700302 return mPrimitiveFields.mTop;
John Reckacb6f072014-03-12 16:11:23 -0700303 }
304
305 void setRight(int right) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700306 if (right != mPrimitiveFields.mRight) {
307 mPrimitiveFields.mRight = right;
308 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
309 if (mPrimitiveFields.mMatrixFlags > TRANSLATION && !mPrimitiveFields.mPivotExplicitlySet) {
310 mPrimitiveFields.mMatrixDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700311 }
312 }
313 }
314
315 float getRight() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700316 return mPrimitiveFields.mRight;
John Reckacb6f072014-03-12 16:11:23 -0700317 }
318
319 void setBottom(int bottom) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700320 if (bottom != mPrimitiveFields.mBottom) {
321 mPrimitiveFields.mBottom = bottom;
322 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
323 if (mPrimitiveFields.mMatrixFlags > TRANSLATION && !mPrimitiveFields.mPivotExplicitlySet) {
324 mPrimitiveFields.mMatrixDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700325 }
326 }
327 }
328
329 float getBottom() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700330 return mPrimitiveFields.mBottom;
John Reckacb6f072014-03-12 16:11:23 -0700331 }
332
333 void setLeftTop(int left, int top) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700334 if (left != mPrimitiveFields.mLeft || top != mPrimitiveFields.mTop) {
335 mPrimitiveFields.mLeft = left;
336 mPrimitiveFields.mTop = top;
337 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
338 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
339 if (mPrimitiveFields.mMatrixFlags > TRANSLATION && !mPrimitiveFields.mPivotExplicitlySet) {
340 mPrimitiveFields.mMatrixDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700341 }
342 }
343 }
344
345 void setLeftTopRightBottom(int left, int top, int right, int bottom) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700346 if (left != mPrimitiveFields.mLeft || top != mPrimitiveFields.mTop || right != mPrimitiveFields.mRight || bottom != mPrimitiveFields.mBottom) {
347 mPrimitiveFields.mLeft = left;
348 mPrimitiveFields.mTop = top;
349 mPrimitiveFields.mRight = right;
350 mPrimitiveFields.mBottom = bottom;
351 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
352 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
353 if (mPrimitiveFields.mMatrixFlags > TRANSLATION && !mPrimitiveFields.mPivotExplicitlySet) {
354 mPrimitiveFields.mMatrixDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700355 }
356 }
357 }
358
359 void offsetLeftRight(float offset) {
360 if (offset != 0) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700361 mPrimitiveFields.mLeft += offset;
362 mPrimitiveFields.mRight += offset;
363 if (mPrimitiveFields.mMatrixFlags > TRANSLATION && !mPrimitiveFields.mPivotExplicitlySet) {
364 mPrimitiveFields.mMatrixDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700365 }
366 }
367 }
368
369 void offsetTopBottom(float offset) {
370 if (offset != 0) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700371 mPrimitiveFields.mTop += offset;
372 mPrimitiveFields.mBottom += offset;
373 if (mPrimitiveFields.mMatrixFlags > TRANSLATION && !mPrimitiveFields.mPivotExplicitlySet) {
374 mPrimitiveFields.mMatrixDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700375 }
376 }
377 }
378
379 void setCaching(bool caching) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700380 mPrimitiveFields.mCaching = caching;
John Reckacb6f072014-03-12 16:11:23 -0700381 }
382
Chris Craikb49f4462014-03-20 12:44:20 -0700383 int getWidth() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700384 return mPrimitiveFields.mWidth;
John Reckacb6f072014-03-12 16:11:23 -0700385 }
386
Chris Craikb49f4462014-03-20 12:44:20 -0700387 int getHeight() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700388 return mPrimitiveFields.mHeight;
John Reckacb6f072014-03-12 16:11:23 -0700389 }
390
John Reckd0a0b2a2014-03-20 16:28:56 -0700391 const SkMatrix* getAnimationMatrix() const {
392 return mAnimationMatrix;
393 }
394
395 uint32_t getMatrixFlags() const {
396 return mPrimitiveFields.mMatrixFlags;
397 }
398
Chris Craik49e6c732014-03-31 12:34:11 -0700399 const SkMatrix* getTransformMatrix() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700400 return mComputedFields.mTransformMatrix;
401 }
402
403 bool getCaching() const {
404 return mPrimitiveFields.mCaching;
405 }
406
407 bool getClipToBounds() const {
408 return mPrimitiveFields.mClipToBounds;
409 }
410
411 bool getHasOverlappingRendering() const {
412 return mPrimitiveFields.mHasOverlappingRendering;
413 }
414
415 const Outline& getOutline() const {
416 return mPrimitiveFields.mOutline;
417 }
418
Chris Craik8c271ca2014-03-25 10:33:01 -0700419 const RevealClip& getRevealClip() const {
420 return mPrimitiveFields.mRevealClip;
421 }
422
John Reckd0a0b2a2014-03-20 16:28:56 -0700423 bool getProjectBackwards() const {
424 return mPrimitiveFields.mProjectBackwards;
425 }
426
427 void debugOutputProperties(const int level) const;
428
429 ANDROID_API void updateMatrix();
430
Chris Craik8c271ca2014-03-25 10:33:01 -0700431 ANDROID_API void updateClipPath();
432
433 // signals that mComputedFields.mClipPath is up to date, and should be used for clipping
434 bool hasClippingPath() const {
435 return mPrimitiveFields.mOutline.willClip() || mPrimitiveFields.mRevealClip.willClip();
436 }
437
438 const SkPath* getClippingPath() const {
439 return hasClippingPath() ? mComputedFields.mClipPath : NULL;
440 }
441
442 SkRegion::Op getClippingPathOp() const {
443 return mComputedFields.mClipPathOp;
444 }
445
John Reckd0a0b2a2014-03-20 16:28:56 -0700446 Outline& mutableOutline() {
447 return mPrimitiveFields.mOutline;
Chris Craikb49f4462014-03-20 12:44:20 -0700448 }
449
Chris Craik8c271ca2014-03-25 10:33:01 -0700450 RevealClip& mutableRevealClip() {
451 return mPrimitiveFields.mRevealClip;
452 }
453
John Reckacb6f072014-03-12 16:11:23 -0700454private:
455 void onTranslationUpdate() {
John Reckd0a0b2a2014-03-20 16:28:56 -0700456 mPrimitiveFields.mMatrixDirty = true;
457 if (mPrimitiveFields.mTranslationX == 0.0f && mPrimitiveFields.mTranslationY == 0.0f && mPrimitiveFields.mTranslationZ == 0.0f) {
458 mPrimitiveFields.mMatrixFlags &= ~TRANSLATION;
John Reckacb6f072014-03-12 16:11:23 -0700459 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700460 mPrimitiveFields.mMatrixFlags |= TRANSLATION;
John Reckacb6f072014-03-12 16:11:23 -0700461 }
462 }
463
John Reckacb6f072014-03-12 16:11:23 -0700464 // Rendering properties
John Reckd0a0b2a2014-03-20 16:28:56 -0700465 struct PrimitiveFields {
466 PrimitiveFields();
John Reckacb6f072014-03-12 16:11:23 -0700467
John Reckd0a0b2a2014-03-20 16:28:56 -0700468 Outline mOutline;
Chris Craik8c271ca2014-03-25 10:33:01 -0700469 RevealClip mRevealClip;
John Reckd0a0b2a2014-03-20 16:28:56 -0700470 bool mClipToBounds;
471 bool mProjectBackwards;
472 bool mProjectionReceiver;
473 float mAlpha;
474 bool mHasOverlappingRendering;
475 float mTranslationX, mTranslationY, mTranslationZ;
476 float mRotation, mRotationX, mRotationY;
477 float mScaleX, mScaleY;
478 float mPivotX, mPivotY;
479 int mLeft, mTop, mRight, mBottom;
480 int mWidth, mHeight;
481 int mPrevWidth, mPrevHeight;
482 bool mPivotExplicitlySet;
483 bool mMatrixDirty;
John Reckd0a0b2a2014-03-20 16:28:56 -0700484 uint32_t mMatrixFlags;
485 bool mCaching;
486 } mPrimitiveFields;
487
488 // mCameraDistance isn't in mPrimitiveFields as it has a complex setter
John Reckacb6f072014-03-12 16:11:23 -0700489 SkMatrix* mStaticMatrix;
490 SkMatrix* mAnimationMatrix;
John Reckacb6f072014-03-12 16:11:23 -0700491
John Reckd0a0b2a2014-03-20 16:28:56 -0700492 /**
493 * These fields are all generated from other properties and are not set directly.
494 */
495 struct ComputedFields {
496 ComputedFields();
497 ~ComputedFields();
498
499 /**
500 * Stores the total transformation of the DisplayList based upon its scalar
501 * translate/rotate/scale properties.
502 *
Chris Craik49e6c732014-03-31 12:34:11 -0700503 * In the common translation-only case, the matrix isn't necessarily allocated,
504 * and the mTranslation properties are used directly.
John Reckd0a0b2a2014-03-20 16:28:56 -0700505 */
Chris Craik49e6c732014-03-31 12:34:11 -0700506 SkMatrix* mTransformMatrix;
507
508 Sk3DView mTransformCamera;
John Reckd0a0b2a2014-03-20 16:28:56 -0700509 SkMatrix* mTransformMatrix3D;
Chris Craik8c271ca2014-03-25 10:33:01 -0700510 SkPath* mClipPath; // TODO: remove this, create new ops for efficient/special case clipping
511 SkRegion::Op mClipPathOp;
John Reckd0a0b2a2014-03-20 16:28:56 -0700512 } mComputedFields;
John Reckacb6f072014-03-12 16:11:23 -0700513};
514
515} /* namespace uirenderer */
516} /* namespace android */
517
Chris Craikb49f4462014-03-20 12:44:20 -0700518#endif /* RENDERNODEPROPERTIES_H */