Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [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 | */ |
| 16 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 17 | #include "CanvasState.h" |
sergeyv | dccca44 | 2016-03-21 15:38:21 -0700 | [diff] [blame] | 18 | #include "hwui/Canvas.h" |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 19 | #include "utils/MathUtils.h" |
| 20 | |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 21 | namespace android { |
| 22 | namespace uirenderer { |
| 23 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 24 | |
| 25 | CanvasState::CanvasState(CanvasStateClient& renderer) |
Chris Craik | 058fc64 | 2014-07-23 18:19:28 -0700 | [diff] [blame] | 26 | : mDirtyClip(false) |
| 27 | , mWidth(-1) |
| 28 | , mHeight(-1) |
| 29 | , mSaveCount(1) |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 30 | , mCanvas(renderer) |
John Reck | d9ee550 | 2015-10-06 10:06:37 -0700 | [diff] [blame] | 31 | , mSnapshot(&mFirstSnapshot) { |
| 32 | } |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 33 | |
John Reck | d9ee550 | 2015-10-06 10:06:37 -0700 | [diff] [blame] | 34 | CanvasState::~CanvasState() { |
| 35 | // First call freeSnapshot on all but mFirstSnapshot |
| 36 | // to invoke all the dtors |
| 37 | freeAllSnapshots(); |
| 38 | |
| 39 | // Now actually release the memory |
| 40 | while (mSnapshotPool) { |
| 41 | void* temp = mSnapshotPool; |
| 42 | mSnapshotPool = mSnapshotPool->previous; |
| 43 | free(temp); |
| 44 | } |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 45 | } |
| 46 | |
Chris Craik | e4db79d | 2015-12-22 16:32:23 -0800 | [diff] [blame] | 47 | void CanvasState::initializeRecordingSaveStack(int viewportWidth, int viewportHeight) { |
| 48 | if (mWidth != viewportWidth || mHeight != viewportHeight) { |
| 49 | mWidth = viewportWidth; |
| 50 | mHeight = viewportHeight; |
| 51 | mFirstSnapshot.initializeViewport(viewportWidth, viewportHeight); |
| 52 | mCanvas.onViewportInitialized(); |
| 53 | } |
| 54 | |
| 55 | freeAllSnapshots(); |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 56 | mSnapshot = allocSnapshot(&mFirstSnapshot, SaveFlags::MatrixClip); |
Chris Craik | e4db79d | 2015-12-22 16:32:23 -0800 | [diff] [blame] | 57 | mSnapshot->setRelativeLightCenter(Vector3()); |
| 58 | mSaveCount = 1; |
| 59 | } |
| 60 | |
Chris Craik | 64e445b | 2015-09-02 14:23:49 -0700 | [diff] [blame] | 61 | void CanvasState::initializeSaveStack( |
| 62 | int viewportWidth, int viewportHeight, |
| 63 | float clipLeft, float clipTop, |
Chris Craik | 69e5adf | 2014-08-14 13:34:01 -0700 | [diff] [blame] | 64 | float clipRight, float clipBottom, const Vector3& lightCenter) { |
Chris Craik | 64e445b | 2015-09-02 14:23:49 -0700 | [diff] [blame] | 65 | if (mWidth != viewportWidth || mHeight != viewportHeight) { |
| 66 | mWidth = viewportWidth; |
| 67 | mHeight = viewportHeight; |
John Reck | d9ee550 | 2015-10-06 10:06:37 -0700 | [diff] [blame] | 68 | mFirstSnapshot.initializeViewport(viewportWidth, viewportHeight); |
Chris Craik | 64e445b | 2015-09-02 14:23:49 -0700 | [diff] [blame] | 69 | mCanvas.onViewportInitialized(); |
| 70 | } |
| 71 | |
John Reck | d9ee550 | 2015-10-06 10:06:37 -0700 | [diff] [blame] | 72 | freeAllSnapshots(); |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 73 | mSnapshot = allocSnapshot(&mFirstSnapshot, SaveFlags::MatrixClip); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 74 | mSnapshot->setClip(clipLeft, clipTop, clipRight, clipBottom); |
Chris Craik | 6b109c7 | 2015-02-27 10:55:28 -0800 | [diff] [blame] | 75 | mSnapshot->fbo = mCanvas.getTargetFbo(); |
Chris Craik | 69e5adf | 2014-08-14 13:34:01 -0700 | [diff] [blame] | 76 | mSnapshot->setRelativeLightCenter(lightCenter); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 77 | mSaveCount = 1; |
| 78 | } |
| 79 | |
John Reck | d9ee550 | 2015-10-06 10:06:37 -0700 | [diff] [blame] | 80 | Snapshot* CanvasState::allocSnapshot(Snapshot* previous, int savecount) { |
| 81 | void* memory; |
| 82 | if (mSnapshotPool) { |
| 83 | memory = mSnapshotPool; |
| 84 | mSnapshotPool = mSnapshotPool->previous; |
| 85 | mSnapshotPoolCount--; |
| 86 | } else { |
| 87 | memory = malloc(sizeof(Snapshot)); |
| 88 | } |
| 89 | return new (memory) Snapshot(previous, savecount); |
| 90 | } |
| 91 | |
| 92 | void CanvasState::freeSnapshot(Snapshot* snapshot) { |
| 93 | snapshot->~Snapshot(); |
| 94 | // Arbitrary number, just don't let this grown unbounded |
| 95 | if (mSnapshotPoolCount > 10) { |
| 96 | free((void*) snapshot); |
| 97 | } else { |
| 98 | snapshot->previous = mSnapshotPool; |
| 99 | mSnapshotPool = snapshot; |
| 100 | mSnapshotPoolCount++; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | void CanvasState::freeAllSnapshots() { |
| 105 | while (mSnapshot != &mFirstSnapshot) { |
| 106 | Snapshot* temp = mSnapshot; |
| 107 | mSnapshot = mSnapshot->previous; |
| 108 | freeSnapshot(temp); |
| 109 | } |
| 110 | } |
| 111 | |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 112 | /////////////////////////////////////////////////////////////////////////////// |
| 113 | // Save (layer) |
| 114 | /////////////////////////////////////////////////////////////////////////////// |
| 115 | |
| 116 | /** |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 117 | * Guaranteed to save without side-effects |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 118 | * |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 119 | * This approach, here and in restoreSnapshot(), allows subclasses to directly manipulate the save |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 120 | * stack, and ensures restoreToCount() doesn't call back into subclass overrides. |
| 121 | */ |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 122 | int CanvasState::saveSnapshot(int flags) { |
John Reck | d9ee550 | 2015-10-06 10:06:37 -0700 | [diff] [blame] | 123 | mSnapshot = allocSnapshot(mSnapshot, flags); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 124 | return mSaveCount++; |
| 125 | } |
| 126 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 127 | int CanvasState::save(int flags) { |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 128 | return saveSnapshot(flags); |
| 129 | } |
| 130 | |
| 131 | /** |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 132 | * Guaranteed to restore without side-effects. |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 133 | */ |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 134 | void CanvasState::restoreSnapshot() { |
John Reck | d9ee550 | 2015-10-06 10:06:37 -0700 | [diff] [blame] | 135 | Snapshot* toRemove = mSnapshot; |
| 136 | Snapshot* toRestore = mSnapshot->previous; |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 137 | |
| 138 | mSaveCount--; |
| 139 | mSnapshot = toRestore; |
| 140 | |
| 141 | // subclass handles restore implementation |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 142 | mCanvas.onSnapshotRestored(*toRemove, *toRestore); |
John Reck | d9ee550 | 2015-10-06 10:06:37 -0700 | [diff] [blame] | 143 | |
| 144 | freeSnapshot(toRemove); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 145 | } |
| 146 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 147 | void CanvasState::restore() { |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 148 | if (mSaveCount > 1) { |
| 149 | restoreSnapshot(); |
| 150 | } |
| 151 | } |
| 152 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 153 | void CanvasState::restoreToCount(int saveCount) { |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 154 | if (saveCount < 1) saveCount = 1; |
| 155 | |
| 156 | while (mSaveCount > saveCount) { |
| 157 | restoreSnapshot(); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | /////////////////////////////////////////////////////////////////////////////// |
| 162 | // Matrix |
| 163 | /////////////////////////////////////////////////////////////////////////////// |
| 164 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 165 | void CanvasState::getMatrix(SkMatrix* matrix) const { |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 166 | mSnapshot->transform->copyTo(*matrix); |
| 167 | } |
| 168 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 169 | void CanvasState::translate(float dx, float dy, float dz) { |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 170 | mSnapshot->transform->translate(dx, dy, dz); |
| 171 | } |
| 172 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 173 | void CanvasState::rotate(float degrees) { |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 174 | mSnapshot->transform->rotate(degrees, 0.0f, 0.0f, 1.0f); |
| 175 | } |
| 176 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 177 | void CanvasState::scale(float sx, float sy) { |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 178 | mSnapshot->transform->scale(sx, sy, 1.0f); |
| 179 | } |
| 180 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 181 | void CanvasState::skew(float sx, float sy) { |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 182 | mSnapshot->transform->skew(sx, sy); |
| 183 | } |
| 184 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 185 | void CanvasState::setMatrix(const SkMatrix& matrix) { |
Derek Sollenberger | 1390882 | 2013-12-10 12:28:58 -0500 | [diff] [blame] | 186 | mSnapshot->transform->load(matrix); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 187 | } |
| 188 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 189 | void CanvasState::setMatrix(const Matrix4& matrix) { |
Chris Craik | 7c85c54 | 2015-08-19 15:10:24 -0700 | [diff] [blame] | 190 | *(mSnapshot->transform) = matrix; |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 191 | } |
| 192 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 193 | void CanvasState::concatMatrix(const SkMatrix& matrix) { |
Derek Sollenberger | 1390882 | 2013-12-10 12:28:58 -0500 | [diff] [blame] | 194 | mat4 transform(matrix); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 195 | mSnapshot->transform->multiply(transform); |
| 196 | } |
| 197 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 198 | void CanvasState::concatMatrix(const Matrix4& matrix) { |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 199 | mSnapshot->transform->multiply(matrix); |
| 200 | } |
| 201 | |
| 202 | /////////////////////////////////////////////////////////////////////////////// |
| 203 | // Clip |
| 204 | /////////////////////////////////////////////////////////////////////////////// |
| 205 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 206 | bool CanvasState::clipRect(float left, float top, float right, float bottom, SkRegion::Op op) { |
Chris Craik | a2a7072 | 2015-12-17 12:58:24 -0800 | [diff] [blame] | 207 | mSnapshot->clip(Rect(left, top, right, bottom), op); |
Chris Craik | 4d3e704 | 2015-08-20 12:54:25 -0700 | [diff] [blame] | 208 | mDirtyClip = true; |
Rob Tsuk | 487a92c | 2015-01-06 13:22:54 -0800 | [diff] [blame] | 209 | return !mSnapshot->clipIsEmpty(); |
Chris Craik | d6b65f6 | 2014-01-01 14:45:21 -0800 | [diff] [blame] | 210 | } |
| 211 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 212 | bool CanvasState::clipPath(const SkPath* path, SkRegion::Op op) { |
Chris Craik | 4d3e704 | 2015-08-20 12:54:25 -0700 | [diff] [blame] | 213 | mSnapshot->clipPath(*path, op); |
| 214 | mDirtyClip = true; |
Rob Tsuk | 487a92c | 2015-01-06 13:22:54 -0800 | [diff] [blame] | 215 | return !mSnapshot->clipIsEmpty(); |
Chris Craik | d6b65f6 | 2014-01-01 14:45:21 -0800 | [diff] [blame] | 216 | } |
| 217 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 218 | bool CanvasState::clipRegion(const SkRegion* region, SkRegion::Op op) { |
Chris Craik | 4d3e704 | 2015-08-20 12:54:25 -0700 | [diff] [blame] | 219 | mSnapshot->clipRegionTransformed(*region, op); |
| 220 | mDirtyClip = true; |
Rob Tsuk | 487a92c | 2015-01-06 13:22:54 -0800 | [diff] [blame] | 221 | return !mSnapshot->clipIsEmpty(); |
Chris Craik | d6b65f6 | 2014-01-01 14:45:21 -0800 | [diff] [blame] | 222 | } |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 223 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 224 | void CanvasState::setClippingOutline(LinearAllocator& allocator, const Outline* outline) { |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 225 | Rect bounds; |
| 226 | float radius; |
| 227 | if (!outline->getAsRoundRect(&bounds, &radius)) return; // only RR supported |
| 228 | |
Chris Craik | 79d26c7 | 2014-08-21 12:26:16 -0700 | [diff] [blame] | 229 | bool outlineIsRounded = MathUtils::isPositive(radius); |
| 230 | if (!outlineIsRounded || currentTransform()->isSimple()) { |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 231 | // TODO: consider storing this rect separately, so that this can't be replaced with clip ops |
| 232 | clipRect(bounds.left, bounds.top, bounds.right, bounds.bottom, SkRegion::kIntersect_Op); |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 233 | } |
Chris Craik | 79d26c7 | 2014-08-21 12:26:16 -0700 | [diff] [blame] | 234 | if (outlineIsRounded) { |
Chris Craik | e83cbd4 | 2014-09-03 17:52:24 -0700 | [diff] [blame] | 235 | setClippingRoundRect(allocator, bounds, radius, false); |
Chris Craik | 79d26c7 | 2014-08-21 12:26:16 -0700 | [diff] [blame] | 236 | } |
Chris Craik | deeda3d | 2014-05-05 19:09:33 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 239 | void CanvasState::setClippingRoundRect(LinearAllocator& allocator, |
Chris Craik | e83cbd4 | 2014-09-03 17:52:24 -0700 | [diff] [blame] | 240 | const Rect& rect, float radius, bool highPriority) { |
| 241 | mSnapshot->setClippingRoundRect(allocator, rect, radius, highPriority); |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 242 | } |
| 243 | |
Chris Craik | fca52b75 | 2015-04-28 11:45:59 -0700 | [diff] [blame] | 244 | void CanvasState::setProjectionPathMask(LinearAllocator& allocator, const SkPath* path) { |
| 245 | mSnapshot->setProjectionPathMask(allocator, path); |
| 246 | } |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 247 | |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 248 | /////////////////////////////////////////////////////////////////////////////// |
| 249 | // Quick Rejection |
| 250 | /////////////////////////////////////////////////////////////////////////////// |
| 251 | |
| 252 | /** |
| 253 | * Calculates whether content drawn within the passed bounds would be outside of, or intersect with |
| 254 | * the clipRect. Does not modify the scissor. |
| 255 | * |
| 256 | * @param clipRequired if not null, will be set to true if element intersects clip |
| 257 | * (and wasn't rejected) |
| 258 | * |
| 259 | * @param snapOut if set, the geometry will be treated as having an AA ramp. |
| 260 | * See Rect::snapGeometryToPixelBoundaries() |
| 261 | */ |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 262 | bool CanvasState::calculateQuickRejectForScissor(float left, float top, |
Chris Craik | deeda3d | 2014-05-05 19:09:33 -0700 | [diff] [blame] | 263 | float right, float bottom, |
| 264 | bool* clipRequired, bool* roundRectClipRequired, |
| 265 | bool snapOut) const { |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 266 | if (mSnapshot->isIgnored() || bottom <= top || right <= left) { |
| 267 | return true; |
| 268 | } |
| 269 | |
| 270 | Rect r(left, top, right, bottom); |
Chris Craik | d6b65f6 | 2014-01-01 14:45:21 -0800 | [diff] [blame] | 271 | currentTransform()->mapRect(r); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 272 | r.snapGeometryToPixelBoundaries(snapOut); |
| 273 | |
Chris Craik | 6fe991e5 | 2015-10-20 09:39:42 -0700 | [diff] [blame] | 274 | Rect clipRect(currentRenderTargetClip()); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 275 | clipRect.snapToPixelBoundaries(); |
| 276 | |
| 277 | if (!clipRect.intersects(r)) return true; |
| 278 | |
| 279 | // clip is required if geometry intersects clip rect |
Chris Craik | deeda3d | 2014-05-05 19:09:33 -0700 | [diff] [blame] | 280 | if (clipRequired) { |
| 281 | *clipRequired = !clipRect.contains(r); |
| 282 | } |
| 283 | |
| 284 | // round rect clip is required if RR clip exists, and geometry intersects its corners |
| 285 | if (roundRectClipRequired) { |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 286 | *roundRectClipRequired = mSnapshot->roundRectClipState != nullptr |
Chris Craik | deeda3d | 2014-05-05 19:09:33 -0700 | [diff] [blame] | 287 | && mSnapshot->roundRectClipState->areaRequiresRoundRectClip(r); |
| 288 | } |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 289 | return false; |
| 290 | } |
| 291 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 292 | bool CanvasState::quickRejectConservative(float left, float top, |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 293 | float right, float bottom) const { |
| 294 | if (mSnapshot->isIgnored() || bottom <= top || right <= left) { |
| 295 | return true; |
| 296 | } |
| 297 | |
| 298 | Rect r(left, top, right, bottom); |
Chris Craik | d6b65f6 | 2014-01-01 14:45:21 -0800 | [diff] [blame] | 299 | currentTransform()->mapRect(r); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 300 | r.roundOut(); // rounded out to be conservative |
| 301 | |
Chris Craik | 6fe991e5 | 2015-10-20 09:39:42 -0700 | [diff] [blame] | 302 | Rect clipRect(currentRenderTargetClip()); |
Chris Craik | 14e5130 | 2013-12-30 15:32:54 -0800 | [diff] [blame] | 303 | clipRect.snapToPixelBoundaries(); |
| 304 | |
| 305 | if (!clipRect.intersects(r)) return true; |
| 306 | |
| 307 | return false; |
| 308 | } |
| 309 | |
Tom Hudson | 984162f | 2014-10-10 13:38:16 -0400 | [diff] [blame] | 310 | } // namespace uirenderer |
| 311 | } // namespace android |