blob: b012fc5c023440592c26c34d29755aeb13540398 [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
John Reck79c7de72014-05-23 10:33:31 -070043// The __VA_ARGS__ will be executed if a & b are not equal
44#define RP_SET(a, b, ...) (a != b ? (a = b, ##__VA_ARGS__, true) : false)
45#define RP_SET_AND_DIRTY(a, b) RP_SET(a, b, mPrimitiveFields.mMatrixOrPivotDirty = true)
46
John Reckacb6f072014-03-12 16:11:23 -070047/*
48 * Data structure that holds the properties for a RenderNode
49 */
50class RenderProperties {
51public:
52 RenderProperties();
53 virtual ~RenderProperties();
54
John Reckd0a0b2a2014-03-20 16:28:56 -070055 RenderProperties& operator=(const RenderProperties& other);
56
John Reck79c7de72014-05-23 10:33:31 -070057 bool setClipToBounds(bool clipToBounds) {
58 return RP_SET(mPrimitiveFields.mClipToBounds, clipToBounds);
John Reckacb6f072014-03-12 16:11:23 -070059 }
60
John Reck79c7de72014-05-23 10:33:31 -070061 bool setProjectBackwards(bool shouldProject) {
62 return RP_SET(mPrimitiveFields.mProjectBackwards, shouldProject);
John Reckacb6f072014-03-12 16:11:23 -070063 }
64
John Reck79c7de72014-05-23 10:33:31 -070065 bool setProjectionReceiver(bool shouldRecieve) {
66 return RP_SET(mPrimitiveFields.mProjectionReceiver, shouldRecieve);
John Reckacb6f072014-03-12 16:11:23 -070067 }
68
John Reckd0a0b2a2014-03-20 16:28:56 -070069 bool isProjectionReceiver() const {
70 return mPrimitiveFields.mProjectionReceiver;
John Reckacb6f072014-03-12 16:11:23 -070071 }
72
John Reck79c7de72014-05-23 10:33:31 -070073 bool setStaticMatrix(const SkMatrix* matrix) {
John Reckacb6f072014-03-12 16:11:23 -070074 delete mStaticMatrix;
John Reckd0a0b2a2014-03-20 16:28:56 -070075 if (matrix) {
76 mStaticMatrix = new SkMatrix(*matrix);
77 } else {
78 mStaticMatrix = NULL;
79 }
John Reck79c7de72014-05-23 10:33:31 -070080 return true;
John Reckacb6f072014-03-12 16:11:23 -070081 }
82
83 // Can return NULL
John Reckd0a0b2a2014-03-20 16:28:56 -070084 const SkMatrix* getStaticMatrix() const {
John Reckacb6f072014-03-12 16:11:23 -070085 return mStaticMatrix;
86 }
87
John Reck79c7de72014-05-23 10:33:31 -070088 bool setAnimationMatrix(const SkMatrix* matrix) {
John Reckacb6f072014-03-12 16:11:23 -070089 delete mAnimationMatrix;
90 if (matrix) {
91 mAnimationMatrix = new SkMatrix(*matrix);
92 } else {
93 mAnimationMatrix = NULL;
94 }
John Reck79c7de72014-05-23 10:33:31 -070095 return true;
John Reckacb6f072014-03-12 16:11:23 -070096 }
97
John Reck79c7de72014-05-23 10:33:31 -070098 bool setAlpha(float alpha) {
John Reckacb6f072014-03-12 16:11:23 -070099 alpha = fminf(1.0f, fmaxf(0.0f, alpha));
John Reck79c7de72014-05-23 10:33:31 -0700100 return RP_SET(mPrimitiveFields.mAlpha, alpha);
John Reckacb6f072014-03-12 16:11:23 -0700101 }
102
103 float getAlpha() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700104 return mPrimitiveFields.mAlpha;
John Reckacb6f072014-03-12 16:11:23 -0700105 }
106
John Reck79c7de72014-05-23 10:33:31 -0700107 bool setHasOverlappingRendering(bool hasOverlappingRendering) {
108 return RP_SET(mPrimitiveFields.mHasOverlappingRendering, hasOverlappingRendering);
John Reckacb6f072014-03-12 16:11:23 -0700109 }
110
111 bool hasOverlappingRendering() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700112 return mPrimitiveFields.mHasOverlappingRendering;
John Reckacb6f072014-03-12 16:11:23 -0700113 }
114
John Reck79c7de72014-05-23 10:33:31 -0700115 bool setElevation(float elevation) {
116 return RP_SET(mPrimitiveFields.mElevation, elevation);
117 // Don't dirty matrix/pivot, since they don't respect Z
Chris Craikcc39e162014-04-25 18:34:11 -0700118 }
119
120 float getElevation() const {
121 return mPrimitiveFields.mElevation;
122 }
123
John Reck79c7de72014-05-23 10:33:31 -0700124 bool setTranslationX(float translationX) {
125 return RP_SET_AND_DIRTY(mPrimitiveFields.mTranslationX, translationX);
John Reckacb6f072014-03-12 16:11:23 -0700126 }
127
128 float getTranslationX() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700129 return mPrimitiveFields.mTranslationX;
John Reckacb6f072014-03-12 16:11:23 -0700130 }
131
John Reck79c7de72014-05-23 10:33:31 -0700132 bool setTranslationY(float translationY) {
133 return RP_SET_AND_DIRTY(mPrimitiveFields.mTranslationY, translationY);
John Reckacb6f072014-03-12 16:11:23 -0700134 }
135
136 float getTranslationY() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700137 return mPrimitiveFields.mTranslationY;
John Reckacb6f072014-03-12 16:11:23 -0700138 }
139
John Reck79c7de72014-05-23 10:33:31 -0700140 bool setTranslationZ(float translationZ) {
141 return RP_SET(mPrimitiveFields.mTranslationZ, translationZ);
142 // mMatrixOrPivotDirty not set, since matrix doesn't respect Z
John Reckacb6f072014-03-12 16:11:23 -0700143 }
144
145 float getTranslationZ() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700146 return mPrimitiveFields.mTranslationZ;
John Reckacb6f072014-03-12 16:11:23 -0700147 }
148
John Recke45b1fd2014-04-15 09:50:16 -0700149 // Animation helper
John Reck79c7de72014-05-23 10:33:31 -0700150 bool setX(float value) {
151 return setTranslationX(value - getLeft());
John Recke45b1fd2014-04-15 09:50:16 -0700152 }
153
154 // Animation helper
155 float getX() const {
156 return getLeft() + getTranslationX();
157 }
158
159 // Animation helper
John Reck79c7de72014-05-23 10:33:31 -0700160 bool setY(float value) {
161 return setTranslationY(value - getTop());
John Recke45b1fd2014-04-15 09:50:16 -0700162 }
163
164 // Animation helper
165 float getY() const {
166 return getTop() + getTranslationY();
167 }
168
169 // Animation helper
John Reck79c7de72014-05-23 10:33:31 -0700170 bool setZ(float value) {
171 return setTranslationZ(value - getElevation());
John Recke45b1fd2014-04-15 09:50:16 -0700172 }
173
Chris Craikcc39e162014-04-25 18:34:11 -0700174 float getZ() const {
175 return getElevation() + getTranslationZ();
176 }
177
John Reck79c7de72014-05-23 10:33:31 -0700178 bool setRotation(float rotation) {
179 return RP_SET_AND_DIRTY(mPrimitiveFields.mRotation, rotation);
John Reckacb6f072014-03-12 16:11:23 -0700180 }
181
182 float getRotation() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700183 return mPrimitiveFields.mRotation;
John Reckacb6f072014-03-12 16:11:23 -0700184 }
185
John Reck79c7de72014-05-23 10:33:31 -0700186 bool setRotationX(float rotationX) {
187 return RP_SET_AND_DIRTY(mPrimitiveFields.mRotationX, rotationX);
John Reckacb6f072014-03-12 16:11:23 -0700188 }
189
190 float getRotationX() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700191 return mPrimitiveFields.mRotationX;
John Reckacb6f072014-03-12 16:11:23 -0700192 }
193
John Reck79c7de72014-05-23 10:33:31 -0700194 bool setRotationY(float rotationY) {
195 return RP_SET_AND_DIRTY(mPrimitiveFields.mRotationY, rotationY);
John Reckacb6f072014-03-12 16:11:23 -0700196 }
197
198 float getRotationY() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700199 return mPrimitiveFields.mRotationY;
John Reckacb6f072014-03-12 16:11:23 -0700200 }
201
John Reck79c7de72014-05-23 10:33:31 -0700202 bool setScaleX(float scaleX) {
203 return RP_SET_AND_DIRTY(mPrimitiveFields.mScaleX, scaleX);
John Reckacb6f072014-03-12 16:11:23 -0700204 }
205
206 float getScaleX() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700207 return mPrimitiveFields.mScaleX;
John Reckacb6f072014-03-12 16:11:23 -0700208 }
209
John Reck79c7de72014-05-23 10:33:31 -0700210 bool setScaleY(float scaleY) {
211 return RP_SET_AND_DIRTY(mPrimitiveFields.mScaleY, scaleY);
John Reckacb6f072014-03-12 16:11:23 -0700212 }
213
214 float getScaleY() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700215 return mPrimitiveFields.mScaleY;
John Reckacb6f072014-03-12 16:11:23 -0700216 }
217
John Reck79c7de72014-05-23 10:33:31 -0700218 bool setPivotX(float pivotX) {
219 if (RP_SET(mPrimitiveFields.mPivotX, pivotX)
220 || !mPrimitiveFields.mPivotExplicitlySet) {
221 mPrimitiveFields.mMatrixOrPivotDirty = true;
222 mPrimitiveFields.mPivotExplicitlySet = true;
223 return true;
224 }
225 return false;
John Reckacb6f072014-03-12 16:11:23 -0700226 }
227
John Reckd0a0b2a2014-03-20 16:28:56 -0700228 /* Note that getPivotX and getPivotY are adjusted by updateMatrix(),
John Reck79c7de72014-05-23 10:33:31 -0700229 * so the value returned may be stale if the RenderProperties has been
230 * modified since the last call to updateMatrix()
John Reckd0a0b2a2014-03-20 16:28:56 -0700231 */
232 float getPivotX() const {
233 return mPrimitiveFields.mPivotX;
234 }
John Reckacb6f072014-03-12 16:11:23 -0700235
John Reck79c7de72014-05-23 10:33:31 -0700236 bool setPivotY(float pivotY) {
237 if (RP_SET(mPrimitiveFields.mPivotY, pivotY)
238 || !mPrimitiveFields.mPivotExplicitlySet) {
239 mPrimitiveFields.mMatrixOrPivotDirty = true;
240 mPrimitiveFields.mPivotExplicitlySet = true;
241 return true;
242 }
243 return false;
John Reckacb6f072014-03-12 16:11:23 -0700244 }
245
John Reckd0a0b2a2014-03-20 16:28:56 -0700246 float getPivotY() const {
247 return mPrimitiveFields.mPivotY;
248 }
John Reckacb6f072014-03-12 16:11:23 -0700249
Chris Craik49e6c7392014-03-31 12:34:11 -0700250 bool isPivotExplicitlySet() const {
251 return mPrimitiveFields.mPivotExplicitlySet;
252 }
253
John Reck79c7de72014-05-23 10:33:31 -0700254 bool setCameraDistance(float distance) {
Chris Craik49e6c7392014-03-31 12:34:11 -0700255 if (distance != getCameraDistance()) {
John Reckf7483e32014-04-11 08:54:47 -0700256 mPrimitiveFields.mMatrixOrPivotDirty = true;
Chris Craik49e6c7392014-03-31 12:34:11 -0700257 mComputedFields.mTransformCamera.setCameraLocation(0, 0, distance);
John Reck79c7de72014-05-23 10:33:31 -0700258 return true;
John Reckacb6f072014-03-12 16:11:23 -0700259 }
John Reck79c7de72014-05-23 10:33:31 -0700260 return false;
John Reckacb6f072014-03-12 16:11:23 -0700261 }
262
263 float getCameraDistance() const {
Chris Craik49e6c7392014-03-31 12:34:11 -0700264 // TODO: update getCameraLocationZ() to be const
265 return const_cast<Sk3DView*>(&mComputedFields.mTransformCamera)->getCameraLocationZ();
John Reckacb6f072014-03-12 16:11:23 -0700266 }
267
John Reck79c7de72014-05-23 10:33:31 -0700268 bool setLeft(int left) {
269 if (RP_SET(mPrimitiveFields.mLeft, left)) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700270 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
John Reckf7483e32014-04-11 08:54:47 -0700271 if (!mPrimitiveFields.mPivotExplicitlySet) {
272 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700273 }
John Reck79c7de72014-05-23 10:33:31 -0700274 return true;
John Reckacb6f072014-03-12 16:11:23 -0700275 }
John Reck79c7de72014-05-23 10:33:31 -0700276 return false;
John Reckacb6f072014-03-12 16:11:23 -0700277 }
278
279 float getLeft() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700280 return mPrimitiveFields.mLeft;
John Reckacb6f072014-03-12 16:11:23 -0700281 }
282
John Reck79c7de72014-05-23 10:33:31 -0700283 bool setTop(int top) {
284 if (RP_SET(mPrimitiveFields.mTop, top)) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700285 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
John Reckf7483e32014-04-11 08:54:47 -0700286 if (!mPrimitiveFields.mPivotExplicitlySet) {
287 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700288 }
John Reck79c7de72014-05-23 10:33:31 -0700289 return true;
John Reckacb6f072014-03-12 16:11:23 -0700290 }
John Reck79c7de72014-05-23 10:33:31 -0700291 return false;
John Reckacb6f072014-03-12 16:11:23 -0700292 }
293
294 float getTop() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700295 return mPrimitiveFields.mTop;
John Reckacb6f072014-03-12 16:11:23 -0700296 }
297
John Reck79c7de72014-05-23 10:33:31 -0700298 bool setRight(int right) {
299 if (RP_SET(mPrimitiveFields.mRight, right)) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700300 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
John Reckf7483e32014-04-11 08:54:47 -0700301 if (!mPrimitiveFields.mPivotExplicitlySet) {
302 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700303 }
John Reck79c7de72014-05-23 10:33:31 -0700304 return true;
John Reckacb6f072014-03-12 16:11:23 -0700305 }
John Reck79c7de72014-05-23 10:33:31 -0700306 return false;
John Reckacb6f072014-03-12 16:11:23 -0700307 }
308
309 float getRight() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700310 return mPrimitiveFields.mRight;
John Reckacb6f072014-03-12 16:11:23 -0700311 }
312
John Reck79c7de72014-05-23 10:33:31 -0700313 bool setBottom(int bottom) {
314 if (RP_SET(mPrimitiveFields.mBottom, bottom)) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700315 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
John Reckf7483e32014-04-11 08:54:47 -0700316 if (!mPrimitiveFields.mPivotExplicitlySet) {
317 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700318 }
John Reck79c7de72014-05-23 10:33:31 -0700319 return true;
John Reckacb6f072014-03-12 16:11:23 -0700320 }
John Reck79c7de72014-05-23 10:33:31 -0700321 return false;
John Reckacb6f072014-03-12 16:11:23 -0700322 }
323
324 float getBottom() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700325 return mPrimitiveFields.mBottom;
John Reckacb6f072014-03-12 16:11:23 -0700326 }
327
John Reck79c7de72014-05-23 10:33:31 -0700328 bool setLeftTop(int left, int top) {
329 bool leftResult = setLeft(left);
330 bool topResult = setTop(top);
331 return leftResult || topResult;
John Reckacb6f072014-03-12 16:11:23 -0700332 }
333
John Reck79c7de72014-05-23 10:33:31 -0700334 bool setLeftTopRightBottom(int left, int top, int right, int bottom) {
Chris Craikcc39e162014-04-25 18:34:11 -0700335 if (left != mPrimitiveFields.mLeft || top != mPrimitiveFields.mTop
336 || right != mPrimitiveFields.mRight || bottom != mPrimitiveFields.mBottom) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700337 mPrimitiveFields.mLeft = left;
338 mPrimitiveFields.mTop = top;
339 mPrimitiveFields.mRight = right;
340 mPrimitiveFields.mBottom = bottom;
341 mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft;
342 mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop;
John Reckf7483e32014-04-11 08:54:47 -0700343 if (!mPrimitiveFields.mPivotExplicitlySet) {
344 mPrimitiveFields.mMatrixOrPivotDirty = true;
John Reckacb6f072014-03-12 16:11:23 -0700345 }
John Reck79c7de72014-05-23 10:33:31 -0700346 return true;
John Reckacb6f072014-03-12 16:11:23 -0700347 }
John Reck79c7de72014-05-23 10:33:31 -0700348 return false;
John Reckacb6f072014-03-12 16:11:23 -0700349 }
350
John Reck79c7de72014-05-23 10:33:31 -0700351 bool offsetLeftRight(float offset) {
John Reckacb6f072014-03-12 16:11:23 -0700352 if (offset != 0) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700353 mPrimitiveFields.mLeft += offset;
354 mPrimitiveFields.mRight += offset;
John Reck79c7de72014-05-23 10:33:31 -0700355 return true;
John Reckacb6f072014-03-12 16:11:23 -0700356 }
John Reck79c7de72014-05-23 10:33:31 -0700357 return false;
John Reckacb6f072014-03-12 16:11:23 -0700358 }
359
John Reck79c7de72014-05-23 10:33:31 -0700360 bool offsetTopBottom(float offset) {
John Reckacb6f072014-03-12 16:11:23 -0700361 if (offset != 0) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700362 mPrimitiveFields.mTop += offset;
363 mPrimitiveFields.mBottom += offset;
John Reck79c7de72014-05-23 10:33:31 -0700364 return true;
John Reckacb6f072014-03-12 16:11:23 -0700365 }
John Reck79c7de72014-05-23 10:33:31 -0700366 return false;
John Reckacb6f072014-03-12 16:11:23 -0700367 }
368
John Reck79c7de72014-05-23 10:33:31 -0700369 bool setCaching(bool caching) {
370 return RP_SET(mPrimitiveFields.mCaching, caching);
John Reckacb6f072014-03-12 16:11:23 -0700371 }
372
Chris Craikb49f4462014-03-20 12:44:20 -0700373 int getWidth() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700374 return mPrimitiveFields.mWidth;
John Reckacb6f072014-03-12 16:11:23 -0700375 }
376
Chris Craikb49f4462014-03-20 12:44:20 -0700377 int getHeight() const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700378 return mPrimitiveFields.mHeight;
John Reckacb6f072014-03-12 16:11:23 -0700379 }
380
John Reckd0a0b2a2014-03-20 16:28:56 -0700381 const SkMatrix* getAnimationMatrix() const {
382 return mAnimationMatrix;
383 }
384
John Reckf7483e32014-04-11 08:54:47 -0700385 bool hasTransformMatrix() const {
386 return getTransformMatrix() && !getTransformMatrix()->isIdentity();
387 }
388
389 // May only call this if hasTransformMatrix() is true
390 bool isTransformTranslateOnly() const {
391 return getTransformMatrix()->getType() == SkMatrix::kTranslate_Mask;
John Reckd0a0b2a2014-03-20 16:28:56 -0700392 }
393
Chris Craik49e6c7392014-03-31 12:34:11 -0700394 const SkMatrix* getTransformMatrix() const {
John Reckf7483e32014-04-11 08:54:47 -0700395 LOG_ALWAYS_FATAL_IF(mPrimitiveFields.mMatrixOrPivotDirty, "Cannot get a dirty matrix!");
John Reckd0a0b2a2014-03-20 16:28:56 -0700396 return mComputedFields.mTransformMatrix;
397 }
398
399 bool getCaching() const {
400 return mPrimitiveFields.mCaching;
401 }
402
403 bool getClipToBounds() const {
404 return mPrimitiveFields.mClipToBounds;
405 }
406
407 bool getHasOverlappingRendering() const {
408 return mPrimitiveFields.mHasOverlappingRendering;
409 }
410
411 const Outline& getOutline() const {
412 return mPrimitiveFields.mOutline;
413 }
414
Chris Craik8c271ca2014-03-25 10:33:01 -0700415 const RevealClip& getRevealClip() const {
416 return mPrimitiveFields.mRevealClip;
417 }
418
John Reckd0a0b2a2014-03-20 16:28:56 -0700419 bool getProjectBackwards() const {
420 return mPrimitiveFields.mProjectBackwards;
421 }
422
423 void debugOutputProperties(const int level) const;
424
425 ANDROID_API void updateMatrix();
426
Chris Craik8c271ca2014-03-25 10:33:01 -0700427 bool hasClippingPath() const {
Chris Craik2bcad172014-05-14 18:11:23 -0700428 return mPrimitiveFields.mRevealClip.willClip();
Chris Craik8c271ca2014-03-25 10:33:01 -0700429 }
430
431 const SkPath* getClippingPath() const {
Chris Craik2bcad172014-05-14 18:11:23 -0700432 return mPrimitiveFields.mRevealClip.getPath();
Chris Craik8c271ca2014-03-25 10:33:01 -0700433 }
434
435 SkRegion::Op getClippingPathOp() const {
Chris Craik2bcad172014-05-14 18:11:23 -0700436 return mPrimitiveFields.mRevealClip.isInverseClip()
437 ? SkRegion::kDifference_Op : SkRegion::kIntersect_Op;
Chris Craik8c271ca2014-03-25 10:33:01 -0700438 }
439
John Reckd0a0b2a2014-03-20 16:28:56 -0700440 Outline& mutableOutline() {
441 return mPrimitiveFields.mOutline;
Chris Craikb49f4462014-03-20 12:44:20 -0700442 }
443
Chris Craik8c271ca2014-03-25 10:33:01 -0700444 RevealClip& mutableRevealClip() {
445 return mPrimitiveFields.mRevealClip;
446 }
447
John Reckacb6f072014-03-12 16:11:23 -0700448private:
John Reckacb6f072014-03-12 16:11:23 -0700449
John Reckacb6f072014-03-12 16:11:23 -0700450 // Rendering properties
John Reckd0a0b2a2014-03-20 16:28:56 -0700451 struct PrimitiveFields {
452 PrimitiveFields();
John Reckacb6f072014-03-12 16:11:23 -0700453
John Reckd0a0b2a2014-03-20 16:28:56 -0700454 Outline mOutline;
Chris Craik8c271ca2014-03-25 10:33:01 -0700455 RevealClip mRevealClip;
John Reckd0a0b2a2014-03-20 16:28:56 -0700456 bool mClipToBounds;
457 bool mProjectBackwards;
458 bool mProjectionReceiver;
459 float mAlpha;
460 bool mHasOverlappingRendering;
Chris Craikcc39e162014-04-25 18:34:11 -0700461 float mElevation;
John Reckd0a0b2a2014-03-20 16:28:56 -0700462 float mTranslationX, mTranslationY, mTranslationZ;
463 float mRotation, mRotationX, mRotationY;
464 float mScaleX, mScaleY;
465 float mPivotX, mPivotY;
466 int mLeft, mTop, mRight, mBottom;
467 int mWidth, mHeight;
John Reckd0a0b2a2014-03-20 16:28:56 -0700468 bool mPivotExplicitlySet;
John Reckf7483e32014-04-11 08:54:47 -0700469 bool mMatrixOrPivotDirty;
John Reckd0a0b2a2014-03-20 16:28:56 -0700470 bool mCaching;
471 } mPrimitiveFields;
472
John Reckacb6f072014-03-12 16:11:23 -0700473 SkMatrix* mStaticMatrix;
474 SkMatrix* mAnimationMatrix;
John Reckacb6f072014-03-12 16:11:23 -0700475
John Reckd0a0b2a2014-03-20 16:28:56 -0700476 /**
477 * These fields are all generated from other properties and are not set directly.
478 */
479 struct ComputedFields {
480 ComputedFields();
481 ~ComputedFields();
482
483 /**
484 * Stores the total transformation of the DisplayList based upon its scalar
485 * translate/rotate/scale properties.
486 *
Chris Craik49e6c7392014-03-31 12:34:11 -0700487 * In the common translation-only case, the matrix isn't necessarily allocated,
488 * and the mTranslation properties are used directly.
John Reckd0a0b2a2014-03-20 16:28:56 -0700489 */
Chris Craik49e6c7392014-03-31 12:34:11 -0700490 SkMatrix* mTransformMatrix;
491
492 Sk3DView mTransformCamera;
John Reckd0a0b2a2014-03-20 16:28:56 -0700493 } mComputedFields;
John Reckacb6f072014-03-12 16:11:23 -0700494};
495
496} /* namespace uirenderer */
497} /* namespace android */
498
Chris Craikb49f4462014-03-20 12:44:20 -0700499#endif /* RENDERNODEPROPERTIES_H */