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

Unified Diff: tests/RecorderTest.cpp

Issue 610003002: Override SkCanvas::drawImage() in SkRecorder. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add tests Created 6 years, 3 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
« tests/RecordReplaceDrawTest.cpp ('K') | « tests/RecordReplaceDrawTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecorderTest.cpp
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
index aced54f7a906fa32c56ffc5ee25ad8b10fd8fd1f..9339bcd2d6cb80d8fc4ce16bf70154dec8ed34e6 100644
--- a/tests/RecorderTest.cpp
+++ b/tests/RecorderTest.cpp
@@ -12,6 +12,7 @@
#include "SkRecorder.h"
#include "SkRecords.h"
#include "SkShader.h"
+#include "SkSurface.h"
#define COUNT(T) + 1
static const int kRecordTypes = SK_RECORD_TYPES(COUNT);
@@ -150,3 +151,29 @@ DEF_TEST(Recorder_IsDrawingToLayer, r) {
REPORTER_ASSERT(r, !recorder.isDrawingToLayer());
}
+DEF_TEST(Recorder_drawImage_takeReference, reporter) {
+
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100));
+ surface->getCanvas()->clear(SK_ColorGREEN);
+ SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
+ int beginImageRefCount = image->getRefCnt();
mtklein 2014/09/27 15:41:22 We generally try to avoid calling getRefCnt(). He
Rémi Piotaix 2014/09/29 17:57:55 Done.
+ {
+ SkRecord record;
+ SkRecorder recorder(&record, 100, 100);
+
+ // DrawImage is supposed to take a reference
+ recorder.drawImage(image.get(), 0, 0);
+ REPORTER_ASSERT(reporter, image->getRefCnt() == beginImageRefCount + 1);
+
+ recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100));
+ REPORTER_ASSERT(reporter, image->getRefCnt() == beginImageRefCount + 2);
+
+ Tally tally;
+ tally.apply(record);
+
+ REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImage>());
+ REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>());
+ }
+ // The SkImage should have the same refCnt as before
+ REPORTER_ASSERT(reporter, image->getRefCnt() == beginImageRefCount);
+}
« tests/RecordReplaceDrawTest.cpp ('K') | « tests/RecordReplaceDrawTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698