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

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

Issue 1404433002: Remove image usage type enum. Use GrTextureParams instead. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix no gpu build Created 5 years, 2 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/SkBitmapProcShader.cpp ('k') | src/core/SkImageCacherator.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 #ifndef SkImageCacherator_DEFINED 8 #ifndef SkImageCacherator_DEFINED
9 #define SkImageCacherator_DEFINED 9 #define SkImageCacherator_DEFINED
10 10
11 #include "SkImageGenerator.h" 11 #include "SkImageGenerator.h"
12 #include "SkMutex.h" 12 #include "SkMutex.h"
13 #include "SkTemplates.h" 13 #include "SkTemplates.h"
14 14
15 class GrContext; 15 class GrContext;
16 class GrTextureParams;
16 class SkBitmap; 17 class SkBitmap;
17 class SkImage; 18 class SkImage;
18 19
19 /* 20 /*
20 * Internal class to manage caching the output of an ImageGenerator. 21 * Internal class to manage caching the output of an ImageGenerator.
21 */ 22 */
22 class SkImageCacherator { 23 class SkImageCacherator {
23 public: 24 public:
24 // Takes ownership of the generator 25 // Takes ownership of the generator
25 static SkImageCacherator* NewFromGenerator(SkImageGenerator*, const SkIRect* subset = nullptr); 26 static SkImageCacherator* NewFromGenerator(SkImageGenerator*, const SkIRect* subset = nullptr);
(...skipping 12 matching lines...) Expand all
38 39
39 /** 40 /**
40 * Returns a ref() on the texture produced by this generator. The caller mu st call unref() 41 * Returns a ref() on the texture produced by this generator. The caller mu st call unref()
41 * when it is done. Will return nullptr on failure. 42 * when it is done. Will return nullptr on failure.
42 * 43 *
43 * If not NULL, the client will be notified (->notifyAddedToCache()) when r esources are 44 * If not NULL, the client will be notified (->notifyAddedToCache()) when r esources are
44 * added to the cache on its behalf. 45 * added to the cache on its behalf.
45 * 46 *
46 * The caller is responsible for calling texture->unref() when they are don e. 47 * The caller is responsible for calling texture->unref() when they are don e.
47 */ 48 */
48 GrTexture* lockAsTexture(GrContext*, SkImageUsageType, const SkImage* client ); 49 GrTexture* lockAsTexture(GrContext*, const GrTextureParams&, const SkImage* client);
49 50
50 /** 51 /**
51 * If the underlying src naturally is represented by an encoded blob (in Sk Data), this returns 52 * If the underlying src naturally is represented by an encoded blob (in Sk Data), this returns
52 * a ref to that data. If not, it returns null. 53 * a ref to that data. If not, it returns null.
53 */ 54 */
54 SkData* refEncoded(); 55 SkData* refEncoded();
55 56
56 private: 57 private:
57 SkImageCacherator(SkImageGenerator*, const SkImageInfo&, const SkIPoint&, ui nt32_t uniqueID); 58 SkImageCacherator(SkImageGenerator*, const SkImageInfo&, const SkIPoint&, ui nt32_t uniqueID);
58 59
59 bool generateBitmap(SkBitmap*); 60 bool generateBitmap(SkBitmap*);
60 bool tryLockAsBitmap(SkBitmap*, const SkImage*); 61 bool tryLockAsBitmap(SkBitmap*, const SkImage*);
61 #if SK_SUPPORT_GPU 62 #if SK_SUPPORT_GPU
62 GrTexture* lockUnstretchedTexture(GrContext*, SkImageUsageType, const SkImag e* client); 63 GrTexture* lockUnstretchedTexture(GrContext*, const GrTextureParams&, const SkImage* client);
63 #endif 64 #endif
64 65
65 class ScopedGenerator { 66 class ScopedGenerator {
66 SkImageCacherator* fCacher; 67 SkImageCacherator* fCacher;
67 public: 68 public:
68 ScopedGenerator(SkImageCacherator* cacher) : fCacher(cacher) { 69 ScopedGenerator(SkImageCacherator* cacher) : fCacher(cacher) {
69 fCacher->fMutexForGenerator.acquire(); 70 fCacher->fMutexForGenerator.acquire();
70 } 71 }
71 ~ScopedGenerator() { 72 ~ScopedGenerator() {
72 fCacher->fMutexForGenerator.release(); 73 fCacher->fMutexForGenerator.release();
73 } 74 }
74 SkImageGenerator* operator->() const { return fCacher->fNotThreadSafeGen erator; } 75 SkImageGenerator* operator->() const { return fCacher->fNotThreadSafeGen erator; }
75 operator SkImageGenerator*() const { return fCacher->fNotThreadSafeGener ator; } 76 operator SkImageGenerator*() const { return fCacher->fNotThreadSafeGener ator; }
76 }; 77 };
77 78
78 SkMutex fMutexForGenerator; 79 SkMutex fMutexForGenerator;
79 SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator; 80 SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator;
80 81
81 const SkImageInfo fInfo; 82 const SkImageInfo fInfo;
82 const SkIPoint fOrigin; 83 const SkIPoint fOrigin;
83 const uint32_t fUniqueID; 84 const uint32_t fUniqueID;
84 85
85 friend class Cacherator_GrTextureMaker; 86 friend class Cacherator_GrTextureMaker;
86 }; 87 };
87 88
88 #endif 89 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | src/core/SkImageCacherator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698