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