Index: tests/RecordTest.cpp |
diff --git a/tests/RecordTest.cpp b/tests/RecordTest.cpp |
index 2240ae985825ee270525ba51a0299d56f52fdd0f..2fcc1e9c53cc6a6020fa4aab979e6bb6ec91a015 100644 |
--- a/tests/RecordTest.cpp |
+++ b/tests/RecordTest.cpp |
@@ -11,6 +11,7 @@ |
#include "SkImageInfo.h" |
#include "SkShader.h" |
#include "SkRecord.h" |
+#include "SkRecordAnalysis.h" |
#include "SkRecords.h" |
// Sums the area of any DrawRect command it sees. |
@@ -76,5 +77,37 @@ DEF_TEST(Record, r) { |
REPORTER_ASSERT(r, summer.area() == 500); |
} |
+DEF_TEST(RecordAnalysis, r) { |
+ SkRecord record; |
+ |
+ SkRect rect = SkRect::MakeWH(10, 10); |
+ SkPaint paint; |
+ APPEND(record, SkRecords::DrawRect, paint, rect); |
+ REPORTER_ASSERT(r, !SkRecordWillPlaybackBitmaps(record)); |
+ |
+ SkBitmap bitmap; |
+ APPEND(record, SkRecords::DrawBitmap, &paint, bitmap, 0.0f, 0.0f); |
+ REPORTER_ASSERT(r, SkRecordWillPlaybackBitmaps(record)); |
+ |
+ SkNEW_PLACEMENT_ARGS(record.replace<SkRecords::DrawRect>(1), |
+ SkRecords::DrawRect, (paint, rect)); |
+ REPORTER_ASSERT(r, !SkRecordWillPlaybackBitmaps(record)); |
+ |
+ SkPaint paint2; |
+ // CreateBitmapShader is too smart for us; an empty (or 1x1) bitmap shader |
+ // gets optimized into a non-bitmap form, so we create a 2x2 bitmap here. |
+ SkBitmap bitmap2; |
+ bitmap2.allocPixels(SkImageInfo::MakeN32Premul(2, 2)); |
+ bitmap2.eraseColor(SK_ColorBLUE); |
+ *(bitmap2.getAddr32(0, 0)) = SK_ColorGREEN; |
+ SkShader* shader = SkShader::CreateBitmapShader(bitmap2, SkShader::kClamp_TileMode, |
+ SkShader::kClamp_TileMode); |
+ paint2.setShader(shader)->unref(); |
+ REPORTER_ASSERT(r, shader->asABitmap(NULL, NULL, NULL) == SkShader::kDefault_BitmapType); |
+ |
+ APPEND(record, SkRecords::DrawRect, paint2, rect); |
+ REPORTER_ASSERT(r, SkRecordWillPlaybackBitmaps(record)); |
+} |
+ |
#undef APPEND |