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

Side by Side Diff: tests/WritePixelsTest.cpp

Issue 132293005: Add a DEF_GPUTEST() macro. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fatory -> factory Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « tests/TestClassDef.h ('k') | 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 2011 Google Inc. 2 * Copyright 2011 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 #include "Test.h"
9 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
10 #include "SkCanvas.h" 9 #include "SkCanvas.h"
11 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
12 #include "SkMathPriv.h" 11 #include "SkMathPriv.h"
13 #include "SkRegion.h" 12 #include "SkRegion.h"
13 #include "Test.h"
14 #include "TestClassDef.h"
15
14 #if SK_SUPPORT_GPU 16 #if SK_SUPPORT_GPU
15 #include "SkGpuDevice.h" 17 #include "SkGpuDevice.h"
16 #include "GrContextFactory.h" 18 #include "GrContextFactory.h"
17 #else 19 #else
18 class GrContext; 20 class GrContext;
19 class GrContextFactory; 21 class GrContextFactory;
20 #endif 22 #endif
21 23
22 static const int DEV_W = 100, DEV_H = 100; 24 static const int DEV_W = 100, DEV_H = 100;
23 static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H); 25 static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 intptr_t pixels = reinterpret_cast<intptr_t>(bitmap->getPixels()); 353 intptr_t pixels = reinterpret_cast<intptr_t>(bitmap->getPixels());
352 for (int y = 0; y < h; ++y) { 354 for (int y = 0; y < h; ++y) {
353 for (int x = 0; x < w; ++x) { 355 for (int x = 0; x < w; ++x) {
354 uint32_t* pixel = reinterpret_cast<uint32_t*>(pixels + y * bitmap->r owBytes() + x * 4); 356 uint32_t* pixel = reinterpret_cast<uint32_t*>(pixels + y * bitmap->r owBytes() + x * 4);
355 *pixel = getBitmapColor(x, y, w, config8888); 357 *pixel = getBitmapColor(x, y, w, config8888);
356 } 358 }
357 } 359 }
358 return true; 360 return true;
359 } 361 }
360 362
361 static void WritePixelsTest(skiatest::Reporter* reporter, GrContextFactory* fact ory) { 363 DEF_GPUTEST(WritePixels, reporter, factory) {
362 SkCanvas canvas; 364 SkCanvas canvas;
363 365
364 const SkIRect testRects[] = { 366 const SkIRect testRects[] = {
365 // entire thing 367 // entire thing
366 DEV_RECT, 368 DEV_RECT,
367 // larger on all sides 369 // larger on all sides
368 SkIRect::MakeLTRB(-10, -10, DEV_W + 10, DEV_H + 10), 370 SkIRect::MakeLTRB(-10, -10, DEV_W + 10, DEV_H + 10),
369 // fully contained 371 // fully contained
370 SkIRect::MakeLTRB(DEV_W / 4, DEV_H / 4, 3 * DEV_W / 4, 3 * DEV_H / 4), 372 SkIRect::MakeLTRB(DEV_W / 4, DEV_H / 4, 3 * DEV_W / 4, 3 * DEV_H / 4),
371 // outside top left 373 // outside top left
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 SkIRect writeRect = SkIRect::MakeXYWH(rect.fLeft, rect.f Top, 464 SkIRect writeRect = SkIRect::MakeXYWH(rect.fLeft, rect.f Top,
463 bmp.width(), bmp.h eight()); 465 bmp.width(), bmp.h eight());
464 bool intersects = SkIRect::Intersects(canvasRect, writeR ect) ; 466 bool intersects = SkIRect::Intersects(canvasRect, writeR ect) ;
465 REPORTER_ASSERT(reporter, intersects == (idBefore != idA fter)); 467 REPORTER_ASSERT(reporter, intersects == (idBefore != idA fter));
466 } 468 }
467 } 469 }
468 } 470 }
469 } 471 }
470 } 472 }
471 } 473 }
472
473 #include "TestClassDef.h"
474 DEFINE_GPUTESTCLASS("WritePixels", WritePixelsTestClass, WritePixelsTest)
OLDNEW
« no previous file with comments | « tests/TestClassDef.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698