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

Unified Diff: src/core/SkGlyphCache.h

Issue 1711223003: Only use fake gamma with linear devices. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Formatting. Created 4 years, 10 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 | « src/core/SkDraw.cpp ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkGlyphCache.h
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h
index cd0b05c6e960adc862d94946efa95046c8dafb23..2c49530e7c72ab5ac7adaa6a7e1023c4476dda41 100644
--- a/src/core/SkGlyphCache.h
+++ b/src/core/SkGlyphCache.h
@@ -11,12 +11,12 @@
#include "SkChunkAlloc.h"
#include "SkDescriptor.h"
#include "SkGlyph.h"
+#include "SkPaint.h"
#include "SkTHash.h"
#include "SkScalerContext.h"
#include "SkTemplates.h"
#include "SkTDArray.h"
-class SkPaint;
class SkTraceMemoryDump;
class SkGlyphCache_Globals;
@@ -137,6 +137,7 @@ public:
the global cache list (after which the caller should not reference it anymore.
*/
static void AttachCache(SkGlyphCache*);
+ using AttachCacheFunctor = SkFunctionWrapper<void, SkGlyphCache, AttachCache>;
/** Detach a strike from the global cache matching the specified descriptor. Once detached,
it can be queried/modified by the current thread, and when finished, be reattached to the
@@ -271,74 +272,40 @@ private:
AuxProcRec* fAuxProcList;
};
-class SkAutoGlyphCacheBase {
+class SkAutoGlyphCache : public skstd::unique_ptr<SkGlyphCache, SkGlyphCache::AttachCacheFunctor> {
public:
- SkGlyphCache* getCache() const { return fCache; }
-
- void release() {
- if (fCache) {
- SkGlyphCache::AttachCache(fCache);
- fCache = nullptr;
- }
- }
-
-protected:
- // Hide the constructors so we can't create one of these directly. Create SkAutoGlyphCache or
- // SkAutoGlyphCacheNoCache instead.
- SkAutoGlyphCacheBase(SkGlyphCache* cache) : fCache(cache) {}
- SkAutoGlyphCacheBase(SkTypeface* typeface, const SkDescriptor* desc) {
- fCache = SkGlyphCache::DetachCache(typeface, desc);
- }
- SkAutoGlyphCacheBase(const SkPaint& /*paint*/,
- const SkSurfaceProps* /*surfaceProps*/,
- const SkMatrix* /*matrix*/) {
- fCache = nullptr;
- }
- SkAutoGlyphCacheBase() {
- fCache = nullptr;
- }
- ~SkAutoGlyphCacheBase() {
- if (fCache) {
- SkGlyphCache::AttachCache(fCache);
- }
- }
-
- SkGlyphCache* fCache;
-
-private:
- static bool DetachProc(const SkGlyphCache*, void*);
-};
-
-class SkAutoGlyphCache : public SkAutoGlyphCacheBase {
-public:
- SkAutoGlyphCache(SkGlyphCache* cache) : SkAutoGlyphCacheBase(cache) {}
- SkAutoGlyphCache(SkTypeface* typeface, const SkDescriptor* desc) :
- SkAutoGlyphCacheBase(typeface, desc) {}
+ /** deprecated: use get() */
+ SkGlyphCache* getCache() const { return this->get(); }
+
+ SkAutoGlyphCache(SkGlyphCache* cache) : INHERITED(cache) {}
+ SkAutoGlyphCache(SkTypeface* typeface, const SkDescriptor* desc)
+ : INHERITED(SkGlyphCache::DetachCache(typeface, desc))
+ {}
+ /** deprecated: always enables fake gamma */
SkAutoGlyphCache(const SkPaint& paint,
const SkSurfaceProps* surfaceProps,
- const SkMatrix* matrix) {
- fCache = paint.detachCache(surfaceProps, matrix, false);
- }
-
+ const SkMatrix* matrix)
+ : INHERITED(paint.detachCache(surfaceProps, SkPaint::FakeGamma::On, matrix))
+ {}
+ SkAutoGlyphCache(const SkPaint& paint,
+ const SkSurfaceProps* surfaceProps,
+ SkPaint::FakeGamma fakeGamma,
+ const SkMatrix* matrix)
+ : INHERITED(paint.detachCache(surfaceProps, fakeGamma, matrix))
+ {}
private:
- SkAutoGlyphCache() : SkAutoGlyphCacheBase() {}
+ using INHERITED = skstd::unique_ptr<SkGlyphCache, SkGlyphCache::AttachCacheFunctor>;
};
-#define SkAutoGlyphCache(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCache)
-class SkAutoGlyphCacheNoGamma : public SkAutoGlyphCacheBase {
+class SkAutoGlyphCacheNoGamma : public SkAutoGlyphCache {
public:
- SkAutoGlyphCacheNoGamma(SkGlyphCache* cache) : SkAutoGlyphCacheBase(cache) {}
- SkAutoGlyphCacheNoGamma(SkTypeface* typeface, const SkDescriptor* desc) :
- SkAutoGlyphCacheBase(typeface, desc) {}
SkAutoGlyphCacheNoGamma(const SkPaint& paint,
const SkSurfaceProps* surfaceProps,
- const SkMatrix* matrix) {
- fCache = paint.detachCache(surfaceProps, matrix, true);
- }
-
-private:
- SkAutoGlyphCacheNoGamma() : SkAutoGlyphCacheBase() {}
+ const SkMatrix* matrix)
+ : SkAutoGlyphCache(paint, surfaceProps, SkPaint::FakeGamma::Off, matrix)
+ {}
};
+#define SkAutoGlyphCache(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCache)
#define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamma)
#endif
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698