| 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 "SkImage_Base.h" | 10 #include "SkImage_Base.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 SkImageCacherator::SkImageCacherator(SkImageGenerator* gen, const SkImageInfo& i
nfo, | 64 SkImageCacherator::SkImageCacherator(SkImageGenerator* gen, const SkImageInfo& i
nfo, |
| 65 const SkIPoint& origin, uint32_t uniqueID) | 65 const SkIPoint& origin, uint32_t uniqueID) |
| 66 : fNotThreadSafeGenerator(gen) | 66 : fNotThreadSafeGenerator(gen) |
| 67 , fInfo(info) | 67 , fInfo(info) |
| 68 , fOrigin(origin) | 68 , fOrigin(origin) |
| 69 , fUniqueID(uniqueID) | 69 , fUniqueID(uniqueID) |
| 70 {} | 70 {} |
| 71 | 71 |
| 72 SkData* SkImageCacherator::refEncoded() { | 72 SkData* SkImageCacherator::refEncoded(GrContext* ctx) { |
| 73 ScopedGenerator generator(this); | 73 ScopedGenerator generator(this); |
| 74 return generator->refEncodedData(); | 74 return generator->refEncodedData(ctx); |
| 75 } | 75 } |
| 76 | 76 |
| 77 static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { | 77 static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { |
| 78 SkASSERT(bitmap.getGenerationID() == expectedID); | 78 SkASSERT(bitmap.getGenerationID() == expectedID); |
| 79 SkASSERT(bitmap.isImmutable()); | 79 SkASSERT(bitmap.isImmutable()); |
| 80 SkASSERT(bitmap.getPixels()); | 80 SkASSERT(bitmap.getPixels()); |
| 81 return true; | 81 return true; |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Note, this returns a new, mutable, bitmap, with a new genID. | 84 // Note, this returns a new, mutable, bitmap, with a new genID. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 ScopedGenerator generator(this); | 252 ScopedGenerator generator(this); |
| 253 SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width
(), fInfo.height()); | 253 SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width
(), fInfo.height()); |
| 254 if (GrTexture* tex = generator->generateTexture(ctx, &subset)) { | 254 if (GrTexture* tex = generator->generateTexture(ctx, &subset)) { |
| 255 return set_key_and_return(tex, key); | 255 return set_key_and_return(tex, key); |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 | 258 |
| 259 const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo); | 259 const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo); |
| 260 | 260 |
| 261 // 3. Ask the generator to return a compressed form that the GPU might suppo
rt | 261 // 3. Ask the generator to return a compressed form that the GPU might suppo
rt |
| 262 SkAutoTUnref<SkData> data(this->refEncoded()); | 262 SkAutoTUnref<SkData> data(this->refEncoded(ctx)); |
| 263 if (data) { | 263 if (data) { |
| 264 GrTexture* tex = load_compressed_into_texture(ctx, data, desc); | 264 GrTexture* tex = load_compressed_into_texture(ctx, data, desc); |
| 265 if (tex) { | 265 if (tex) { |
| 266 return set_key_and_return(tex, key); | 266 return set_key_and_return(tex, key); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 // 4. Ask the generator to return YUV planes, which the GPU can convert | 270 // 4. Ask the generator to return YUV planes, which the GPU can convert |
| 271 { | 271 { |
| 272 ScopedGenerator generator(this); | 272 ScopedGenerator generator(this); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 300 } | 300 } |
| 301 | 301 |
| 302 #else | 302 #else |
| 303 | 303 |
| 304 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, | 304 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, |
| 305 const SkImage* client, SkImage::Cach
ingHint) { | 305 const SkImage* client, SkImage::Cach
ingHint) { |
| 306 return nullptr; | 306 return nullptr; |
| 307 } | 307 } |
| 308 | 308 |
| 309 #endif | 309 #endif |
| OLD | NEW |