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

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

Issue 2453473004: Avoid separate allocation of SkImageCacherator (Closed)
Patch Set: pass validator to ctor 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') | src/image/SkImage_Generator.cpp » ('J')
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
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 */ 61 */
62 SkData* refEncoded(GrContext*); 62 SkData* refEncoded(GrContext*);
63 63
64 // Only return true if the generate has already been cached. 64 // Only return true if the generate has already been cached.
65 bool lockAsBitmapOnlyIfAlreadyCached(SkBitmap*); 65 bool lockAsBitmapOnlyIfAlreadyCached(SkBitmap*);
66 // Call the underlying generator directly 66 // Call the underlying generator directly
67 bool directGeneratePixels(const SkImageInfo& dstInfo, void* dstPixels, size_ t dstRB, 67 bool directGeneratePixels(const SkImageInfo& dstInfo, void* dstPixels, size_ t dstRB,
68 int srcX, int srcY); 68 int srcX, int srcY);
69 69
70 private: 70 private:
71 SkImageCacherator(SkImageGenerator*, const SkImageInfo&, const SkIPoint&, ui nt32_t uniqueID); 71 struct Validator {
72 Validator(SkImageGenerator*, const SkIRect* subset);
73
74 operator bool() const { return fGenerator.get(); }
75
76 std::unique_ptr<SkImageGenerator> fGenerator;
77 SkImageInfo fInfo;
78 SkIPoint fOrigin;
79 uint32_t fUniqueID;
80 };
81
82 SkImageCacherator(Validator*);
72 83
73 bool generateBitmap(SkBitmap*); 84 bool generateBitmap(SkBitmap*);
74 bool tryLockAsBitmap(SkBitmap*, const SkImage*, SkImage::CachingHint); 85 bool tryLockAsBitmap(SkBitmap*, const SkImage*, SkImage::CachingHint);
75 #if SK_SUPPORT_GPU 86 #if SK_SUPPORT_GPU
76 // Returns the texture. If the cacherator is generating the texture and want s to cache it, 87 // Returns the texture. If the cacherator is generating the texture and want s to cache it,
77 // it should use the passed in key (if the key is valid). 88 // it should use the passed in key (if the key is valid).
78 GrTexture* lockTexture(GrContext*, const GrUniqueKey& key, const SkImage* cl ient, 89 GrTexture* lockTexture(GrContext*, const GrUniqueKey& key, const SkImage* cl ient,
79 SkImage::CachingHint, bool willBeMipped, SkSourceGamm aTreatment); 90 SkImage::CachingHint, bool willBeMipped, SkSourceGamm aTreatment);
80 #endif 91 #endif
81 92
(...skipping 11 matching lines...) Expand all
93 }; 104 };
94 105
95 SkMutex fMutexForGenerator; 106 SkMutex fMutexForGenerator;
96 SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator; 107 SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator;
97 108
98 const SkImageInfo fInfo; 109 const SkImageInfo fInfo;
99 const SkIPoint fOrigin; 110 const SkIPoint fOrigin;
100 const uint32_t fUniqueID; 111 const uint32_t fUniqueID;
101 112
102 friend class GrImageTextureMaker; 113 friend class GrImageTextureMaker;
114 friend class SkImage;
115 friend class SkImage_Generator;
103 }; 116 };
104 117
105 #endif 118 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkImageCacherator.cpp » ('j') | src/image/SkImage_Generator.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698