John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 1 | /* |
| 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 Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 16 | #ifndef RENDERNODEPROPERTIES_H |
| 17 | #define RENDERNODEPROPERTIES_H |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 18 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 19 | #include <algorithm> |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 20 | #include <stddef.h> |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 21 | #include <vector> |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 22 | #include <cutils/compiler.h> |
| 23 | #include <androidfw/ResourceTypes.h> |
Chris Craik | fe02b4b | 2014-06-16 16:34:29 -0700 | [diff] [blame] | 24 | #include <utils/Log.h> |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 25 | |
| 26 | #include <SkCamera.h> |
| 27 | #include <SkMatrix.h> |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 28 | #include <SkRegion.h> |
Tom Hudson | 2dc236b | 2014-10-15 15:46:42 -0400 | [diff] [blame] | 29 | #include <SkXfermode.h> |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 30 | |
| 31 | #include "Rect.h" |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 32 | #include "RevealClip.h" |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 33 | #include "Outline.h" |
John Reck | 293e868 | 2014-06-17 10:34:02 -0700 | [diff] [blame] | 34 | #include "utils/MathUtils.h" |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 35 | |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 36 | class SkBitmap; |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 37 | class SkColorFilter; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 38 | class SkPaint; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 39 | |
| 40 | namespace android { |
| 41 | namespace uirenderer { |
| 42 | |
| 43 | class Matrix4; |
| 44 | class RenderNode; |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 45 | class RenderProperties; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 46 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 47 | // The __VA_ARGS__ will be executed if a & b are not equal |
| 48 | #define RP_SET(a, b, ...) (a != b ? (a = b, ##__VA_ARGS__, true) : false) |
| 49 | #define RP_SET_AND_DIRTY(a, b) RP_SET(a, b, mPrimitiveFields.mMatrixOrPivotDirty = true) |
| 50 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 51 | // Keep in sync with View.java:LAYER_TYPE_* |
Chris Craik | 182952f | 2015-03-09 14:17:29 -0700 | [diff] [blame] | 52 | enum class LayerType { |
| 53 | None = 0, |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 54 | // Although we cannot build the software layer directly (must be done at |
| 55 | // record time), this information is used when applying alpha. |
Chris Craik | 182952f | 2015-03-09 14:17:29 -0700 | [diff] [blame] | 56 | Software = 1, |
| 57 | RenderLayer = 2, |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 58 | // TODO: LayerTypeSurfaceTexture? Maybe? |
| 59 | }; |
| 60 | |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 61 | enum ClippingFlags { |
| 62 | CLIP_TO_BOUNDS = 0x1 << 0, |
| 63 | CLIP_TO_CLIP_BOUNDS = 0x1 << 1, |
| 64 | }; |
| 65 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 66 | class ANDROID_API LayerProperties { |
| 67 | public: |
| 68 | bool setType(LayerType type) { |
| 69 | if (RP_SET(mType, type)) { |
| 70 | reset(); |
| 71 | return true; |
| 72 | } |
| 73 | return false; |
| 74 | } |
| 75 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 76 | bool setOpaque(bool opaque) { |
| 77 | return RP_SET(mOpaque, opaque); |
| 78 | } |
| 79 | |
| 80 | bool opaque() const { |
| 81 | return mOpaque; |
| 82 | } |
| 83 | |
| 84 | bool setAlpha(uint8_t alpha) { |
| 85 | return RP_SET(mAlpha, alpha); |
| 86 | } |
| 87 | |
| 88 | uint8_t alpha() const { |
| 89 | return mAlpha; |
| 90 | } |
| 91 | |
| 92 | bool setXferMode(SkXfermode::Mode mode) { |
| 93 | return RP_SET(mMode, mode); |
| 94 | } |
| 95 | |
| 96 | SkXfermode::Mode xferMode() const { |
| 97 | return mMode; |
| 98 | } |
| 99 | |
| 100 | bool setColorFilter(SkColorFilter* filter); |
| 101 | |
| 102 | SkColorFilter* colorFilter() const { |
| 103 | return mColorFilter; |
| 104 | } |
| 105 | |
| 106 | // Sets alpha, xfermode, and colorfilter from an SkPaint |
| 107 | // paint may be NULL, in which case defaults will be set |
| 108 | bool setFromPaint(const SkPaint* paint); |
| 109 | |
| 110 | bool needsBlending() const { |
| 111 | return !opaque() || alpha() < 255; |
| 112 | } |
| 113 | |
| 114 | LayerProperties& operator=(const LayerProperties& other); |
| 115 | |
| 116 | private: |
| 117 | LayerProperties(); |
| 118 | ~LayerProperties(); |
| 119 | void reset(); |
| 120 | |
Chris Craik | 856f0cc | 2015-04-21 15:13:29 -0700 | [diff] [blame] | 121 | // Private since external users should go through properties().effectiveLayerType() |
| 122 | LayerType type() const { |
| 123 | return mType; |
| 124 | } |
| 125 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 126 | friend class RenderProperties; |
| 127 | |
Chris Craik | 182952f | 2015-03-09 14:17:29 -0700 | [diff] [blame] | 128 | LayerType mType = LayerType::None; |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 129 | // Whether or not that Layer's content is opaque, doesn't include alpha |
| 130 | bool mOpaque; |
| 131 | uint8_t mAlpha; |
| 132 | SkXfermode::Mode mMode; |
Chris Craik | 182952f | 2015-03-09 14:17:29 -0700 | [diff] [blame] | 133 | SkColorFilter* mColorFilter = nullptr; |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 134 | }; |
| 135 | |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 136 | /* |
| 137 | * Data structure that holds the properties for a RenderNode |
| 138 | */ |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 139 | class ANDROID_API RenderProperties { |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 140 | public: |
| 141 | RenderProperties(); |
| 142 | virtual ~RenderProperties(); |
| 143 | |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 144 | static bool setFlag(int flag, bool newValue, int* outFlags) { |
| 145 | if (newValue) { |
| 146 | if (!(flag & *outFlags)) { |
| 147 | *outFlags |= flag; |
| 148 | return true; |
| 149 | } |
| 150 | return false; |
| 151 | } else { |
| 152 | if (flag & *outFlags) { |
| 153 | *outFlags &= ~flag; |
| 154 | return true; |
| 155 | } |
| 156 | return false; |
| 157 | } |
| 158 | } |
| 159 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 160 | RenderProperties& operator=(const RenderProperties& other); |
| 161 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 162 | bool setClipToBounds(bool clipToBounds) { |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 163 | return setFlag(CLIP_TO_BOUNDS, clipToBounds, &mPrimitiveFields.mClippingFlags); |
| 164 | } |
| 165 | |
| 166 | bool setClipBounds(const Rect& clipBounds) { |
| 167 | bool ret = setFlag(CLIP_TO_CLIP_BOUNDS, true, &mPrimitiveFields.mClippingFlags); |
| 168 | return RP_SET(mPrimitiveFields.mClipBounds, clipBounds) || ret; |
| 169 | } |
| 170 | |
| 171 | bool setClipBoundsEmpty() { |
| 172 | return setFlag(CLIP_TO_CLIP_BOUNDS, false, &mPrimitiveFields.mClippingFlags); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 173 | } |
| 174 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 175 | bool setProjectBackwards(bool shouldProject) { |
| 176 | return RP_SET(mPrimitiveFields.mProjectBackwards, shouldProject); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 177 | } |
| 178 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 179 | bool setProjectionReceiver(bool shouldRecieve) { |
| 180 | return RP_SET(mPrimitiveFields.mProjectionReceiver, shouldRecieve); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 181 | } |
| 182 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 183 | bool isProjectionReceiver() const { |
| 184 | return mPrimitiveFields.mProjectionReceiver; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 185 | } |
| 186 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 187 | bool setStaticMatrix(const SkMatrix* matrix) { |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 188 | delete mStaticMatrix; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 189 | if (matrix) { |
| 190 | mStaticMatrix = new SkMatrix(*matrix); |
| 191 | } else { |
Chris Craik | e84a208 | 2014-12-22 14:28:49 -0800 | [diff] [blame] | 192 | mStaticMatrix = nullptr; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 193 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 194 | return true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | // Can return NULL |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 198 | const SkMatrix* getStaticMatrix() const { |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 199 | return mStaticMatrix; |
| 200 | } |
| 201 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 202 | bool setAnimationMatrix(const SkMatrix* matrix) { |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 203 | delete mAnimationMatrix; |
| 204 | if (matrix) { |
| 205 | mAnimationMatrix = new SkMatrix(*matrix); |
| 206 | } else { |
Chris Craik | e84a208 | 2014-12-22 14:28:49 -0800 | [diff] [blame] | 207 | mAnimationMatrix = nullptr; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 208 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 209 | return true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 210 | } |
| 211 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 212 | bool setAlpha(float alpha) { |
John Reck | 3b52c03 | 2014-08-06 10:19:32 -0700 | [diff] [blame] | 213 | alpha = MathUtils::clampAlpha(alpha); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 214 | return RP_SET(mPrimitiveFields.mAlpha, alpha); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | float getAlpha() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 218 | return mPrimitiveFields.mAlpha; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 219 | } |
| 220 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 221 | bool setHasOverlappingRendering(bool hasOverlappingRendering) { |
| 222 | return RP_SET(mPrimitiveFields.mHasOverlappingRendering, hasOverlappingRendering); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | bool hasOverlappingRendering() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 226 | return mPrimitiveFields.mHasOverlappingRendering; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 227 | } |
| 228 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 229 | bool setElevation(float elevation) { |
| 230 | return RP_SET(mPrimitiveFields.mElevation, elevation); |
| 231 | // Don't dirty matrix/pivot, since they don't respect Z |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | float getElevation() const { |
| 235 | return mPrimitiveFields.mElevation; |
| 236 | } |
| 237 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 238 | bool setTranslationX(float translationX) { |
| 239 | return RP_SET_AND_DIRTY(mPrimitiveFields.mTranslationX, translationX); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | float getTranslationX() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 243 | return mPrimitiveFields.mTranslationX; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 244 | } |
| 245 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 246 | bool setTranslationY(float translationY) { |
| 247 | return RP_SET_AND_DIRTY(mPrimitiveFields.mTranslationY, translationY); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | float getTranslationY() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 251 | return mPrimitiveFields.mTranslationY; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 252 | } |
| 253 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 254 | bool setTranslationZ(float translationZ) { |
| 255 | return RP_SET(mPrimitiveFields.mTranslationZ, translationZ); |
| 256 | // mMatrixOrPivotDirty not set, since matrix doesn't respect Z |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | float getTranslationZ() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 260 | return mPrimitiveFields.mTranslationZ; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 261 | } |
| 262 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 263 | // Animation helper |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 264 | bool setX(float value) { |
| 265 | return setTranslationX(value - getLeft()); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | // Animation helper |
| 269 | float getX() const { |
| 270 | return getLeft() + getTranslationX(); |
| 271 | } |
| 272 | |
| 273 | // Animation helper |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 274 | bool setY(float value) { |
| 275 | return setTranslationY(value - getTop()); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | // Animation helper |
| 279 | float getY() const { |
| 280 | return getTop() + getTranslationY(); |
| 281 | } |
| 282 | |
| 283 | // Animation helper |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 284 | bool setZ(float value) { |
| 285 | return setTranslationZ(value - getElevation()); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 286 | } |
| 287 | |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 288 | float getZ() const { |
| 289 | return getElevation() + getTranslationZ(); |
| 290 | } |
| 291 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 292 | bool setRotation(float rotation) { |
| 293 | return RP_SET_AND_DIRTY(mPrimitiveFields.mRotation, rotation); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | float getRotation() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 297 | return mPrimitiveFields.mRotation; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 298 | } |
| 299 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 300 | bool setRotationX(float rotationX) { |
| 301 | return RP_SET_AND_DIRTY(mPrimitiveFields.mRotationX, rotationX); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | float getRotationX() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 305 | return mPrimitiveFields.mRotationX; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 306 | } |
| 307 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 308 | bool setRotationY(float rotationY) { |
| 309 | return RP_SET_AND_DIRTY(mPrimitiveFields.mRotationY, rotationY); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | float getRotationY() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 313 | return mPrimitiveFields.mRotationY; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 314 | } |
| 315 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 316 | bool setScaleX(float scaleX) { |
| 317 | return RP_SET_AND_DIRTY(mPrimitiveFields.mScaleX, scaleX); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | float getScaleX() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 321 | return mPrimitiveFields.mScaleX; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 322 | } |
| 323 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 324 | bool setScaleY(float scaleY) { |
| 325 | return RP_SET_AND_DIRTY(mPrimitiveFields.mScaleY, scaleY); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | float getScaleY() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 329 | return mPrimitiveFields.mScaleY; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 330 | } |
| 331 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 332 | bool setPivotX(float pivotX) { |
| 333 | if (RP_SET(mPrimitiveFields.mPivotX, pivotX) |
| 334 | || !mPrimitiveFields.mPivotExplicitlySet) { |
| 335 | mPrimitiveFields.mMatrixOrPivotDirty = true; |
| 336 | mPrimitiveFields.mPivotExplicitlySet = true; |
| 337 | return true; |
| 338 | } |
| 339 | return false; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 340 | } |
| 341 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 342 | /* Note that getPivotX and getPivotY are adjusted by updateMatrix(), |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 343 | * so the value returned may be stale if the RenderProperties has been |
| 344 | * modified since the last call to updateMatrix() |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 345 | */ |
| 346 | float getPivotX() const { |
| 347 | return mPrimitiveFields.mPivotX; |
| 348 | } |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 349 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 350 | bool setPivotY(float pivotY) { |
| 351 | if (RP_SET(mPrimitiveFields.mPivotY, pivotY) |
| 352 | || !mPrimitiveFields.mPivotExplicitlySet) { |
| 353 | mPrimitiveFields.mMatrixOrPivotDirty = true; |
| 354 | mPrimitiveFields.mPivotExplicitlySet = true; |
| 355 | return true; |
| 356 | } |
| 357 | return false; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 358 | } |
| 359 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 360 | float getPivotY() const { |
| 361 | return mPrimitiveFields.mPivotY; |
| 362 | } |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 363 | |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 364 | bool isPivotExplicitlySet() const { |
| 365 | return mPrimitiveFields.mPivotExplicitlySet; |
| 366 | } |
| 367 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 368 | bool setCameraDistance(float distance) { |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 369 | if (distance != getCameraDistance()) { |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 370 | mPrimitiveFields.mMatrixOrPivotDirty = true; |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 371 | mComputedFields.mTransformCamera.setCameraLocation(0, 0, distance); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 372 | return true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 373 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 374 | return false; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | float getCameraDistance() const { |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 378 | // TODO: update getCameraLocationZ() to be const |
| 379 | return const_cast<Sk3DView*>(&mComputedFields.mTransformCamera)->getCameraLocationZ(); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 380 | } |
| 381 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 382 | bool setLeft(int left) { |
| 383 | if (RP_SET(mPrimitiveFields.mLeft, left)) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 384 | mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft; |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 385 | if (!mPrimitiveFields.mPivotExplicitlySet) { |
| 386 | mPrimitiveFields.mMatrixOrPivotDirty = true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 387 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 388 | return true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 389 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 390 | return false; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | float getLeft() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 394 | return mPrimitiveFields.mLeft; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 395 | } |
| 396 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 397 | bool setTop(int top) { |
| 398 | if (RP_SET(mPrimitiveFields.mTop, top)) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 399 | mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop; |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 400 | if (!mPrimitiveFields.mPivotExplicitlySet) { |
| 401 | mPrimitiveFields.mMatrixOrPivotDirty = true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 402 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 403 | return true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 404 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 405 | return false; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | float getTop() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 409 | return mPrimitiveFields.mTop; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 410 | } |
| 411 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 412 | bool setRight(int right) { |
| 413 | if (RP_SET(mPrimitiveFields.mRight, right)) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 414 | mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft; |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 415 | if (!mPrimitiveFields.mPivotExplicitlySet) { |
| 416 | mPrimitiveFields.mMatrixOrPivotDirty = true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 417 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 418 | return true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 419 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 420 | return false; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | float getRight() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 424 | return mPrimitiveFields.mRight; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 425 | } |
| 426 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 427 | bool setBottom(int bottom) { |
| 428 | if (RP_SET(mPrimitiveFields.mBottom, bottom)) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 429 | mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop; |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 430 | if (!mPrimitiveFields.mPivotExplicitlySet) { |
| 431 | mPrimitiveFields.mMatrixOrPivotDirty = true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 432 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 433 | return true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 434 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 435 | return false; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | float getBottom() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 439 | return mPrimitiveFields.mBottom; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 440 | } |
| 441 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 442 | bool setLeftTop(int left, int top) { |
| 443 | bool leftResult = setLeft(left); |
| 444 | bool topResult = setTop(top); |
| 445 | return leftResult || topResult; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 446 | } |
| 447 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 448 | bool setLeftTopRightBottom(int left, int top, int right, int bottom) { |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 449 | if (left != mPrimitiveFields.mLeft || top != mPrimitiveFields.mTop |
| 450 | || right != mPrimitiveFields.mRight || bottom != mPrimitiveFields.mBottom) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 451 | mPrimitiveFields.mLeft = left; |
| 452 | mPrimitiveFields.mTop = top; |
| 453 | mPrimitiveFields.mRight = right; |
| 454 | mPrimitiveFields.mBottom = bottom; |
| 455 | mPrimitiveFields.mWidth = mPrimitiveFields.mRight - mPrimitiveFields.mLeft; |
| 456 | mPrimitiveFields.mHeight = mPrimitiveFields.mBottom - mPrimitiveFields.mTop; |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 457 | if (!mPrimitiveFields.mPivotExplicitlySet) { |
| 458 | mPrimitiveFields.mMatrixOrPivotDirty = true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 459 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 460 | return true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 461 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 462 | return false; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 463 | } |
| 464 | |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 465 | bool offsetLeftRight(int offset) { |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 466 | if (offset != 0) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 467 | mPrimitiveFields.mLeft += offset; |
| 468 | mPrimitiveFields.mRight += offset; |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 469 | return true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 470 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 471 | return false; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 472 | } |
| 473 | |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 474 | bool offsetTopBottom(int offset) { |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 475 | if (offset != 0) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 476 | mPrimitiveFields.mTop += offset; |
| 477 | mPrimitiveFields.mBottom += offset; |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 478 | return true; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 479 | } |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 480 | return false; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 481 | } |
| 482 | |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 483 | int getWidth() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 484 | return mPrimitiveFields.mWidth; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 485 | } |
| 486 | |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 487 | int getHeight() const { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 488 | return mPrimitiveFields.mHeight; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 489 | } |
| 490 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 491 | const SkMatrix* getAnimationMatrix() const { |
| 492 | return mAnimationMatrix; |
| 493 | } |
| 494 | |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 495 | bool hasTransformMatrix() const { |
| 496 | return getTransformMatrix() && !getTransformMatrix()->isIdentity(); |
| 497 | } |
| 498 | |
| 499 | // May only call this if hasTransformMatrix() is true |
| 500 | bool isTransformTranslateOnly() const { |
| 501 | return getTransformMatrix()->getType() == SkMatrix::kTranslate_Mask; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 502 | } |
| 503 | |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 504 | const SkMatrix* getTransformMatrix() const { |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 505 | LOG_ALWAYS_FATAL_IF(mPrimitiveFields.mMatrixOrPivotDirty, "Cannot get a dirty matrix!"); |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 506 | return mComputedFields.mTransformMatrix; |
| 507 | } |
| 508 | |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 509 | int getClippingFlags() const { |
| 510 | return mPrimitiveFields.mClippingFlags; |
| 511 | } |
| 512 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 513 | bool getClipToBounds() const { |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 514 | return mPrimitiveFields.mClippingFlags & CLIP_TO_BOUNDS; |
| 515 | } |
| 516 | |
| 517 | void getClippingRectForFlags(uint32_t flags, Rect* outRect) const { |
| 518 | if (flags & CLIP_TO_BOUNDS) { |
| 519 | outRect->set(0, 0, getWidth(), getHeight()); |
| 520 | if (flags & CLIP_TO_CLIP_BOUNDS) { |
| 521 | outRect->intersect(mPrimitiveFields.mClipBounds); |
| 522 | } |
| 523 | } else { |
| 524 | outRect->set(mPrimitiveFields.mClipBounds); |
| 525 | } |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | bool getHasOverlappingRendering() const { |
| 529 | return mPrimitiveFields.mHasOverlappingRendering; |
| 530 | } |
| 531 | |
| 532 | const Outline& getOutline() const { |
| 533 | return mPrimitiveFields.mOutline; |
| 534 | } |
| 535 | |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 536 | const RevealClip& getRevealClip() const { |
| 537 | return mPrimitiveFields.mRevealClip; |
| 538 | } |
| 539 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 540 | bool getProjectBackwards() const { |
| 541 | return mPrimitiveFields.mProjectBackwards; |
| 542 | } |
| 543 | |
| 544 | void debugOutputProperties(const int level) const; |
| 545 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 546 | void updateMatrix(); |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 547 | |
| 548 | Outline& mutableOutline() { |
| 549 | return mPrimitiveFields.mOutline; |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 550 | } |
| 551 | |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 552 | RevealClip& mutableRevealClip() { |
| 553 | return mPrimitiveFields.mRevealClip; |
| 554 | } |
| 555 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 556 | const LayerProperties& layerProperties() const { |
| 557 | return mLayerProperties; |
| 558 | } |
| 559 | |
| 560 | LayerProperties& mutateLayerProperties() { |
| 561 | return mLayerProperties; |
| 562 | } |
| 563 | |
John Reck | 293e868 | 2014-06-17 10:34:02 -0700 | [diff] [blame] | 564 | // Returns true if damage calculations should be clipped to bounds |
| 565 | // TODO: Figure out something better for getZ(), as children should still be |
| 566 | // clipped to this RP's bounds. But as we will damage -INT_MAX to INT_MAX |
| 567 | // for this RP's getZ() anyway, this can be optimized when we have a |
| 568 | // Z damage estimate instead of INT_MAX |
| 569 | bool getClipDamageToBounds() const { |
| 570 | return getClipToBounds() && (getZ() <= 0 || getOutline().isEmpty()); |
| 571 | } |
| 572 | |
Chris Craik | 5c75c52 | 2014-09-05 14:08:08 -0700 | [diff] [blame] | 573 | bool hasShadow() const { |
Chris Craik | b5a5435 | 2014-11-21 14:54:35 -0800 | [diff] [blame] | 574 | return getZ() > 0.0f |
Chris Craik | e84a208 | 2014-12-22 14:28:49 -0800 | [diff] [blame] | 575 | && getOutline().getPath() != nullptr |
Chris Craik | 9fa364d | 2014-09-19 16:04:45 -0700 | [diff] [blame] | 576 | && getOutline().getAlpha() != 0.0f; |
Chris Craik | 5c75c52 | 2014-09-05 14:08:08 -0700 | [diff] [blame] | 577 | } |
| 578 | |
Chris Craik | 1a0808e | 2015-05-13 16:33:04 -0700 | [diff] [blame] | 579 | bool promotedToLayer() const { |
| 580 | return mLayerProperties.mType == LayerType::None |
Chris Craik | 856f0cc | 2015-04-21 15:13:29 -0700 | [diff] [blame] | 581 | && !MathUtils::isZero(mPrimitiveFields.mAlpha) |
| 582 | && mPrimitiveFields.mAlpha < 1 |
Chris Craik | 1a0808e | 2015-05-13 16:33:04 -0700 | [diff] [blame] | 583 | && mPrimitiveFields.mHasOverlappingRendering; |
| 584 | } |
| 585 | |
| 586 | LayerType effectiveLayerType() const { |
| 587 | return promotedToLayer() ? LayerType::RenderLayer : mLayerProperties.mType; |
Chris Craik | 856f0cc | 2015-04-21 15:13:29 -0700 | [diff] [blame] | 588 | } |
| 589 | |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 590 | private: |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 591 | // Rendering properties |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 592 | struct PrimitiveFields { |
| 593 | PrimitiveFields(); |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 594 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 595 | Outline mOutline; |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 596 | RevealClip mRevealClip; |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 597 | int mClippingFlags; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 598 | bool mProjectBackwards; |
| 599 | bool mProjectionReceiver; |
| 600 | float mAlpha; |
| 601 | bool mHasOverlappingRendering; |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 602 | float mElevation; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 603 | float mTranslationX, mTranslationY, mTranslationZ; |
| 604 | float mRotation, mRotationX, mRotationY; |
| 605 | float mScaleX, mScaleY; |
| 606 | float mPivotX, mPivotY; |
| 607 | int mLeft, mTop, mRight, mBottom; |
| 608 | int mWidth, mHeight; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 609 | bool mPivotExplicitlySet; |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 610 | bool mMatrixOrPivotDirty; |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 611 | Rect mClipBounds; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 612 | } mPrimitiveFields; |
| 613 | |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 614 | SkMatrix* mStaticMatrix; |
| 615 | SkMatrix* mAnimationMatrix; |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 616 | LayerProperties mLayerProperties; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 617 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 618 | /** |
| 619 | * These fields are all generated from other properties and are not set directly. |
| 620 | */ |
| 621 | struct ComputedFields { |
| 622 | ComputedFields(); |
| 623 | ~ComputedFields(); |
| 624 | |
| 625 | /** |
| 626 | * Stores the total transformation of the DisplayList based upon its scalar |
| 627 | * translate/rotate/scale properties. |
| 628 | * |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 629 | * In the common translation-only case, the matrix isn't necessarily allocated, |
| 630 | * and the mTranslation properties are used directly. |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 631 | */ |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 632 | SkMatrix* mTransformMatrix; |
| 633 | |
| 634 | Sk3DView mTransformCamera; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 635 | } mComputedFields; |
John Reck | acb6f07 | 2014-03-12 16:11:23 -0700 | [diff] [blame] | 636 | }; |
| 637 | |
| 638 | } /* namespace uirenderer */ |
| 639 | } /* namespace android */ |
| 640 | |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 641 | #endif /* RENDERNODEPROPERTIES_H */ |