Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkCachingPixelRef.h" | 9 #include "SkCachingPixelRef.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 REPORTER_ASSERT(fReporter, info); | 182 REPORTER_ASSERT(fReporter, info); |
| 183 if ((NULL == info) || (kFailGetInfo_TestType == fType)) { | 183 if ((NULL == info) || (kFailGetInfo_TestType == fType)) { |
| 184 return false; | 184 return false; |
| 185 } | 185 } |
| 186 *info = SkImageInfo::MakeN32(TestImageGenerator::Width(), | 186 *info = SkImageInfo::MakeN32(TestImageGenerator::Width(), |
| 187 TestImageGenerator::Height(), | 187 TestImageGenerator::Height(), |
| 188 kOpaque_SkAlphaType); | 188 kOpaque_SkAlphaType); |
| 189 return true; | 189 return true; |
| 190 } | 190 } |
| 191 | 191 |
| 192 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, | 192 virtual Result onGetPixels(const SkImageInfo& info, void* pixels, size_t row Bytes, |
| 193 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE { | 193 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE { |
| 194 REPORTER_ASSERT(fReporter, pixels != NULL); | 194 REPORTER_ASSERT(fReporter, pixels != NULL); |
| 195 size_t minRowBytes = static_cast<size_t>(info.width() * info.bytesPerPix el()); | 195 const size_t minRowBytes = info.minRowBytes(); |
|
djsollen
2015/02/12 14:22:15
remove this and have >= info.minRowBytes on next l
scroggo
2015/02/12 15:28:36
I originally wrote that, but then I thought I saw
| |
| 196 REPORTER_ASSERT(fReporter, rowBytes >= minRowBytes); | 196 REPORTER_ASSERT(fReporter, rowBytes >= minRowBytes); |
| 197 if ((NULL == pixels) | 197 if (fType != kSucceedGetPixels_TestType) { |
| 198 || (fType != kSucceedGetPixels_TestType) | 198 return kUnimplemented; |
| 199 || (info.colorType() != kN32_SkColorType)) { | 199 } |
| 200 return false; | 200 if (info.colorType() != kN32_SkColorType) { |
| 201 return kInvalidConversion; | |
| 201 } | 202 } |
| 202 char* bytePtr = static_cast<char*>(pixels); | 203 char* bytePtr = static_cast<char*>(pixels); |
| 203 for (int y = 0; y < info.height(); ++y) { | 204 for (int y = 0; y < info.height(); ++y) { |
| 204 sk_memset32(reinterpret_cast<SkColor*>(bytePtr), | 205 sk_memset32(reinterpret_cast<SkColor*>(bytePtr), |
| 205 TestImageGenerator::Color(), info.width()); | 206 TestImageGenerator::Color(), info.width()); |
| 206 bytePtr += rowBytes; | 207 bytePtr += rowBytes; |
| 207 } | 208 } |
| 208 return true; | 209 return kSuccess; |
| 209 } | 210 } |
| 210 | 211 |
| 211 private: | 212 private: |
| 212 const TestType fType; | 213 const TestType fType; |
| 213 skiatest::Reporter* const fReporter; | 214 skiatest::Reporter* const fReporter; |
| 214 }; | 215 }; |
| 215 | 216 |
| 216 static void check_test_image_generator_bitmap(skiatest::Reporter* reporter, | 217 static void check_test_image_generator_bitmap(skiatest::Reporter* reporter, |
| 217 const SkBitmap& bm) { | 218 const SkBitmap& bm) { |
| 218 REPORTER_ASSERT(reporter, TestImageGenerator::Width() == bm.width()); | 219 REPORTER_ASSERT(reporter, TestImageGenerator::Width() == bm.width()); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 canvas.clear(kDefaultColor); | 348 canvas.clear(kDefaultColor); |
| 348 canvas.drawImage(image, 0, 0, NULL); | 349 canvas.drawImage(image, 0, 0, NULL); |
| 349 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { | 350 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { |
| 350 REPORTER_ASSERT( | 351 REPORTER_ASSERT( |
| 351 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); | 352 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); |
| 352 } else { | 353 } else { |
| 353 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); | 354 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); |
| 354 } | 355 } |
| 355 } | 356 } |
| 356 } | 357 } |
| OLD | NEW |