Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: src/core/SkRecordDraw.cpp

Issue 470063008: Bound everything except drawText(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: right Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRecordDraw.cpp
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index 2f8aa57fcc34b82900e2c7d0f48a3e08f1bb76f8..a52baed0a2ab044a2a0cb0f75152653341fbb3cb 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,31 @@ private:
AdjustTextForFontMetrics(&dst, op.paint);
return this->adjustAndMap(dst, &op.paint);
}
+ SkIRect bounds(const DrawTextOnPath& op) const {
+ SkRect dst = op.path.getBounds();
+
+ // Pad all sides by the maximum padding in any direction we'd normally apply.
+ SkRect pad = { 0, 0, 0, 0};
+ AdjustTextForFontMetrics(&pad, op.paint);
+
+ // That maximum padding happens to always be the right pad today.
+ SkASSERT(pad.fLeft == -pad.fRight);
+ SkASSERT(pad.fTop == -pad.fBottom);
+ SkASSERT(pad.fRight > pad.fBottom);
+ dst.outset(pad.fRight, pad.fRight);
+
+ 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698