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

Unified 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 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 cd5ac9ba09b6b6c0f9c0d8336cef88f0dad5fe83..8bf335bf512ad20b754f3b0ba5b0f137c5aa5f1a 100644
--- a/src/core/SkImageCacherator.h
+++ b/src/core/SkImageCacherator.h
@@ -9,6 +9,7 @@
#define SkImageCacherator_DEFINED
#include "SkImageGenerator.h"
+#include "SkMutex.h"
#include "SkTemplates.h"
class GrContext;
@@ -69,12 +70,27 @@ public:
int srcX, int srcY);
private:
- class SharedGenerator;
+ // Ref-counted tuple(SkImageGenerator, SkMutex) which allows sharing of one generator
+ // among several cacherators.
+ class SharedGenerator final : public SkNVRefCnt<SharedGenerator> {
+ public:
+ static sk_sp<SharedGenerator> Make(SkImageGenerator* gen) {
+ return gen ? sk_sp<SharedGenerator>(new SharedGenerator(gen)) : nullptr;
+ }
+
+ private:
+ explicit SharedGenerator(SkImageGenerator* gen) : fGenerator(gen) { SkASSERT(gen); }
+
+ friend class ScopedGenerator;
+ friend class SkImageCacherator;
+
+ std::unique_ptr<SkImageGenerator> fGenerator;
+ SkMutex fMutex;
+ };
class ScopedGenerator;
struct Validator {
- Validator(SkImageGenerator*, const SkIRect* subset);
- ~Validator();
+ Validator(sk_sp<SharedGenerator>, const SkIRect* subset);
operator bool() const { return fSharedGenerator.get(); }
« 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