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

Unified Diff: tests/RecordTest.cpp

Issue 481173003: Revert "Move the code over using the same template type approach previously used for willPlayBackBi… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « tests/PictureTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « tests/PictureTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698