| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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" | 8 #include "Test.h" |
| 9 | 9 |
| 10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
| 11 #include "GrContext.h" | 11 #include "GrContext.h" |
| 12 #include "GrRenderTargetContext.h" | 12 #include "GrRenderTargetContext.h" |
| 13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
| 14 #include "GrRenderTarget.h" | 14 #include "GrRenderTarget.h" |
| 15 #include "GrTexture.h" | 15 #include "GrTexture.h" |
| 16 #include "GrTextureProvider.h" | 16 #include "GrTextureProvider.h" |
| 17 | 17 |
| 18 static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t
expectedValue, | 18 static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t
expectedValue, |
| 19 uint32_t* actualValue, int* failX, int* failY) { | 19 uint32_t* actualValue, int* failX, int* failY) { |
| 20 GrRenderTarget* rt = rtc->accessRenderTarget(); | |
| 21 int w = rect.width(); | 20 int w = rect.width(); |
| 22 int h = rect.height(); | 21 int h = rect.height(); |
| 23 std::unique_ptr<uint32_t[]> pixels(new uint32_t[w * h]); | 22 std::unique_ptr<uint32_t[]> pixels(new uint32_t[w * h]); |
| 24 memset(pixels.get(), ~expectedValue, sizeof(uint32_t) * w * h); | 23 memset(pixels.get(), ~expectedValue, sizeof(uint32_t) * w * h); |
| 25 rt->readPixels(rect.fLeft, rect.fTop, w, h, kRGBA_8888_GrPixelConfig, pixels
.get()); | 24 SkImageInfo ii = SkImageInfo::MakeN32Premul(w, h); |
| 25 rtc->readPixels(ii, pixels.get(), 0, rect.fLeft, rect.fTop); |
| 26 for (int y = 0; y < h; ++y) { | 26 for (int y = 0; y < h; ++y) { |
| 27 for (int x = 0; x < w; ++x) { | 27 for (int x = 0; x < w; ++x) { |
| 28 uint32_t pixel = pixels.get()[y * w + x]; | 28 uint32_t pixel = pixels.get()[y * w + x]; |
| 29 if (pixel != expectedValue) { | 29 if (pixel != expectedValue) { |
| 30 *actualValue = pixel; | 30 *actualValue = pixel; |
| 31 *failX = x + rect.fLeft; | 31 *failX = x + rect.fLeft; |
| 32 *failY = y + rect.fTop; | 32 *failY = y + rect.fTop; |
| 33 return false; | 33 return false; |
| 34 } | 34 } |
| 35 } | 35 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 215 } |
| 216 if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &fail
X, &failY) || | 216 if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &fail
X, &failY) || |
| 217 !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX
, &failY) || | 217 !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX
, &failY) || |
| 218 !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &fai
lX, &failY) || | 218 !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &fai
lX, &failY) || |
| 219 !check_rect(rtContext.get(), outerBottomEdge, kColor1, &actualValue, &fa
ilX, &failY)) { | 219 !check_rect(rtContext.get(), outerBottomEdge, kColor1, &actualValue, &fa
ilX, &failY)) { |
| 220 ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1,
actualValue, | 220 ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1,
actualValue, |
| 221 failX, failY); | 221 failX, failY); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 #endif | 224 #endif |
| OLD | NEW |