| 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(); }
|
|
|
|
|