summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-02 20:27:50 +0000
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-02 20:27:50 +0000
commit4ec6fb7d7dbe56ed097cb92d7dcab4ce764f5431 (patch)
treedeecfa6aeef7e5bd1ad08025061246e37a2cc4a8
parent405b06dd3ddcffa15a81ff05a80eeb7fde149333 (diff)
downloadsrc-4ec6fb7d7dbe56ed097cb92d7dcab4ce764f5431.tar.gz
Add literal picture recording mode, triggered by a compile time switch.
This is helpful to record SKPs from Chrome as a fair bootstrapping source for SkRecord. Without this sort of switch, a good bit of SkPicture's cleverness is baked into the SKP, and thus SkRecord looks unfairly good. Tested by defining SK_RECORD_LITERAL_PICTURES and running dm --match ~optimizations. By design that GM will never pass in literal mode. BUG=skia:2378 R=robertphillips@google.com, reed@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/246393008 git-svn-id: http://skia.googlecode.com/svn/trunk/src@14547 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--core/SkPictureRecord.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/core/SkPictureRecord.cpp b/core/SkPictureRecord.cpp
index f3d108c4..f6da2f27 100644
--- a/core/SkPictureRecord.cpp
+++ b/core/SkPictureRecord.cpp
@@ -15,6 +15,15 @@
#define HEAP_BLOCK_SIZE 4096
+// If SK_RECORD_LITERAL_PICTURES is defined, record our inputs as literally as possible.
+// Otherwise, we can be clever and record faster equivalents. kBeClever is normally true.
+static const bool kBeClever =
+#ifdef SK_RECORD_LITERAL_PICTURES
+ false;
+#else
+ true;
+#endif
+
enum {
// just need a value that save or getSaveCount would never return
kNoInitialSave = -1,
@@ -34,7 +43,7 @@ SkPictureRecord::SkPictureRecord(SkPicture* picture, const SkISize& dimensions,
, fFlattenableHeap(HEAP_BLOCK_SIZE)
, fPaints(&fFlattenableHeap)
, fRecordFlags(flags)
- , fOptsEnabled(true) {
+ , fOptsEnabled(kBeClever) {
#ifdef SK_DEBUG_SIZE
fPointBytes = fRectBytes = fTextBytes = 0;
fPointWrites = fRectWrites = fTextWrites = 0;
@@ -1031,9 +1040,9 @@ void SkPictureRecord::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
#endif
- if (rrect.isRect()) {
+ if (rrect.isRect() && kBeClever) {
this->SkPictureRecord::drawRect(rrect.getBounds(), paint);
- } else if (rrect.isOval()) {
+ } else if (rrect.isOval() && kBeClever) {
this->SkPictureRecord::drawOval(rrect.getBounds(), paint);
} else {
// op + paint index + rrect
@@ -1089,7 +1098,7 @@ void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) {
void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
const SkPaint* paint = NULL) {
- if (bitmap.drawsNothing()) {
+ if (bitmap.drawsNothing() && kBeClever) {
return;
}
@@ -1111,7 +1120,7 @@ void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar
void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint,
DrawBitmapRectFlags flags) {
- if (bitmap.drawsNothing()) {
+ if (bitmap.drawsNothing() && kBeClever) {
return;
}
@@ -1138,7 +1147,7 @@ void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect*
void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
const SkPaint* paint) {
- if (bitmap.drawsNothing()) {
+ if (bitmap.drawsNothing() && kBeClever) {
return;
}
@@ -1158,7 +1167,7 @@ void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m
void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint) {
- if (bitmap.drawsNothing()) {
+ if (bitmap.drawsNothing() && kBeClever) {
return;
}
@@ -1179,7 +1188,7 @@ void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent
void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top,
const SkPaint* paint = NULL) {
- if (bitmap.drawsNothing()) {
+ if (bitmap.drawsNothing() && kBeClever) {
return;
}
@@ -1224,7 +1233,7 @@ void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
#endif
- bool fast = !paint.isVerticalText() && paint.canComputeFastBounds();
+ bool fast = !paint.isVerticalText() && paint.canComputeFastBounds() && kBeClever;
// op + paint index + length + 'length' worth of chars + x + y
size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar);
@@ -1275,8 +1284,8 @@ void SkPictureRecord::onDrawPosText(const void* text, size_t byteLength, const S
}
}
- bool fastBounds = !paint.isVerticalText() && paint.canComputeFastBounds();
- bool fast = canUseDrawH && fastBounds;
+ bool fastBounds = !paint.isVerticalText() && paint.canComputeFastBounds() && kBeClever;
+ bool fast = canUseDrawH && fastBounds && kBeClever;
// op + paint index + length + 'length' worth of data + num points
size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 1 * kUInt32Size;
@@ -1349,10 +1358,11 @@ void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY,
const SkPaint& paint, const SkFlatData* flatPaintData) {
int points = paint.countText(text, byteLength);
- if (0 == points)
+ if (0 == points && kBeClever) {
return;
+ }
- bool fast = !paint.isVerticalText() && paint.canComputeFastBounds();
+ bool fast = !paint.isVerticalText() && paint.canComputeFastBounds() && kBeClever;
// op + paint index + length + 'length' worth of data + num points
size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 1 * kUInt32Size;
@@ -1545,7 +1555,7 @@ void SkPictureRecord::onPopCull() {
fCullOffsetStack.pop();
// Collapse empty push/pop pairs.
- if ((size_t)(cullSkipOffset + kUInt32Size) == fWriter.bytesWritten()) {
+ if ((size_t)(cullSkipOffset + kUInt32Size) == fWriter.bytesWritten() && kBeClever) {
SkASSERT(fWriter.bytesWritten() >= kPushCullOpSize);
SkASSERT(PUSH_CULL == peek_op(&fWriter, fWriter.bytesWritten() - kPushCullOpSize));
fWriter.rewindToOffset(fWriter.bytesWritten() - kPushCullOpSize);