Chromium Code Reviews| Index: src/core/SkRecordDraw.cpp |
| diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp |
| index 2f8aa57fcc34b82900e2c7d0f48a3e08f1bb76f8..a1855d20ecc3c41bf1aa88d5f748811f8d1a6ef4 100644 |
| --- a/src/core/SkRecordDraw.cpp |
| +++ b/src/core/SkRecordDraw.cpp |
| @@ -6,7 +6,7 @@ |
| */ |
| #include "SkRecordDraw.h" |
| -#include "SkTSort.h" |
| +#include "SkPatchUtils.h" |
| void SkRecordDraw(const SkRecord& record, |
| SkCanvas* canvas, |
| @@ -256,20 +256,18 @@ private: |
| } |
| } |
| - // FIXME: these methods could use better bounds |
| - SkIRect bounds(const DrawPatch&) const { return fCurrentClipBounds; } |
| - SkIRect bounds(const DrawPicture&) const { return fCurrentClipBounds; } |
| - SkIRect bounds(const DrawTextOnPath&) const { return fCurrentClipBounds; } |
| - SkIRect bounds(const DrawSprite&) const { return fCurrentClipBounds; } |
| - SkIRect bounds(const DrawTextBlob&) const { return fCurrentClipBounds; } |
| - SkIRect bounds(const DrawText&) const { return fCurrentClipBounds; } |
| - SkIRect bounds(const DrawVertices&) const { return fCurrentClipBounds; } |
| - // end of methods that could use better bounds |
| - |
| - SkIRect bounds(const Clear&) const { return SkIRect::MakeLargest(); } // Ignores the clip |
| + // FIXME: this method could use better bounds |
| + SkIRect bounds(const DrawText&) const { return fCurrentClipBounds; } |
| + |
| + SkIRect bounds(const Clear&) const { return SkIRect::MakeLargest(); } // Ignores the clip. |
| SkIRect bounds(const DrawPaint&) const { return fCurrentClipBounds; } |
| SkIRect bounds(const NoOp&) const { return SkIRect::MakeEmpty(); } // NoOps don't draw. |
| + SkIRect bounds(const DrawSprite& op) const { |
| + const SkBitmap& bm = op.bitmap; |
| + return SkIRect::MakeXYWH(op.left, op.top, bm.width(), bm.height()); // Ignores the matrix. |
| + } |
| + |
| SkIRect bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); } |
| SkIRect bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); } |
| SkIRect bounds(const DrawRRect& op) const { |
| @@ -311,6 +309,24 @@ private: |
| return this->adjustAndMap(dst, &op.paint); |
| } |
| + SkIRect bounds(const DrawPatch& op) const { |
| + SkRect dst; |
| + dst.set(op.cubics, SkPatchUtils::kNumCtrlPts); |
| + return this->adjustAndMap(dst, &op.paint); |
| + } |
| + SkIRect bounds(const DrawVertices& op) const { |
| + SkRect dst; |
| + dst.set(op.vertices, op.vertexCount); |
| + return this->adjustAndMap(dst, &op.paint); |
| + } |
| + |
| + SkIRect bounds(const DrawPicture& op) const { |
| + SkRect dst = SkRect::MakeWH(op.picture->width(), op.picture->height()); |
| + if (op.matrix) { |
| + op.matrix->mapRect(&dst); |
| + } |
| + return this->adjustAndMap(dst, op.paint); |
| + } |
| SkIRect bounds(const DrawPosText& op) const { |
| const int N = op.paint.countText(op.text, op.byteLength); |
| @@ -338,6 +354,21 @@ private: |
| AdjustTextForFontMetrics(&dst, op.paint); |
| return this->adjustAndMap(dst, &op.paint); |
| } |
| + SkIRect bounds(const DrawTextOnPath& op) const { |
| + SkRect dst = op.path.getBounds(); |
|
robertphillips
2014/08/25 21:00:40
B.c. we don't know the shape of the path don't we
mtklein
2014/08/25 21:09:22
Done. Now using the max pad in all directions.
|
| + AdjustTextForFontMetrics(&dst, op.paint); |
| + return this->adjustAndMap(dst, &op.paint); |
| + } |
| + |
| + SkIRect bounds(const DrawTextBlob& op) const { |
| + SkRect dst = op.blob->bounds(); |
| + dst.offset(op.x, op.y); |
| + // TODO: remove when implicit bounds are plumbed through |
| + if (dst.isEmpty()) { |
| + return fCurrentClipBounds; |
| + } |
| + return this->adjustAndMap(dst, &op.paint); |
| + } |
| static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) { |
| #ifdef SK_DEBUG |