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

Unified Diff: src/core/SkImageCacherator.h

Issue 2451273006: Shared image generator (Closed)
Patch Set: cleanup Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkImageCacherator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageCacherator.h
diff --git a/src/core/SkImageCacherator.h b/src/core/SkImageCacherator.h
index 2d9e94cc4d7f9bc7b1e3a439f69eebe3a636b800..cd5ac9ba09b6b6c0f9c0d8336cef88f0dad5fe83 100644
--- a/src/core/SkImageCacherator.h
+++ b/src/core/SkImageCacherator.h
@@ -9,7 +9,6 @@
#define SkImageCacherator_DEFINED
#include "SkImageGenerator.h"
-#include "SkMutex.h"
#include "SkTemplates.h"
class GrContext;
@@ -26,6 +25,8 @@ public:
// Takes ownership of the generator
static SkImageCacherator* NewFromGenerator(SkImageGenerator*, const SkIRect* subset = nullptr);
+ ~SkImageCacherator();
+
const SkImageInfo& info() const { return fInfo; }
uint32_t uniqueID() const { return fUniqueID; }
@@ -68,15 +69,19 @@ public:
int srcX, int srcY);
private:
+ class SharedGenerator;
+ class ScopedGenerator;
+
struct Validator {
Validator(SkImageGenerator*, const SkIRect* subset);
+ ~Validator();
- operator bool() const { return fGenerator.get(); }
+ operator bool() const { return fSharedGenerator.get(); }
- std::unique_ptr<SkImageGenerator> fGenerator;
- SkImageInfo fInfo;
- SkIPoint fOrigin;
- uint32_t fUniqueID;
+ sk_sp<SharedGenerator> fSharedGenerator;
+ SkImageInfo fInfo;
+ SkIPoint fOrigin;
+ uint32_t fUniqueID;
};
SkImageCacherator(Validator*);
@@ -90,25 +95,10 @@ private:
SkImage::CachingHint, bool willBeMipped, SkSourceGammaTreatment);
#endif
- class ScopedGenerator {
- SkImageCacherator* fCacher;
- public:
- ScopedGenerator(SkImageCacherator* cacher) : fCacher(cacher) {
- fCacher->fMutexForGenerator.acquire();
- }
- ~ScopedGenerator() {
- fCacher->fMutexForGenerator.release();
- }
- SkImageGenerator* operator->() const { return fCacher->fNotThreadSafeGenerator; }
- operator SkImageGenerator*() const { return fCacher->fNotThreadSafeGenerator; }
- };
-
- SkMutex fMutexForGenerator;
- SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator;
-
- const SkImageInfo fInfo;
- const SkIPoint fOrigin;
- const uint32_t fUniqueID;
+ sk_sp<SharedGenerator> fSharedGenerator;
+ const SkImageInfo fInfo;
+ const SkIPoint fOrigin;
+ const uint32_t fUniqueID;
friend class GrImageTextureMaker;
friend class SkImage;
« 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