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

Unified Diff: tests/CanvasTest.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
Index: tests/CanvasTest.cpp
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 216a408155a035acd3a1446cb031a411753c9639..02d583656c479de247c2b6fd1b4791ce3002978f 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -267,7 +267,8 @@ SkPoint kTestPoints2[] = {
{ SkIntToScalar(9), SkIntToScalar(1) },
{ SkIntToScalar(10), SkIntToScalar(1) },
};
-
+SkSurface* kTestSurface;
+SkImage* kTestImage;
///////////////////////////////////////////////////////////////////////////////
// Macros for defining test steps
@@ -282,7 +283,7 @@ public: \
}; \
static NAME##_TestStep NAME##_TestStepInstance;
-#define TEST_STEP_NO_PDF(NAME, FUNCTION) \
+#define TEST_STEP_NO_PDF(NAME, FUNCTION) \
class NAME##_TestStep : public CanvasTestStep{ \
public: \
NAME##_TestStep() : CanvasTestStep(false) {} \
@@ -363,6 +364,8 @@ SIMPLE_TEST_STEP(DrawData, drawData(kTestText.c_str(), kTestText.size()));
SIMPLE_TEST_STEP(BeginGroup, beginCommentGroup(kTestText.c_str()));
SIMPLE_TEST_STEP(AddComment, addComment(kTestText.c_str(), kTestText.c_str()));
SIMPLE_TEST_STEP(EndGroup, endCommentGroup());
+SIMPLE_TEST_STEP(DrawImage, drawImage(kTestImage, 0, 0));
+SIMPLE_TEST_STEP(DrawImageRect, drawImageRect(kTestImage, 0, SkRect::MakeWH(kWidth, kHeight)));
///////////////////////////////////////////////////////////////////////////////
// Complex test steps
@@ -463,7 +466,7 @@ static void DrawPictureTestStep(SkCanvas* canvas,
skiatest::Reporter*,
CanvasTestStep*) {
SkPictureRecorder recorder;
- SkCanvas* testCanvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScalar(kHeight),
+ SkCanvas* testCanvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScalar(kHeight),
NULL, 0);
testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1));
testCanvas->clipRect(kTestRect);
@@ -689,15 +692,15 @@ public:
testStep->setAssertMessageFormat(kPictureDrawAssertMessageFormat);
SkPictureRecorder referenceRecorder;
SkCanvas* referenceCanvas =
- referenceRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth),
- SkIntToScalar(kHeight),
+ referenceRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth),
+ SkIntToScalar(kHeight),
NULL, recordFlags);
testStep->draw(referenceCanvas, reporter);
SkPictureRecorder testRecorder;
SkCanvas* testCanvas =
- testRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth),
- SkIntToScalar(kHeight),
+ testRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth),
+ SkIntToScalar(kHeight),
NULL, recordFlags);
testStep->draw(testCanvas, reporter);
testStep->setAssertMessageFormat(kPictureSecondDrawAssertMessageFormat);
@@ -905,6 +908,8 @@ DEF_TEST(Canvas, reporter) {
// Init global here because bitmap pixels cannot be alocated during
// static initialization
kTestBitmap = testBitmap();
+ kTestSurface = createSurface(SK_ColorGREEN);
+ kTestImage = kTestSurface->newImageSnapshot();
for (int testStep = 0; testStep < testStepArray().count(); testStep++) {
TestOverrideStateConsistency(reporter, testStepArray()[testStep]);
@@ -917,6 +922,8 @@ DEF_TEST(Canvas, reporter) {
// Explicitly call reset(), so we don't leak the pixels (since kTestBitmap is a global)
kTestBitmap.reset();
+ kTestSurface->unref();
+ kTestImage->unref();
test_newraster(reporter);
}

Powered by Google App Engine
This is Rietveld 408576698