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

Unified Diff: tests/RecordDrawTest.cpp

Issue 610003002: Override SkCanvas::drawImage() in SkRecorder. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase master Created 6 years, 2 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 | « src/image/SkImage_Raster.cpp ('k') | tests/RecordReplaceDrawTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordDrawTest.cpp
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index f1c3a8b644328493e532c85d46eea192f58d7f38..51313de9a9f5438de426f647f717bb0b76e99bf7 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -11,11 +11,13 @@
#include "SkDebugCanvas.h"
#include "SkDrawPictureCallback.h"
#include "SkDropShadowImageFilter.h"
+#include "SkImagePriv.h"
#include "SkRecord.h"
#include "SkRecordDraw.h"
#include "SkRecordOpts.h"
#include "SkRecorder.h"
#include "SkRecords.h"
+#include "SkSurface.h"
static const int W = 1920, H = 1080;
@@ -252,3 +254,57 @@ DEF_TEST(RecordDraw_SaveLayerAffectsClipBounds, r) {
REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[2].bounds, SkRect::MakeLTRB(0, 0, 40, 40)));
REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[3].bounds, SkRect::MakeLTRB(0, 0, 50, 50)));
}
+
+DEF_TEST(RecordDraw_drawImage, r){
+ class SkCanvasMock : public SkCanvas {
+ public:
+ SkCanvasMock(int width, int height) : INHERITED(width, height) {
+ this->resetTestValues();
+ }
+ virtual ~SkCanvasMock() {}
+ virtual void drawImage(const SkImage* image, SkScalar left, SkScalar top,
+ const SkPaint* paint = NULL) SK_OVERRIDE {
+
+ fDrawImageCalled = true;
+ }
+
+ virtual void drawImageRect(const SkImage* image, const SkRect* src,
+ const SkRect& dst,
+ const SkPaint* paint = NULL) SK_OVERRIDE {
+ fDrawImageRectCalled = true;
+ }
+
+ void resetTestValues() {
+ fDrawImageCalled = fDrawImageRectCalled = false;
+ }
+
+ bool fDrawImageCalled;
+ bool fDrawImageRectCalled;
+ private:
+ typedef SkCanvas INHERITED;
tfarina 2014/10/24 00:52:15 Filed https://code.google.com/p/skia/issues/detail
+ };
+
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(10, 10));
+ surface->getCanvas()->clear(SK_ColorGREEN);
+ SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
+
+ SkCanvasMock canvas(10, 10);
+
+ {
+ SkRecord record;
+ SkRecorder recorder(&record, 10, 10);
+ recorder.drawImage(image, 0, 0);
+ SkRecordDraw(record, &canvas, 0, 0);
+ }
+ REPORTER_ASSERT(r, canvas.fDrawImageCalled);
+ canvas.resetTestValues();
+
+ {
+ SkRecord record;
+ SkRecorder recorder(&record, 10, 10);
+ recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10));
+ SkRecordDraw(record, &canvas, 0, 0);
+ }
+ REPORTER_ASSERT(r, canvas.fDrawImageRectCalled);
+
+}
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | tests/RecordReplaceDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698