| 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" |
| 11 #include "SkImageCacherator.h" | 11 #include "SkImageCacherator.h" |
| 12 #include "SkMallocPixelRef.h" | 12 #include "SkMallocPixelRef.h" |
| 13 #include "SkNextID.h" | 13 #include "SkNextID.h" |
| 14 #include "SkPixelRef.h" | 14 #include "SkPixelRef.h" |
| 15 #include "SkResourceCache.h" | 15 #include "SkResourceCache.h" |
| 16 | 16 |
| 17 #if SK_SUPPORT_GPU | 17 #if SK_SUPPORT_GPU |
| 18 #include "GrContext.h" | 18 #include "GrContext.h" |
| 19 #include "GrGpuResourcePriv.h" | 19 #include "GrGpuResourcePriv.h" |
| 20 #include "GrImageIDTextureAdjuster.h" | 20 #include "GrImageIDTextureAdjuster.h" |
| 21 #include "GrResourceKey.h" | 21 #include "GrResourceKey.h" |
| 22 #include "GrTextureParams.h" | 22 #include "GrTextureParams.h" |
| 23 #include "GrYUVProvider.h" | 23 #include "GrYUVProvider.h" |
| 24 #include "SkGr.h" | 24 #include "SkGr.h" |
| 25 #include "SkGrPriv.h" | 25 #include "SkGrPriv.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 bool SkEncodedFormatQuery_Gpu::supportedFormat(SkEncodedFormat format) { |
| 29 #if SK_SUPPORT_GPU |
| 30 return GrIsCompressedFormatPossiblySupported(fCtx, format); |
| 31 #else |
| 32 return false; |
| 33 #endif |
| 34 } |
| 35 |
| 36 bool SkEncodedFormatQuery_Gpu::supportedFormatFromData(const void* data, size_t
length) { |
| 37 #if SK_SUPPORT_GPU |
| 38 return GrIsCompressedTextureDataPossiblySupported(fCtx, data, length); |
| 39 #else |
| 40 return false; |
| 41 #endif |
| 42 } |
| 43 |
| 44 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 45 |
| 28 SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen, | 46 SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen, |
| 29 const SkIRect* subset) { | 47 const SkIRect* subset) { |
| 30 if (!gen) { | 48 if (!gen) { |
| 31 return nullptr; | 49 return nullptr; |
| 32 } | 50 } |
| 33 | 51 |
| 34 // We are required to take ownership of gen, regardless of if we return a ca
cherator or not | 52 // We are required to take ownership of gen, regardless of if we return a ca
cherator or not |
| 35 SkAutoTDelete<SkImageGenerator> genHolder(gen); | 53 SkAutoTDelete<SkImageGenerator> genHolder(gen); |
| 36 | 54 |
| 37 const SkImageInfo& info = gen->getInfo(); | 55 const SkImageInfo& info = gen->getInfo(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 63 | 81 |
| 64 SkImageCacherator::SkImageCacherator(SkImageGenerator* gen, const SkImageInfo& i
nfo, | 82 SkImageCacherator::SkImageCacherator(SkImageGenerator* gen, const SkImageInfo& i
nfo, |
| 65 const SkIPoint& origin, uint32_t uniqueID) | 83 const SkIPoint& origin, uint32_t uniqueID) |
| 66 : fNotThreadSafeGenerator(gen) | 84 : fNotThreadSafeGenerator(gen) |
| 67 , fInfo(info) | 85 , fInfo(info) |
| 68 , fOrigin(origin) | 86 , fOrigin(origin) |
| 69 , fUniqueID(uniqueID) | 87 , fUniqueID(uniqueID) |
| 70 {} | 88 {} |
| 71 | 89 |
| 72 SkData* SkImageCacherator::refEncoded(GrContext* ctx) { | 90 SkData* SkImageCacherator::refEncoded(GrContext* ctx) { |
| 91 SkEncodedFormatQuery* query = nullptr; |
| 92 #if SK_SUPPORT_GPU |
| 93 SkEncodedFormatQuery_Gpu gpuQuery(ctx); |
| 94 if (ctx) { |
| 95 query = &gpuQuery; |
| 96 } |
| 97 #endif |
| 73 ScopedGenerator generator(this); | 98 ScopedGenerator generator(this); |
| 74 return generator->refEncodedData(ctx); | 99 return generator->refEncodedData(query); |
| 75 } | 100 } |
| 76 | 101 |
| 77 static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { | 102 static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { |
| 78 SkASSERT(bitmap.getGenerationID() == expectedID); | 103 SkASSERT(bitmap.getGenerationID() == expectedID); |
| 79 SkASSERT(bitmap.isImmutable()); | 104 SkASSERT(bitmap.isImmutable()); |
| 80 SkASSERT(bitmap.getPixels()); | 105 SkASSERT(bitmap.getPixels()); |
| 81 return true; | 106 return true; |
| 82 } | 107 } |
| 83 | 108 |
| 84 // Note, this returns a new, mutable, bitmap, with a new genID. | 109 // Note, this returns a new, mutable, bitmap, with a new genID. |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 357 } |
| 333 | 358 |
| 334 #else | 359 #else |
| 335 | 360 |
| 336 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, | 361 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, |
| 337 const SkImage* client, SkImage::Cach
ingHint) { | 362 const SkImage* client, SkImage::Cach
ingHint) { |
| 338 return nullptr; | 363 return nullptr; |
| 339 } | 364 } |
| 340 | 365 |
| 341 #endif | 366 #endif |
| OLD | NEW |