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

Side by Side Diff: tests/CanvasTest.cpp

Issue 614773004: Add tests for SkCanvas::drawImage[Rect]() Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Change dest rect in DrawImageRect test step 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 /* Description: 8 /* Description:
9 * This test defines a series of elementatry test steps that perform 9 * This test defines a series of elementatry test steps that perform
10 * a single or a small group of canvas API calls. Each test step is 10 * a single or a small group of canvas API calls. Each test step is
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 , fIRect(SkIRect::MakeXYWH(0, 0, 2, 1)) 110 , fIRect(SkIRect::MakeXYWH(0, 0, 2, 1))
111 , fRegion(TestRegion()) 111 , fRegion(TestRegion())
112 , fColor(0x01020304) 112 , fColor(0x01020304)
113 , fPoints(kTestPoints) 113 , fPoints(kTestPoints)
114 , fPointCount(3) 114 , fPointCount(3)
115 , fWidth(2) 115 , fWidth(2)
116 , fHeight(2) 116 , fHeight(2)
117 , fText("Hello World") 117 , fText("Hello World")
118 , fPoints2(kTestPoints2) 118 , fPoints2(kTestPoints2)
119 , fBitmap(TestBitmap()) 119 , fBitmap(TestBitmap())
120 , fImage(createImage(fColor))
120 { } 121 { }
121 122
122 SkRect fRect; 123 SkRect fRect;
123 SkMatrix fMatrix;; 124 SkMatrix fMatrix;;
124 SkPath fPath; 125 SkPath fPath;
125 SkPath fNearlyZeroLengthPath; 126 SkPath fNearlyZeroLengthPath;
126 SkIRect fIRect; 127 SkIRect fIRect;
127 SkRegion fRegion; 128 SkRegion fRegion;
128 SkColor fColor; 129 SkColor fColor;
129 SkPaint fPaint; 130 SkPaint fPaint;
130 const SkPoint* fPoints; 131 const SkPoint* fPoints;
131 size_t fPointCount; 132 size_t fPointCount;
132 int fWidth; 133 int fWidth;
133 int fHeight; 134 int fHeight;
134 SkString fText; 135 SkString fText;
135 const SkPoint* fPoints2; 136 const SkPoint* fPoints2;
136 SkBitmap fBitmap; 137 SkBitmap fBitmap;
138 SkAutoTUnref<const SkImage> fImage;
137 139
138 private: 140 private:
141 static const SkImage* createImage(SkColor color) {
142 SkAutoTUnref<SkSurface> surface (createSurface(color));
143
144 return surface->newImageSnapshot();
145 }
139 static SkMatrix TestMatrix() { 146 static SkMatrix TestMatrix() {
140 SkMatrix matrix; 147 SkMatrix matrix;
141 matrix.reset(); 148 matrix.reset();
142 matrix.setScale(SkIntToScalar(2), SkIntToScalar(3)); 149 matrix.setScale(SkIntToScalar(2), SkIntToScalar(3));
143 150
144 return matrix; 151 return matrix;
145 } 152 }
146 static SkPath TestPath() { 153 static SkPath TestPath() {
147 SkPath path; 154 SkPath path;
148 path.addRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), 155 path.addRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 SIMPLE_TEST_STEP(DrawText, drawText(d.fText.c_str(), d.fText.size(), 0, 1, d.fPa int)); 373 SIMPLE_TEST_STEP(DrawText, drawText(d.fText.c_str(), d.fText.size(), 0, 1, d.fPa int));
367 SIMPLE_TEST_STEP(DrawPosText, drawPosText(d.fText.c_str(), d.fText.size(), d.fPo ints2, d.fPaint)); 374 SIMPLE_TEST_STEP(DrawPosText, drawPosText(d.fText.c_str(), d.fText.size(), d.fPo ints2, d.fPaint));
368 SIMPLE_TEST_STEP(DrawTextOnPath, drawTextOnPath(d.fText.c_str(), d.fText.size(), 375 SIMPLE_TEST_STEP(DrawTextOnPath, drawTextOnPath(d.fText.c_str(), d.fText.size(),
369 d.fPath, NULL, d.fPaint)); 376 d.fPath, NULL, d.fPaint));
370 SIMPLE_TEST_STEP(DrawTextOnPathMatrix, drawTextOnPath(d.fText.c_str(), d.fText.s ize(), d.fPath, 377 SIMPLE_TEST_STEP(DrawTextOnPathMatrix, drawTextOnPath(d.fText.c_str(), d.fText.s ize(), d.fPath,
371 &d.fMatrix, d.fPaint)); 378 &d.fMatrix, d.fPaint));
372 SIMPLE_TEST_STEP(DrawData, drawData(d.fText.c_str(), d.fText.size())); 379 SIMPLE_TEST_STEP(DrawData, drawData(d.fText.c_str(), d.fText.size()));
373 SIMPLE_TEST_STEP(BeginGroup, beginCommentGroup(d.fText.c_str())); 380 SIMPLE_TEST_STEP(BeginGroup, beginCommentGroup(d.fText.c_str()));
374 SIMPLE_TEST_STEP(AddComment, addComment(d.fText.c_str(), d.fText.c_str())); 381 SIMPLE_TEST_STEP(AddComment, addComment(d.fText.c_str(), d.fText.c_str()));
375 SIMPLE_TEST_STEP(EndGroup, endCommentGroup()); 382 SIMPLE_TEST_STEP(EndGroup, endCommentGroup());
383 SIMPLE_TEST_STEP(DrawImage, drawImage(d.fImage, 0, 0));
384 SIMPLE_TEST_STEP(DrawImageRect, drawImageRect(d.fImage, 0, d.fRect));
385
376 386
377 /////////////////////////////////////////////////////////////////////////////// 387 ///////////////////////////////////////////////////////////////////////////////
378 // Complex test steps 388 // Complex test steps
379 389
380 static void SaveMatrixClipStep(SkCanvas* canvas, const TestData& d, 390 static void SaveMatrixClipStep(SkCanvas* canvas, const TestData& d,
381 skiatest::Reporter* reporter, CanvasTestStep* tes tStep) { 391 skiatest::Reporter* reporter, CanvasTestStep* tes tStep) {
382 int saveCount = canvas->getSaveCount(); 392 int saveCount = canvas->getSaveCount();
383 canvas->save(); 393 canvas->save();
384 canvas->translate(SkIntToScalar(1), SkIntToScalar(2)); 394 canvas->translate(SkIntToScalar(1), SkIntToScalar(2));
385 canvas->clipRegion(d.fRegion); 395 canvas->clipRegion(d.fRegion);
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 878
869 for (int testStep = 0; testStep < testStepArray().count(); testStep++) { 879 for (int testStep = 0; testStep < testStepArray().count(); testStep++) {
870 TestOverrideStateConsistency(reporter, d, testStepArray()[testStep]); 880 TestOverrideStateConsistency(reporter, d, testStepArray()[testStep]);
871 if (testStepArray()[testStep]->enablePdfTesting()) { 881 if (testStepArray()[testStep]->enablePdfTesting()) {
872 TestPdfDevice(reporter, d, testStepArray()[testStep]); 882 TestPdfDevice(reporter, d, testStepArray()[testStep]);
873 } 883 }
874 } 884 }
875 885
876 test_newraster(reporter); 886 test_newraster(reporter);
877 } 887 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698