| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBitmapCache.h" | 9 #include "SkBitmapCache.h" |
| 10 #include "SkImageCacherator.h" | 10 #include "SkImageCacherator.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 return nullptr; | 38 return nullptr; |
| 39 } | 39 } |
| 40 if (*subset != bounds) { | 40 if (*subset != bounds) { |
| 41 // we need a different uniqueID since we really are a subset of the
raw generator | 41 // we need a different uniqueID since we really are a subset of the
raw generator |
| 42 uniqueID = SkNextID::ImageID(); | 42 uniqueID = SkNextID::ImageID(); |
| 43 } | 43 } |
| 44 } else { | 44 } else { |
| 45 subset = &bounds; | 45 subset = &bounds; |
| 46 } | 46 } |
| 47 | 47 |
| 48 return SkNEW_ARGS(SkImageCacherator, (gen, | 48 return new SkImageCacherator(gen, gen->getInfo().makeWH(subset->width(), sub
set->height()), |
| 49 gen->getInfo().makeWH(subset->width(),
subset->height()), | 49 SkIPoint::Make(subset->x(), subset->y()), uniqu
eID); |
| 50 SkIPoint::Make(subset->x(), subset->y(
)), | |
| 51 uniqueID)); | |
| 52 } | 50 } |
| 53 | 51 |
| 54 SkImageCacherator::SkImageCacherator(SkImageGenerator* gen, const SkImageInfo& i
nfo, | 52 SkImageCacherator::SkImageCacherator(SkImageGenerator* gen, const SkImageInfo& i
nfo, |
| 55 const SkIPoint& origin, uint32_t uniqueID) | 53 const SkIPoint& origin, uint32_t uniqueID) |
| 56 : fGenerator(gen) | 54 : fGenerator(gen) |
| 57 , fInfo(info) | 55 , fInfo(info) |
| 58 , fOrigin(origin) | 56 , fOrigin(origin) |
| 59 , fUniqueID(uniqueID) | 57 , fUniqueID(uniqueID) |
| 60 {} | 58 {} |
| 61 | 59 |
| 62 SkImageCacherator::~SkImageCacherator() { | 60 SkImageCacherator::~SkImageCacherator() { delete fGenerator; } |
| 63 SkDELETE(fGenerator); | |
| 64 } | |
| 65 | 61 |
| 66 static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { | 62 static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { |
| 67 SkASSERT(bitmap.getGenerationID() == expectedID); | 63 SkASSERT(bitmap.getGenerationID() == expectedID); |
| 68 SkASSERT(bitmap.isImmutable()); | 64 SkASSERT(bitmap.isImmutable()); |
| 69 SkASSERT(bitmap.getPixels()); | 65 SkASSERT(bitmap.getPixels()); |
| 70 return true; | 66 return true; |
| 71 } | 67 } |
| 72 | 68 |
| 73 static bool generate_bitmap(SkBitmap* bitmap, const SkImageInfo& info, const SkI
Point& origin, | 69 static bool generate_bitmap(SkBitmap* bitmap, const SkImageInfo& info, const SkI
Point& origin, |
| 74 SkImageGenerator* generator) { | 70 SkImageGenerator* generator) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 SkBitmap bitmap; | 186 SkBitmap bitmap; |
| 191 if (!generate_bitmap(&bitmap, fInfo, fOrigin, fGenerator)) { | 187 if (!generate_bitmap(&bitmap, fInfo, fOrigin, fGenerator)) { |
| 192 return nullptr; | 188 return nullptr; |
| 193 } | 189 } |
| 194 return GrRefCachedBitmapTexture(ctx, bitmap, usage); | 190 return GrRefCachedBitmapTexture(ctx, bitmap, usage); |
| 195 #else | 191 #else |
| 196 return nullptr; | 192 return nullptr; |
| 197 #endif | 193 #endif |
| 198 } | 194 } |
| 199 | 195 |
| OLD | NEW |