| OLD | NEW |
| 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 #endif | 19 #endif |
| 18 | 20 |
| 19 static const int DEV_W = 100, DEV_H = 100; | 21 static const int DEV_W = 100, DEV_H = 100; |
| 20 static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H); | 22 static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H); |
| 21 static const SkRect DEV_RECT_S = SkRect::MakeWH(DEV_W * SK_Scalar1, | 23 static const SkRect DEV_RECT_S = SkRect::MakeWH(DEV_W * SK_Scalar1, |
| 22 DEV_H * SK_Scalar1); | 24 DEV_H * SK_Scalar1); |
| 23 | 25 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 default: | 246 default: |
| 245 SkASSERT(0); | 247 SkASSERT(0); |
| 246 break; | 248 break; |
| 247 } | 249 } |
| 248 bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h, rowBytes); | 250 bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h, rowBytes); |
| 249 if (alloc) { | 251 if (alloc) { |
| 250 bitmap->allocPixels(); | 252 bitmap->allocPixels(); |
| 251 } | 253 } |
| 252 } | 254 } |
| 253 | 255 |
| 254 static void ReadPixelsTest(skiatest::Reporter* reporter, GrContextFactory* facto
ry) { | 256 DEF_GPUTEST(ReadPixels, reporter, factory) { |
| 255 const SkIRect testRects[] = { | 257 const SkIRect testRects[] = { |
| 256 // entire thing | 258 // entire thing |
| 257 DEV_RECT, | 259 DEV_RECT, |
| 258 // larger on all sides | 260 // larger on all sides |
| 259 SkIRect::MakeLTRB(-10, -10, DEV_W + 10, DEV_H + 10), | 261 SkIRect::MakeLTRB(-10, -10, DEV_W + 10, DEV_H + 10), |
| 260 // fully contained | 262 // fully contained |
| 261 SkIRect::MakeLTRB(DEV_W / 4, DEV_H / 4, 3 * DEV_W / 4, 3 * DEV_H / 4), | 263 SkIRect::MakeLTRB(DEV_W / 4, DEV_H / 4, 3 * DEV_W / 4, 3 * DEV_H / 4), |
| 262 // outside top left | 264 // outside top left |
| 263 SkIRect::MakeLTRB(-10, -10, -1, -1), | 265 SkIRect::MakeLTRB(-10, -10, -1, -1), |
| 264 // touching top left corner | 266 // touching top left corner |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 clippedRect.fTop, true, false, | 401 clippedRect.fTop, true, false, |
| 400 SkCanvas::kNative_Premul_Config8888); | 402 SkCanvas::kNative_Premul_Config8888); |
| 401 } else { | 403 } else { |
| 402 REPORTER_ASSERT(reporter, !success); | 404 REPORTER_ASSERT(reporter, !success); |
| 403 } | 405 } |
| 404 } | 406 } |
| 405 } | 407 } |
| 406 } | 408 } |
| 407 } | 409 } |
| 408 } | 410 } |
| 409 | |
| 410 #include "TestClassDef.h" | |
| 411 DEFINE_GPUTESTCLASS("ReadPixels", ReadPixelsTestClass, ReadPixelsTest) | |
| OLD | NEW |