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

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

Issue 1409163002: Rewrite GrTextureMaker to disentangle bitmap case from base class and give GPU object a say in what… (Closed) Base URL: https://skia.googlesource.com/skia.git@move
Patch Set: tidy 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 | « include/gpu/SkGr.h ('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 GrTextureParams;
17 class GrUniqueKey;
17 class SkBitmap; 18 class SkBitmap;
18 class SkImage; 19 class SkImage;
19 20
20 /* 21 /*
21 * Internal class to manage caching the output of an ImageGenerator. 22 * Internal class to manage caching the output of an ImageGenerator.
22 */ 23 */
23 class SkImageCacherator { 24 class SkImageCacherator {
24 public: 25 public:
25 // Takes ownership of the generator 26 // Takes ownership of the generator
26 static SkImageCacherator* NewFromGenerator(SkImageGenerator*, const SkIRect* subset = nullptr); 27 static SkImageCacherator* NewFromGenerator(SkImageGenerator*, const SkIRect* subset = nullptr);
(...skipping 26 matching lines...) Expand all
53 * a ref to that data. If not, it returns null. 54 * a ref to that data. If not, it returns null.
54 */ 55 */
55 SkData* refEncoded(); 56 SkData* refEncoded();
56 57
57 private: 58 private:
58 SkImageCacherator(SkImageGenerator*, const SkImageInfo&, const SkIPoint&, ui nt32_t uniqueID); 59 SkImageCacherator(SkImageGenerator*, const SkImageInfo&, const SkIPoint&, ui nt32_t uniqueID);
59 60
60 bool generateBitmap(SkBitmap*); 61 bool generateBitmap(SkBitmap*);
61 bool tryLockAsBitmap(SkBitmap*, const SkImage*); 62 bool tryLockAsBitmap(SkBitmap*, const SkImage*);
62 #if SK_SUPPORT_GPU 63 #if SK_SUPPORT_GPU
63 GrTexture* lockUnstretchedTexture(GrContext*, const SkImage* client); 64 // Returns the texture. If the cacherator is generating the texture and want s to cache it,
65 // it should use the passed in key (if the key is valid).
66 GrTexture* lockTexture(GrContext*, const GrUniqueKey& key, const SkImage* cl ient);
64 #endif 67 #endif
65 68
66 class ScopedGenerator { 69 class ScopedGenerator {
67 SkImageCacherator* fCacher; 70 SkImageCacherator* fCacher;
68 public: 71 public:
69 ScopedGenerator(SkImageCacherator* cacher) : fCacher(cacher) { 72 ScopedGenerator(SkImageCacherator* cacher) : fCacher(cacher) {
70 fCacher->fMutexForGenerator.acquire(); 73 fCacher->fMutexForGenerator.acquire();
71 } 74 }
72 ~ScopedGenerator() { 75 ~ScopedGenerator() {
73 fCacher->fMutexForGenerator.release(); 76 fCacher->fMutexForGenerator.release();
74 } 77 }
75 SkImageGenerator* operator->() const { return fCacher->fNotThreadSafeGen erator; } 78 SkImageGenerator* operator->() const { return fCacher->fNotThreadSafeGen erator; }
76 operator SkImageGenerator*() const { return fCacher->fNotThreadSafeGener ator; } 79 operator SkImageGenerator*() const { return fCacher->fNotThreadSafeGener ator; }
77 }; 80 };
78 81
79 SkMutex fMutexForGenerator; 82 SkMutex fMutexForGenerator;
80 SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator; 83 SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator;
81 84
82 const SkImageInfo fInfo; 85 const SkImageInfo fInfo;
83 const SkIPoint fOrigin; 86 const SkIPoint fOrigin;
84 const uint32_t fUniqueID; 87 const uint32_t fUniqueID;
85 88
86 friend class Cacherator_GrTextureMaker; 89 friend class Cacherator_GrTextureParamsAdjuster;
87 }; 90 };
88 91
89 #endif 92 #endif
OLDNEW
« no previous file with comments | « include/gpu/SkGr.h ('k') | src/core/SkImageCacherator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698