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 SkASSERT((fType <= kLast_TestType) && (fType >= 0)); | 182 SkASSERT((fType <= kLast_TestType) && (fType >= 0)); |
183 } | 183 } |
184 virtual ~TestImageGenerator() { } | 184 virtual ~TestImageGenerator() { } |
185 virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE { | 185 virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE { |
186 REPORTER_ASSERT(fReporter, NULL != info); | 186 REPORTER_ASSERT(fReporter, NULL != info); |
187 if ((NULL == info) || (kFailGetInfo_TestType == fType)) { | 187 if ((NULL == info) || (kFailGetInfo_TestType == fType)) { |
188 return false; | 188 return false; |
189 } | 189 } |
190 info->fWidth = TestImageGenerator::Width(); | 190 info->fWidth = TestImageGenerator::Width(); |
191 info->fHeight = TestImageGenerator::Height(); | 191 info->fHeight = TestImageGenerator::Height(); |
192 info->fColorType = kN32_SkColorType; | 192 info->fColorType = kPMColor_SkColorType; |
193 info->fAlphaType = kOpaque_SkAlphaType; | 193 info->fAlphaType = kOpaque_SkAlphaType; |
194 return true; | 194 return true; |
195 } | 195 } |
196 virtual bool getPixels(const SkImageInfo& info, | 196 virtual bool getPixels(const SkImageInfo& info, |
197 void* pixels, | 197 void* pixels, |
198 size_t rowBytes) SK_OVERRIDE { | 198 size_t rowBytes) SK_OVERRIDE { |
199 REPORTER_ASSERT(fReporter, pixels != NULL); | 199 REPORTER_ASSERT(fReporter, pixels != NULL); |
200 size_t minRowBytes | 200 size_t minRowBytes |
201 = static_cast<size_t>(info.fWidth * info.bytesPerPixel()); | 201 = static_cast<size_t>(info.fWidth * info.bytesPerPixel()); |
202 REPORTER_ASSERT(fReporter, rowBytes >= minRowBytes); | 202 REPORTER_ASSERT(fReporter, rowBytes >= minRowBytes); |
203 if ((NULL == pixels) | 203 if ((NULL == pixels) |
204 || (fType != kSucceedGetPixels_TestType) | 204 || (fType != kSucceedGetPixels_TestType) |
205 || (info.fColorType != kN32_SkColorType)) { | 205 || (info.fColorType != kPMColor_SkColorType)) { |
206 return false; | 206 return false; |
207 } | 207 } |
208 char* bytePtr = static_cast<char*>(pixels); | 208 char* bytePtr = static_cast<char*>(pixels); |
209 for (int y = 0; y < info.fHeight; ++y) { | 209 for (int y = 0; y < info.fHeight; ++y) { |
210 sk_memset32(reinterpret_cast<SkColor*>(bytePtr), | 210 sk_memset32(reinterpret_cast<SkColor*>(bytePtr), |
211 TestImageGenerator::Color(), info.fWidth); | 211 TestImageGenerator::Color(), info.fWidth); |
212 bytePtr += rowBytes; | 212 bytePtr += rowBytes; |
213 } | 213 } |
214 return true; | 214 return true; |
215 } | 215 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 314 |
315 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool(); | 315 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool(); |
316 // Only acts differently from NULL on a platform that has a | 316 // Only acts differently from NULL on a platform that has a |
317 // default discardable memory implementation that differs from the | 317 // default discardable memory implementation that differs from the |
318 // global DM pool. | 318 // global DM pool. |
319 check_pixelref(TestImageGenerator::kFailGetPixels_TestType, | 319 check_pixelref(TestImageGenerator::kFailGetPixels_TestType, |
320 reporter, kSkDiscardable_PixelRefType, globalPool); | 320 reporter, kSkDiscardable_PixelRefType, globalPool); |
321 check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, | 321 check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, |
322 reporter, kSkDiscardable_PixelRefType, globalPool); | 322 reporter, kSkDiscardable_PixelRefType, globalPool); |
323 } | 323 } |
OLD | NEW |