Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: src/core/SkImageCacherator.cpp

Issue 1862133002: Add whitelist parameter to refEncodedData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkImageCacherator.h ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 SkGpuFormatWhitelist::includes(SkEncodedFormat format) {
29 #if SK_SUPPORT_GPU
30 return GrIsCompressedFormatPossiblySupported(fCtx, format);
31 #else
32 return false;
33 #endif
34 }
35
36 //////////////////////////////////////////////////////////////////////////////// ///////////////////
37
28 SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen, 38 SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen,
29 const SkIRect* subset) { 39 const SkIRect* subset) {
30 if (!gen) { 40 if (!gen) {
31 return nullptr; 41 return nullptr;
32 } 42 }
33 43
34 // We are required to take ownership of gen, regardless of if we return a ca cherator or not 44 // We are required to take ownership of gen, regardless of if we return a ca cherator or not
35 SkAutoTDelete<SkImageGenerator> genHolder(gen); 45 SkAutoTDelete<SkImageGenerator> genHolder(gen);
36 46
37 const SkImageInfo& info = gen->getInfo(); 47 const SkImageInfo& info = gen->getInfo();
(...skipping 25 matching lines...) Expand all
63 73
64 SkImageCacherator::SkImageCacherator(SkImageGenerator* gen, const SkImageInfo& i nfo, 74 SkImageCacherator::SkImageCacherator(SkImageGenerator* gen, const SkImageInfo& i nfo,
65 const SkIPoint& origin, uint32_t uniqueID) 75 const SkIPoint& origin, uint32_t uniqueID)
66 : fNotThreadSafeGenerator(gen) 76 : fNotThreadSafeGenerator(gen)
67 , fInfo(info) 77 , fInfo(info)
68 , fOrigin(origin) 78 , fOrigin(origin)
69 , fUniqueID(uniqueID) 79 , fUniqueID(uniqueID)
70 {} 80 {}
71 81
72 SkData* SkImageCacherator::refEncoded(GrContext* ctx) { 82 SkData* SkImageCacherator::refEncoded(GrContext* ctx) {
83 SkImageGenerator::RefEncodedWhitelist* whitelist = nullptr;
84 #if SK_SUPPORT_GPU
85 SkGpuFormatWhitelist gpuWhitelist(ctx);
86 if (ctx) {
87 whitelist = &gpuWhitelist;
88 }
89 #endif
73 ScopedGenerator generator(this); 90 ScopedGenerator generator(this);
74 return generator->refEncodedData(ctx); 91 return generator->refEncodedData(whitelist);
75 } 92 }
76 93
77 static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { 94 static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) {
78 SkASSERT(bitmap.getGenerationID() == expectedID); 95 SkASSERT(bitmap.getGenerationID() == expectedID);
79 SkASSERT(bitmap.isImmutable()); 96 SkASSERT(bitmap.isImmutable());
80 SkASSERT(bitmap.getPixels()); 97 SkASSERT(bitmap.getPixels());
81 return true; 98 return true;
82 } 99 }
83 100
84 // Note, this returns a new, mutable, bitmap, with a new genID. 101 // Note, this returns a new, mutable, bitmap, with a new genID.
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 349 }
333 350
334 #else 351 #else
335 352
336 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s&, 353 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s&,
337 const SkImage* client, SkImage::Cach ingHint) { 354 const SkImage* client, SkImage::Cach ingHint) {
338 return nullptr; 355 return nullptr;
339 } 356 }
340 357
341 #endif 358 #endif
OLDNEW
« no previous file with comments | « src/core/SkImageCacherator.h ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698