commit-bot@chromium.org | c4b21e6 | 2014-04-11 18:33:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
commit-bot@chromium.org | 506db0b | 2014-04-08 23:31:35 +0000 | [diff] [blame] | 8 | #include "SkRecordDraw.h" |
mtklein | 131a22b | 2014-08-25 14:16:15 -0700 | [diff] [blame] | 9 | #include "SkPatchUtils.h" |
commit-bot@chromium.org | 506db0b | 2014-04-08 23:31:35 +0000 | [diff] [blame] | 10 | |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 11 | void SkRecordDraw(const SkRecord& record, |
| 12 | SkCanvas* canvas, |
| 13 | const SkBBoxHierarchy* bbh, |
| 14 | SkDrawPictureCallback* callback) { |
Mike Klein | c11530e | 2014-06-24 11:29:06 -0400 | [diff] [blame] | 15 | SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 16 | |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 17 | if (bbh) { |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 18 | // Draw only ops that affect pixels in the canvas's current clip. |
mtklein | 3e8232b | 2014-08-18 13:39:11 -0700 | [diff] [blame] | 19 | // The SkRecord and BBH were recorded in identity space. This canvas |
| 20 | // is not necessarily in that same space. getClipBounds() returns us |
| 21 | // this canvas' clip bounds transformed back into identity space, which |
| 22 | // lets us query the BBH. |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 23 | SkRect query = { 0, 0, 0, 0 }; |
| 24 | (void)canvas->getClipBounds(&query); |
mtklein | 3e8232b | 2014-08-18 13:39:11 -0700 | [diff] [blame] | 25 | |
mtklein | 6bd4196 | 2014-10-02 07:41:56 -0700 | [diff] [blame] | 26 | SkTDArray<unsigned> ops; |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 27 | bbh->search(query, &ops); |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 28 | |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 29 | SkRecords::Draw draw(canvas); |
| 30 | for (int i = 0; i < ops.count(); i++) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 31 | if (callback && callback->abortDrawing()) { |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 32 | return; |
| 33 | } |
mtklein | 6bd4196 | 2014-10-02 07:41:56 -0700 | [diff] [blame] | 34 | record.visit<void>(ops[i], draw); |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 35 | } |
| 36 | } else { |
| 37 | // Draw all ops. |
mtklein | 00f30bd | 2014-09-02 12:03:31 -0700 | [diff] [blame] | 38 | SkRecords::Draw draw(canvas); |
| 39 | for (unsigned i = 0; i < record.count(); i++) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 40 | if (callback && callback->abortDrawing()) { |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 41 | return; |
| 42 | } |
mtklein | 00f30bd | 2014-09-02 12:03:31 -0700 | [diff] [blame] | 43 | record.visit<void>(i, draw); |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 44 | } |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 45 | } |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 46 | } |
commit-bot@chromium.org | d9ce2be | 2014-04-09 23:30:28 +0000 | [diff] [blame] | 47 | |
mtklein | 00f30bd | 2014-09-02 12:03:31 -0700 | [diff] [blame] | 48 | void SkRecordPartialDraw(const SkRecord& record, |
| 49 | SkCanvas* canvas, |
| 50 | const SkRect& clearRect, |
robertphillips | 4815fe5 | 2014-09-16 10:32:43 -0700 | [diff] [blame] | 51 | unsigned start, unsigned stop, |
| 52 | const SkMatrix& initialCTM) { |
mtklein | 00f30bd | 2014-09-02 12:03:31 -0700 | [diff] [blame] | 53 | SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
| 54 | |
| 55 | stop = SkTMin(stop, record.count()); |
robertphillips | 4815fe5 | 2014-09-16 10:32:43 -0700 | [diff] [blame] | 56 | SkRecords::PartialDraw draw(canvas, clearRect, initialCTM); |
mtklein | 00f30bd | 2014-09-02 12:03:31 -0700 | [diff] [blame] | 57 | for (unsigned i = start; i < stop; i++) { |
| 58 | record.visit<void>(i, draw); |
| 59 | } |
| 60 | } |
| 61 | |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 62 | namespace SkRecords { |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 63 | |
mtklein | 7cdc1ee | 2014-07-07 10:41:04 -0700 | [diff] [blame] | 64 | // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multiple threads. |
| 65 | static SkBitmap shallow_copy(const SkBitmap& bitmap) { |
| 66 | return bitmap; |
| 67 | } |
| 68 | |
commit-bot@chromium.org | 2e0c32a | 2014-04-28 16:19:45 +0000 | [diff] [blame] | 69 | // NoOps draw nothing. |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 70 | template <> void Draw::draw(const NoOp&) {} |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 71 | |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 72 | #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 73 | DRAW(Restore, restore()); |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 74 | DRAW(Save, save()); |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 75 | DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); |
| 76 | DRAW(PopCull, popCull()); |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 77 | DRAW(PushCull, pushCull(r.rect)); |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 78 | DRAW(Clear, clear(r.color)); |
commit-bot@chromium.org | 99bd7d8 | 2014-05-19 15:51:12 +0000 | [diff] [blame] | 79 | DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 80 | |
| 81 | DRAW(ClipPath, clipPath(r.path, r.op, r.doAA)); |
| 82 | DRAW(ClipRRect, clipRRect(r.rrect, r.op, r.doAA)); |
| 83 | DRAW(ClipRect, clipRect(r.rect, r.op, r.doAA)); |
| 84 | DRAW(ClipRegion, clipRegion(r.region, r.op)); |
| 85 | |
mtklein | 5f0e822 | 2014-08-22 11:44:26 -0700 | [diff] [blame] | 86 | DRAW(BeginCommentGroup, beginCommentGroup(r.description)); |
| 87 | DRAW(AddComment, addComment(r.key, r.value)); |
| 88 | DRAW(EndCommentGroup, endCommentGroup()); |
| 89 | |
mtklein | 7cdc1ee | 2014-07-07 10:41:04 -0700 | [diff] [blame] | 90 | DRAW(DrawBitmap, drawBitmap(shallow_copy(r.bitmap), r.left, r.top, r.paint)); |
| 91 | DRAW(DrawBitmapMatrix, drawBitmapMatrix(shallow_copy(r.bitmap), r.matrix, r.paint)); |
| 92 | DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.paint)); |
| 93 | DRAW(DrawBitmapRectToRect, |
| 94 | drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, r.flags)); |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 95 | DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); |
| 96 | DRAW(DrawOval, drawOval(r.oval, r.paint)); |
| 97 | DRAW(DrawPaint, drawPaint(r.paint)); |
| 98 | DRAW(DrawPath, drawPath(r.path, r.paint)); |
mtklein | 9b222a5 | 2014-09-18 11:16:31 -0700 | [diff] [blame] | 99 | DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode, r.paint)); |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 100 | DRAW(DrawPicture, drawPicture(r.picture, r.matrix, r.paint)); |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 101 | DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint)); |
| 102 | DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); |
| 103 | DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); |
| 104 | DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); |
| 105 | DRAW(DrawRect, drawRect(r.rect, r.paint)); |
mtklein | 7cdc1ee | 2014-07-07 10:41:04 -0700 | [diff] [blame] | 106 | DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint)); |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 107 | DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); |
fmalita | 00d5c2c | 2014-08-21 08:53:26 -0700 | [diff] [blame] | 108 | DRAW(DrawTextBlob, drawTextBlob(r.blob, r.x, r.y, r.paint)); |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 109 | DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.paint)); |
| 110 | DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, |
| 111 | r.xmode.get(), r.indices, r.indexCount, r.paint)); |
mtklein | 29dfaa8 | 2014-09-04 14:12:44 -0700 | [diff] [blame] | 112 | DRAW(DrawData, drawData(r.data, r.length)); |
commit-bot@chromium.org | 73b55eb | 2014-04-14 20:35:12 +0000 | [diff] [blame] | 113 | #undef DRAW |
| 114 | |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 115 | |
| 116 | // This is an SkRecord visitor that fills an SkBBoxHierarchy. |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 117 | // |
| 118 | // The interesting part here is how to calculate bounds for ops which don't |
| 119 | // have intrinsic bounds. What is the bounds of a Save or a Translate? |
| 120 | // |
| 121 | // We answer this by thinking about a particular definition of bounds: if I |
| 122 | // don't execute this op, pixels in this rectangle might draw incorrectly. So |
| 123 | // the bounds of a Save, a Translate, a Restore, etc. are the union of the |
| 124 | // bounds of Draw* ops that they might have an effect on. For any given |
| 125 | // Save/Restore block, the bounds of the Save, the Restore, and any other |
| 126 | // non-drawing ("control") ops inside are exactly the union of the bounds of |
| 127 | // the drawing ops inside that block. |
| 128 | // |
| 129 | // To implement this, we keep a stack of active Save blocks. As we consume ops |
| 130 | // inside the Save/Restore block, drawing ops are unioned with the bounds of |
| 131 | // the block, and control ops are stashed away for later. When we finish the |
| 132 | // block with a Restore, our bounds are complete, and we go back and fill them |
| 133 | // in for all the control ops we stashed away. |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 134 | class FillBounds : SkNoncopyable { |
| 135 | public: |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 136 | FillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) : fBounds(record.count()) { |
| 137 | // Calculate bounds for all ops. This won't go quite in order, so we'll need |
| 138 | // to store the bounds separately then feed them in to the BBH later in order. |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 139 | const Bounds largest = Bounds::MakeLargest(); |
mtklein | 6332f1d | 2014-08-19 07:09:40 -0700 | [diff] [blame] | 140 | fCTM = &SkMatrix::I(); |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 141 | fCurrentClipBounds = largest; |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 142 | for (fCurrentOp = 0; fCurrentOp < record.count(); fCurrentOp++) { |
| 143 | record.visit<void>(fCurrentOp, *this); |
| 144 | } |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 145 | |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 146 | // If we have any lingering unpaired Saves, simulate restores to make |
| 147 | // sure all ops in those Save blocks have their bounds calculated. |
| 148 | while (!fSaveStack.isEmpty()) { |
| 149 | this->popSaveBlock(); |
| 150 | } |
| 151 | |
| 152 | // Any control ops not part of any Save/Restore block draw everywhere. |
| 153 | while (!fControlIndices.isEmpty()) { |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 154 | this->popControl(largest); |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | // Finally feed all stored bounds into the BBH. They'll be returned in this order. |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 158 | SkASSERT(bbh); |
mtklein | 6bd4196 | 2014-10-02 07:41:56 -0700 | [diff] [blame] | 159 | for (unsigned i = 0; i < record.count(); i++) { |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 160 | if (!fBounds[i].isEmpty()) { |
mtklein | 6bd4196 | 2014-10-02 07:41:56 -0700 | [diff] [blame] | 161 | bbh->insert(i, fBounds[i], true/*ok to defer*/); |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | bbh->flushDeferredInserts(); |
| 165 | } |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 166 | |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 167 | template <typename T> void operator()(const T& op) { |
| 168 | this->updateCTM(op); |
| 169 | this->updateClipBounds(op); |
| 170 | this->trackBounds(op); |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | private: |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 174 | // In this file, SkRect are in local coordinates, Bounds are translated back to identity space. |
| 175 | typedef SkRect Bounds; |
| 176 | |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 177 | struct SaveBounds { |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 178 | int controlOps; // Number of control ops in this Save block, including the Save. |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 179 | Bounds bounds; // Bounds of everything in the block. |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 180 | const SkPaint* paint; // Unowned. If set, adjusts the bounds of all ops in this block. |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 181 | }; |
| 182 | |
mtklein | 8e393bf | 2014-10-01 12:48:58 -0700 | [diff] [blame] | 183 | // Only Restore and SetMatrix change the CTM. |
| 184 | template <typename T> void updateCTM(const T&) {} |
mtklein | 6332f1d | 2014-08-19 07:09:40 -0700 | [diff] [blame] | 185 | void updateCTM(const Restore& op) { fCTM = &op.matrix; } |
| 186 | void updateCTM(const SetMatrix& op) { fCTM = &op.matrix; } |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 187 | |
mtklein | 8e393bf | 2014-10-01 12:48:58 -0700 | [diff] [blame] | 188 | // Most ops don't change the clip. |
| 189 | template <typename T> void updateClipBounds(const T&) {} |
Mike Klein | 271a030 | 2014-09-23 15:28:38 -0400 | [diff] [blame] | 190 | |
mtklein | 8e393bf | 2014-10-01 12:48:58 -0700 | [diff] [blame] | 191 | // Clip{Path,RRect,Rect,Region} obviously change the clip. They all know their bounds already. |
| 192 | void updateClipBounds(const ClipPath& op) { this->updateClipBoundsForClipOp(op.devBounds); } |
| 193 | void updateClipBounds(const ClipRRect& op) { this->updateClipBoundsForClipOp(op.devBounds); } |
| 194 | void updateClipBounds(const ClipRect& op) { this->updateClipBoundsForClipOp(op.devBounds); } |
| 195 | void updateClipBounds(const ClipRegion& op) { this->updateClipBoundsForClipOp(op.devBounds); } |
Mike Klein | 271a030 | 2014-09-23 15:28:38 -0400 | [diff] [blame] | 196 | |
mtklein | 8e393bf | 2014-10-01 12:48:58 -0700 | [diff] [blame] | 197 | // The bounds of clip ops need to be adjusted for the paints of saveLayers they're inside. |
| 198 | void updateClipBoundsForClipOp(const SkIRect& devBounds) { |
| 199 | Bounds clip = SkRect::Make(devBounds); |
Mike Klein | 271a030 | 2014-09-23 15:28:38 -0400 | [diff] [blame] | 200 | // We don't call adjustAndMap() because as its last step it would intersect the adjusted |
| 201 | // clip bounds with the previous clip, exactly what we can't do when the clip grows. |
| 202 | fCurrentClipBounds = this->adjustForSaveLayerPaints(&clip) ? clip : Bounds::MakeLargest(); |
| 203 | } |
| 204 | |
mtklein | 8e393bf | 2014-10-01 12:48:58 -0700 | [diff] [blame] | 205 | // Restore holds the devBounds for the clip after the {save,saveLayer}/restore block completes. |
| 206 | void updateClipBounds(const Restore& op) { |
| 207 | // This is just like the clip ops above, but we need to skip the effects (if any) of our |
| 208 | // paired saveLayer (if it is one); it has not yet been popped off the save stack. Our |
| 209 | // devBounds reflect the state of the world after the saveLayer/restore block is done, |
| 210 | // so they are not affected by the saveLayer's paint. |
| 211 | const int kSavesToIgnore = 1; |
| 212 | Bounds clip = SkRect::Make(op.devBounds); |
| 213 | fCurrentClipBounds = |
| 214 | this->adjustForSaveLayerPaints(&clip, kSavesToIgnore) ? clip : Bounds::MakeLargest(); |
| 215 | } |
| 216 | |
Mike Klein | 271a030 | 2014-09-23 15:28:38 -0400 | [diff] [blame] | 217 | // We also take advantage of SaveLayer bounds when present to further cut the clip down. |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 218 | void updateClipBounds(const SaveLayer& op) { |
| 219 | if (op.bounds) { |
Mike Klein | 271a030 | 2014-09-23 15:28:38 -0400 | [diff] [blame] | 220 | // adjustAndMap() intersects these layer bounds with the previous clip for us. |
| 221 | fCurrentClipBounds = this->adjustAndMap(*op.bounds, op.paint); |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 222 | } |
| 223 | } |
mtklein | 6cfa73a | 2014-08-13 13:33:49 -0700 | [diff] [blame] | 224 | |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 225 | // The bounds of these ops must be calculated when we hit the Restore |
| 226 | // from the bounds of the ops in the same Save block. |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 227 | void trackBounds(const Save&) { this->pushSaveBlock(NULL); } |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 228 | void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } |
| 229 | void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(); } |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 230 | |
mtklein | 68199a2 | 2014-08-25 13:49:29 -0700 | [diff] [blame] | 231 | void trackBounds(const SetMatrix&) { this->pushControl(); } |
| 232 | void trackBounds(const ClipRect&) { this->pushControl(); } |
| 233 | void trackBounds(const ClipRRect&) { this->pushControl(); } |
| 234 | void trackBounds(const ClipPath&) { this->pushControl(); } |
| 235 | void trackBounds(const ClipRegion&) { this->pushControl(); } |
| 236 | void trackBounds(const PushCull&) { this->pushControl(); } |
| 237 | void trackBounds(const PopCull&) { this->pushControl(); } |
| 238 | void trackBounds(const BeginCommentGroup&) { this->pushControl(); } |
| 239 | void trackBounds(const AddComment&) { this->pushControl(); } |
| 240 | void trackBounds(const EndCommentGroup&) { this->pushControl(); } |
mtklein | 29dfaa8 | 2014-09-04 14:12:44 -0700 | [diff] [blame] | 241 | void trackBounds(const DrawData&) { this->pushControl(); } |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 242 | |
| 243 | // For all other ops, we can calculate and store the bounds directly now. |
| 244 | template <typename T> void trackBounds(const T& op) { |
| 245 | fBounds[fCurrentOp] = this->bounds(op); |
| 246 | this->updateSaveBounds(fBounds[fCurrentOp]); |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 247 | } |
| 248 | |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 249 | void pushSaveBlock(const SkPaint* paint) { |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 250 | // Starting a new Save block. Push a new entry to represent that. |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 251 | SaveBounds sb = { 0, Bounds::MakeEmpty(), paint }; |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 252 | fSaveStack.push(sb); |
| 253 | this->pushControl(); |
| 254 | } |
| 255 | |
mtklein | d910f54 | 2014-08-22 09:06:34 -0700 | [diff] [blame] | 256 | static bool PaintMayAffectTransparentBlack(const SkPaint* paint) { |
dneto | 327f905 | 2014-09-15 10:53:16 -0700 | [diff] [blame] | 257 | if (paint) { |
| 258 | // FIXME: this is very conservative |
| 259 | if (paint->getImageFilter() || paint->getColorFilter()) { |
| 260 | return true; |
| 261 | } |
| 262 | |
| 263 | // Unusual Xfermodes require us to process a saved layer |
| 264 | // even with operations outisde the clip. |
| 265 | // For example, DstIn is used by masking layers. |
| 266 | // https://code.google.com/p/skia/issues/detail?id=1291 |
| 267 | // https://crbug.com/401593 |
| 268 | SkXfermode* xfermode = paint->getXfermode(); |
| 269 | SkXfermode::Mode mode; |
| 270 | // SrcOver is ok, and is also the common case with a NULL xfermode. |
| 271 | // So we should make that the fast path and bypass the mode extraction |
| 272 | // and test. |
| 273 | if (xfermode && xfermode->asMode(&mode)) { |
| 274 | switch (mode) { |
| 275 | // For each of the following transfer modes, if the source |
| 276 | // alpha is zero (our transparent black), the resulting |
| 277 | // blended alpha is not necessarily equal to the original |
| 278 | // destination alpha. |
| 279 | case SkXfermode::kClear_Mode: |
| 280 | case SkXfermode::kSrc_Mode: |
| 281 | case SkXfermode::kSrcIn_Mode: |
| 282 | case SkXfermode::kDstIn_Mode: |
| 283 | case SkXfermode::kSrcOut_Mode: |
| 284 | case SkXfermode::kDstATop_Mode: |
| 285 | case SkXfermode::kModulate_Mode: |
| 286 | return true; |
| 287 | break; |
| 288 | default: |
| 289 | break; |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | return false; |
mtklein | d910f54 | 2014-08-22 09:06:34 -0700 | [diff] [blame] | 294 | } |
| 295 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 296 | Bounds popSaveBlock() { |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 297 | // We're done the Save block. Apply the block's bounds to all control ops inside it. |
| 298 | SaveBounds sb; |
| 299 | fSaveStack.pop(&sb); |
mtklein | d910f54 | 2014-08-22 09:06:34 -0700 | [diff] [blame] | 300 | |
| 301 | // If the paint affects transparent black, we can't trust any of our calculated bounds. |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 302 | const Bounds& bounds = |
mtklein | d910f54 | 2014-08-22 09:06:34 -0700 | [diff] [blame] | 303 | PaintMayAffectTransparentBlack(sb.paint) ? fCurrentClipBounds : sb.bounds; |
| 304 | |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 305 | while (sb.controlOps --> 0) { |
mtklein | d910f54 | 2014-08-22 09:06:34 -0700 | [diff] [blame] | 306 | this->popControl(bounds); |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | // This whole Save block may be part another Save block. |
mtklein | d910f54 | 2014-08-22 09:06:34 -0700 | [diff] [blame] | 310 | this->updateSaveBounds(bounds); |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 311 | |
| 312 | // If called from a real Restore (not a phony one for balance), it'll need the bounds. |
mtklein | d910f54 | 2014-08-22 09:06:34 -0700 | [diff] [blame] | 313 | return bounds; |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | void pushControl() { |
| 317 | fControlIndices.push(fCurrentOp); |
| 318 | if (!fSaveStack.isEmpty()) { |
| 319 | fSaveStack.top().controlOps++; |
| 320 | } |
| 321 | } |
| 322 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 323 | void popControl(const Bounds& bounds) { |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 324 | fBounds[fControlIndices.top()] = bounds; |
| 325 | fControlIndices.pop(); |
| 326 | } |
| 327 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 328 | void updateSaveBounds(const Bounds& bounds) { |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 329 | // If we're in a Save block, expand its bounds to cover these bounds too. |
| 330 | if (!fSaveStack.isEmpty()) { |
| 331 | fSaveStack.top().bounds.join(bounds); |
| 332 | } |
| 333 | } |
| 334 | |
mtklein | 131a22b | 2014-08-25 14:16:15 -0700 | [diff] [blame] | 335 | // FIXME: this method could use better bounds |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 336 | Bounds bounds(const DrawText&) const { return fCurrentClipBounds; } |
mtklein | 68199a2 | 2014-08-25 13:49:29 -0700 | [diff] [blame] | 337 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 338 | Bounds bounds(const Clear&) const { return Bounds::MakeLargest(); } // Ignores the clip. |
| 339 | Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; } |
| 340 | Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOps don't draw. |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 341 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 342 | Bounds bounds(const DrawSprite& op) const { |
mtklein | 131a22b | 2014-08-25 14:16:15 -0700 | [diff] [blame] | 343 | const SkBitmap& bm = op.bitmap; |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 344 | return Bounds::MakeXYWH(op.left, op.top, bm.width(), bm.height()); // Ignores the matrix. |
mtklein | 131a22b | 2014-08-25 14:16:15 -0700 | [diff] [blame] | 345 | } |
| 346 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 347 | Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); } |
| 348 | Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); } |
| 349 | Bounds bounds(const DrawRRect& op) const { |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 350 | return this->adjustAndMap(op.rrect.rect(), &op.paint); |
| 351 | } |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 352 | Bounds bounds(const DrawDRRect& op) const { |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 353 | return this->adjustAndMap(op.outer.rect(), &op.paint); |
| 354 | } |
| 355 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 356 | Bounds bounds(const DrawBitmapRectToRect& op) const { |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 357 | return this->adjustAndMap(op.dst, op.paint); |
| 358 | } |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 359 | Bounds bounds(const DrawBitmapNine& op) const { |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 360 | return this->adjustAndMap(op.dst, op.paint); |
| 361 | } |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 362 | Bounds bounds(const DrawBitmap& op) const { |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 363 | const SkBitmap& bm = op.bitmap; |
| 364 | return this->adjustAndMap(SkRect::MakeXYWH(op.left, op.top, bm.width(), bm.height()), |
| 365 | op.paint); |
| 366 | } |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 367 | Bounds bounds(const DrawBitmapMatrix& op) const { |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 368 | const SkBitmap& bm = op.bitmap; |
| 369 | SkRect dst = SkRect::MakeWH(bm.width(), bm.height()); |
| 370 | op.matrix.mapRect(&dst); |
| 371 | return this->adjustAndMap(dst, op.paint); |
| 372 | } |
| 373 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 374 | Bounds bounds(const DrawPath& op) const { |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 375 | return op.path.isInverseFillType() ? fCurrentClipBounds |
| 376 | : this->adjustAndMap(op.path.getBounds(), &op.paint); |
| 377 | } |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 378 | Bounds bounds(const DrawPoints& op) const { |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 379 | SkRect dst; |
| 380 | dst.set(op.pts, op.count); |
| 381 | |
| 382 | // Pad the bounding box a little to make sure hairline points' bounds aren't empty. |
| 383 | SkScalar stroke = SkMaxScalar(op.paint.getStrokeWidth(), 0.01f); |
| 384 | dst.outset(stroke/2, stroke/2); |
| 385 | |
| 386 | return this->adjustAndMap(dst, &op.paint); |
| 387 | } |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 388 | Bounds bounds(const DrawPatch& op) const { |
mtklein | 131a22b | 2014-08-25 14:16:15 -0700 | [diff] [blame] | 389 | SkRect dst; |
| 390 | dst.set(op.cubics, SkPatchUtils::kNumCtrlPts); |
| 391 | return this->adjustAndMap(dst, &op.paint); |
| 392 | } |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 393 | Bounds bounds(const DrawVertices& op) const { |
mtklein | 131a22b | 2014-08-25 14:16:15 -0700 | [diff] [blame] | 394 | SkRect dst; |
| 395 | dst.set(op.vertices, op.vertexCount); |
| 396 | return this->adjustAndMap(dst, &op.paint); |
| 397 | } |
| 398 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 399 | Bounds bounds(const DrawPicture& op) const { |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 400 | SkRect dst = op.picture->cullRect(); |
mtklein | 131a22b | 2014-08-25 14:16:15 -0700 | [diff] [blame] | 401 | if (op.matrix) { |
| 402 | op.matrix->mapRect(&dst); |
| 403 | } |
| 404 | return this->adjustAndMap(dst, op.paint); |
| 405 | } |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 406 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 407 | Bounds bounds(const DrawPosText& op) const { |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 408 | const int N = op.paint.countText(op.text, op.byteLength); |
| 409 | if (N == 0) { |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 410 | return Bounds::MakeEmpty(); |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | SkRect dst; |
mtklein | 937c9c7 | 2014-09-02 15:19:48 -0700 | [diff] [blame] | 414 | dst.set(op.pos, N); |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 415 | AdjustTextForFontMetrics(&dst, op.paint); |
| 416 | return this->adjustAndMap(dst, &op.paint); |
| 417 | } |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 418 | Bounds bounds(const DrawPosTextH& op) const { |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 419 | const int N = op.paint.countText(op.text, op.byteLength); |
| 420 | if (N == 0) { |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 421 | return Bounds::MakeEmpty(); |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | SkScalar left = op.xpos[0], right = op.xpos[0]; |
| 425 | for (int i = 1; i < N; i++) { |
| 426 | left = SkMinScalar(left, op.xpos[i]); |
| 427 | right = SkMaxScalar(right, op.xpos[i]); |
| 428 | } |
| 429 | SkRect dst = { left, op.y, right, op.y }; |
| 430 | AdjustTextForFontMetrics(&dst, op.paint); |
| 431 | return this->adjustAndMap(dst, &op.paint); |
| 432 | } |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 433 | Bounds bounds(const DrawTextOnPath& op) const { |
mtklein | 131a22b | 2014-08-25 14:16:15 -0700 | [diff] [blame] | 434 | SkRect dst = op.path.getBounds(); |
| 435 | |
| 436 | // Pad all sides by the maximum padding in any direction we'd normally apply. |
| 437 | SkRect pad = { 0, 0, 0, 0}; |
| 438 | AdjustTextForFontMetrics(&pad, op.paint); |
| 439 | |
| 440 | // That maximum padding happens to always be the right pad today. |
| 441 | SkASSERT(pad.fLeft == -pad.fRight); |
| 442 | SkASSERT(pad.fTop == -pad.fBottom); |
| 443 | SkASSERT(pad.fRight > pad.fBottom); |
| 444 | dst.outset(pad.fRight, pad.fRight); |
| 445 | |
| 446 | return this->adjustAndMap(dst, &op.paint); |
| 447 | } |
| 448 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 449 | Bounds bounds(const DrawTextBlob& op) const { |
mtklein | 131a22b | 2014-08-25 14:16:15 -0700 | [diff] [blame] | 450 | SkRect dst = op.blob->bounds(); |
| 451 | dst.offset(op.x, op.y); |
| 452 | // TODO: remove when implicit bounds are plumbed through |
| 453 | if (dst.isEmpty()) { |
| 454 | return fCurrentClipBounds; |
| 455 | } |
| 456 | return this->adjustAndMap(dst, &op.paint); |
| 457 | } |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 458 | |
| 459 | static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) { |
caryclark | 9a657fa | 2014-08-20 05:24:29 -0700 | [diff] [blame] | 460 | #ifdef SK_DEBUG |
mtklein | a19afb4 | 2014-08-19 17:47:14 -0700 | [diff] [blame] | 461 | SkRect correct = *rect; |
| 462 | #endif |
mtklein | c846049 | 2014-08-21 16:39:12 -0700 | [diff] [blame] | 463 | const SkScalar yPad = 2.0f * paint.getTextSize(), // In practice, this seems to be enough. |
mtklein | a19afb4 | 2014-08-19 17:47:14 -0700 | [diff] [blame] | 464 | xPad = 4.0f * yPad; // Hack for very wide Github logo font. |
| 465 | rect->outset(xPad, yPad); |
caryclark | 9a657fa | 2014-08-20 05:24:29 -0700 | [diff] [blame] | 466 | #ifdef SK_DEBUG |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 467 | SkPaint::FontMetrics metrics; |
| 468 | paint.getFontMetrics(&metrics); |
mtklein | a19afb4 | 2014-08-19 17:47:14 -0700 | [diff] [blame] | 469 | correct.fLeft += metrics.fXMin; |
| 470 | correct.fTop += metrics.fTop; |
| 471 | correct.fRight += metrics.fXMax; |
| 472 | correct.fBottom += metrics.fBottom; |
mtklein | d13291a | 2014-08-21 14:46:49 -0700 | [diff] [blame] | 473 | // See skia:2862 for why we ignore small text sizes. |
| 474 | SkASSERTF(paint.getTextSize() < 0.001f || rect->contains(correct), |
| 475 | "%f %f %f %f vs. %f %f %f %f\n", |
mtklein | a19afb4 | 2014-08-19 17:47:14 -0700 | [diff] [blame] | 476 | -xPad, -yPad, +xPad, +yPad, |
| 477 | metrics.fXMin, metrics.fTop, metrics.fXMax, metrics.fBottom); |
| 478 | #endif |
mtklein | 62b67ae | 2014-08-18 11:10:37 -0700 | [diff] [blame] | 479 | } |
| 480 | |
mtklein | 479601b | 2014-08-18 08:45:33 -0700 | [diff] [blame] | 481 | // Returns true if rect was meaningfully adjusted for the effects of paint, |
| 482 | // false if the paint could affect the rect in unknown ways. |
| 483 | static bool AdjustForPaint(const SkPaint* paint, SkRect* rect) { |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 484 | if (paint) { |
| 485 | if (paint->canComputeFastBounds()) { |
mtklein | 479601b | 2014-08-18 08:45:33 -0700 | [diff] [blame] | 486 | *rect = paint->computeFastBounds(*rect, rect); |
| 487 | return true; |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 488 | } |
mtklein | 479601b | 2014-08-18 08:45:33 -0700 | [diff] [blame] | 489 | return false; |
| 490 | } |
| 491 | return true; |
| 492 | } |
| 493 | |
mtklein | 8e393bf | 2014-10-01 12:48:58 -0700 | [diff] [blame] | 494 | bool adjustForSaveLayerPaints(SkRect* rect, int savesToIgnore = 0) const { |
| 495 | for (int i = fSaveStack.count() - 1 - savesToIgnore; i >= 0; i--) { |
Mike Klein | 271a030 | 2014-09-23 15:28:38 -0400 | [diff] [blame] | 496 | if (!AdjustForPaint(fSaveStack[i].paint, rect)) { |
| 497 | return false; |
| 498 | } |
| 499 | } |
| 500 | return true; |
| 501 | } |
| 502 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 503 | // Adjust rect for all paints that may affect its geometry, then map it to identity space. |
| 504 | Bounds adjustAndMap(SkRect rect, const SkPaint* paint) const { |
mtklein | 479601b | 2014-08-18 08:45:33 -0700 | [diff] [blame] | 505 | // Inverted rectangles really confuse our BBHs. |
| 506 | rect.sort(); |
| 507 | |
| 508 | // Adjust the rect for its own paint. |
| 509 | if (!AdjustForPaint(paint, &rect)) { |
| 510 | // The paint could do anything to our bounds. The only safe answer is the current clip. |
| 511 | return fCurrentClipBounds; |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | // Adjust rect for all the paints from the SaveLayers we're inside. |
Mike Klein | 271a030 | 2014-09-23 15:28:38 -0400 | [diff] [blame] | 515 | if (!this->adjustForSaveLayerPaints(&rect)) { |
| 516 | // Same deal as above. |
| 517 | return fCurrentClipBounds; |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 518 | } |
| 519 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 520 | // Map the rect back to identity space. |
mtklein | 6332f1d | 2014-08-19 07:09:40 -0700 | [diff] [blame] | 521 | fCTM->mapRect(&rect); |
mtklein | 479601b | 2014-08-18 08:45:33 -0700 | [diff] [blame] | 522 | |
| 523 | // Nothing can draw outside the current clip. |
| 524 | // (Only bounded ops call into this method, so oddballs like Clear don't matter here.) |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 525 | rect.intersect(fCurrentClipBounds); |
| 526 | return rect; |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 527 | } |
| 528 | |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 529 | // Conservative identity-space bounds for each op in the SkRecord. |
| 530 | SkAutoTMalloc<Bounds> fBounds; |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 531 | |
| 532 | // We walk fCurrentOp through the SkRecord, as we go using updateCTM() |
| 533 | // and updateClipBounds() to maintain the exact CTM (fCTM) and conservative |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 534 | // identity-space bounds of the current clip (fCurrentClipBounds). |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 535 | unsigned fCurrentOp; |
mtklein | 6332f1d | 2014-08-19 07:09:40 -0700 | [diff] [blame] | 536 | const SkMatrix* fCTM; |
mtklein | 533eb78 | 2014-08-27 10:39:42 -0700 | [diff] [blame] | 537 | Bounds fCurrentClipBounds; |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 538 | |
| 539 | // Used to track the bounds of Save/Restore blocks and the control ops inside them. |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 540 | SkTDArray<SaveBounds> fSaveStack; |
| 541 | SkTDArray<unsigned> fControlIndices; |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 542 | }; |
| 543 | |
commit-bot@chromium.org | 27f6b0d | 2014-05-09 14:59:29 +0000 | [diff] [blame] | 544 | } // namespace SkRecords |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 545 | |
| 546 | void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
mtklein | 828ce1f | 2014-08-13 12:58:45 -0700 | [diff] [blame] | 547 | SkRecords::FillBounds(record, bbh); |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 548 | } |