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

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

Issue 2462013003: Deferred image generator subsetting (Closed)
Patch Set: unlocked generator access comments Created 4 years, 1 month 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 | « no previous file | 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 "SkTemplates.h" 13 #include "SkTemplates.h"
13 14
14 class GrContext; 15 class GrContext;
15 class GrTextureParams; 16 class GrTextureParams;
16 class GrUniqueKey; 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.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 */ 63 */
63 SkData* refEncoded(GrContext*); 64 SkData* refEncoded(GrContext*);
64 65
65 // Only return true if the generate has already been cached. 66 // Only return true if the generate has already been cached.
66 bool lockAsBitmapOnlyIfAlreadyCached(SkBitmap*); 67 bool lockAsBitmapOnlyIfAlreadyCached(SkBitmap*);
67 // Call the underlying generator directly 68 // Call the underlying generator directly
68 bool directGeneratePixels(const SkImageInfo& dstInfo, void* dstPixels, size_ t dstRB, 69 bool directGeneratePixels(const SkImageInfo& dstInfo, void* dstPixels, size_ t dstRB,
69 int srcX, int srcY); 70 int srcX, int srcY);
70 71
71 private: 72 private:
72 class SharedGenerator; 73 // Ref-counted tuple(SkImageGenerator, SkMutex) which allows sharing of one generator
74 // among several cacherators.
75 class SharedGenerator final : public SkNVRefCnt<SharedGenerator> {
76 public:
77 static sk_sp<SharedGenerator> Make(SkImageGenerator* gen) {
78 return gen ? sk_sp<SharedGenerator>(new SharedGenerator(gen)) : null ptr;
79 }
80
81 private:
82 explicit SharedGenerator(SkImageGenerator* gen) : fGenerator(gen) { SkAS SERT(gen); }
83
84 friend class ScopedGenerator;
85 friend class SkImageCacherator;
86
87 std::unique_ptr<SkImageGenerator> fGenerator;
88 SkMutex fMutex;
89 };
73 class ScopedGenerator; 90 class ScopedGenerator;
74 91
75 struct Validator { 92 struct Validator {
76 Validator(SkImageGenerator*, const SkIRect* subset); 93 Validator(sk_sp<SharedGenerator>, const SkIRect* subset);
77 ~Validator();
78 94
79 operator bool() const { return fSharedGenerator.get(); } 95 operator bool() const { return fSharedGenerator.get(); }
80 96
81 sk_sp<SharedGenerator> fSharedGenerator; 97 sk_sp<SharedGenerator> fSharedGenerator;
82 SkImageInfo fInfo; 98 SkImageInfo fInfo;
83 SkIPoint fOrigin; 99 SkIPoint fOrigin;
84 uint32_t fUniqueID; 100 uint32_t fUniqueID;
85 }; 101 };
86 102
87 SkImageCacherator(Validator*); 103 SkImageCacherator(Validator*);
(...skipping 11 matching lines...) Expand all
99 const SkImageInfo fInfo; 115 const SkImageInfo fInfo;
100 const SkIPoint fOrigin; 116 const SkIPoint fOrigin;
101 const uint32_t fUniqueID; 117 const uint32_t fUniqueID;
102 118
103 friend class GrImageTextureMaker; 119 friend class GrImageTextureMaker;
104 friend class SkImage; 120 friend class SkImage;
105 friend class SkImage_Generator; 121 friend class SkImage_Generator;
106 }; 122 };
107 123
108 #endif 124 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkImageCacherator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698