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

Unified Diff: third_party/WebKit/Source/platform/graphics/FrameData.h

Issue 1331533002: [poc] curve-filter Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix CanvasRenderingContext2D::createPattern crash for #40 Created 4 years, 11 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
Index: third_party/WebKit/Source/platform/graphics/FrameData.h
diff --git a/third_party/WebKit/Source/platform/graphics/FrameData.h b/third_party/WebKit/Source/platform/graphics/FrameData.h
index e64c9318bd54efa3417f2bfbbe91dfd52d9bc8f2..04324fe8845328051bb044f8f13f8cde5ae77aab 100644
--- a/third_party/WebKit/Source/platform/graphics/FrameData.h
+++ b/third_party/WebKit/Source/platform/graphics/FrameData.h
@@ -28,12 +28,44 @@
#ifndef FrameData_h
#define FrameData_h
+#include "platform/graphics/ColorSpaceFilter.h"
#include "platform/graphics/ImageOrientation.h"
+#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkImage.h"
+#include "third_party/skia/include/core/SkPicture.h"
#include "wtf/Allocator.h"
+#include "wtf/HashMap.h"
+#include "wtf/MainThread.h"
#include "wtf/Noncopyable.h"
#include "wtf/RefPtr.h"
#include "wtf/VectorTraits.h"
+#include "wtf/text/StringHash.h"
+#include "wtf/text/WTFString.h"
+
+class ColorTransformImageCache {
+ WTF_MAKE_NONCOPYABLE(ColorTransformImageCache);
+public:
+ ColorTransformImageCache() { }
+
+ void set(const String& key, SkImage* image)
+ {
+ m_colorImages.set(key, image);
+ }
+
+ PassRefPtr<SkImage> find(const String& key) const
+ {
+ HashMap<String, RefPtr<SkImage>>::const_iterator it = m_colorImages.find(key);
+ return it != m_colorImages.end() ? it->value : nullptr;
+ }
+
+ void clear()
+ {
+ m_colorImages.clear();
+ }
+
+private:
+ HashMap<String, RefPtr<SkImage>> m_colorImages;
+};
namespace blink {
@@ -44,11 +76,28 @@ public:
FrameData();
~FrameData();
+ PassRefPtr<SkImage> find(SkColorFilter* transform)
+ {
+ return cache().find(colorSpaceFilterKey(transform));
+ }
+
+ void cache(SkColorFilter* transform, SkImage* image)
+ {
+ cache().set(colorSpaceFilterKey(transform), image);
+ }
+
+ ColorTransformImageCache& cache()
+ {
+ RELEASE_ASSERT(isMainThread());
+ return m_cache;
+ }
+
// Clear the cached image data on the frame, and (optionally) the metadata.
// Returns whether there was cached image data to clear.
bool clear(bool clearMetadata);
RefPtr<SkImage> m_frame;
+ ColorTransformImageCache m_cache;
ImageOrientation m_orientation;
float m_duration;
bool m_haveMetadata : 1;

Powered by Google App Engine
This is Rietveld 408576698