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

Unified Diff: Source/platform/graphics/Pattern.h

Issue 358893002: Use newImageSnapshot() to get an image from a Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Bitmap caching for Shaders/Patterns from StaticBitmapImage/SkImage Created 6 years, 4 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: Source/platform/graphics/Pattern.h
diff --git a/Source/platform/graphics/Pattern.h b/Source/platform/graphics/Pattern.h
index 3a2b89d5096d1466ee0aac8668f6339ac3d5448b..7e5884c0bdd596526241e68babb955f11f486ffe 100644
--- a/Source/platform/graphics/Pattern.h
+++ b/Source/platform/graphics/Pattern.h
@@ -40,35 +40,53 @@
namespace blink {
-class AffineTransform;
-
class PLATFORM_EXPORT Pattern : public RefCounted<Pattern> {
public:
- static PassRefPtr<Pattern> create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY)
- {
- return adoptRef(new Pattern(tileImage, repeatX, repeatY));
- }
- ~Pattern();
+ static PassRefPtr<Pattern> create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY);
+
+ virtual ~Pattern();
- SkShader* shader();
+ SkShader* shader(SkShader::ShaderLocation preferredLocation = SkShader::kKeep_ShaderLocation);
void setPatternSpaceTransform(const AffineTransform& patternSpaceTransformation);
- const AffineTransform& getPatternSpaceTransform() { return m_patternSpaceTransformation; };
+ const AffineTransform& getPatternSpaceTransform() { return m_patternSpaceTransformation; }
bool repeatX() const { return m_repeatX; }
bool repeatY() const { return m_repeatY; }
+protected:
+ virtual PassRefPtr<SkShader> createShader(SkShader::ShaderLocation preferredLocation) = 0;
-private:
- Pattern(PassRefPtr<Image>, bool repeatX, bool repeatY);
+ Pattern(bool repeatX, bool repeatY, int64_t externalMemoryAllocated = 0)
+ : m_repeatX(repeatX)
+ , m_repeatY(repeatY)
+ , m_externalMemoryAllocated(0)
+ {
+ adjustExternalMemoryAllocated(externalMemoryAllocated);
+ }
- RefPtr<NativeImageSkia> m_tileImage;
bool m_repeatX;
bool m_repeatY;
AffineTransform m_patternSpaceTransformation;
+
+ void adjustExternalMemoryAllocated(int64_t delta);
+
+private:
RefPtr<SkShader> m_pattern;
- int m_externalMemoryAllocated;
+ int64_t m_externalMemoryAllocated;
+};
+
+class BitmapBackedPattern : public Pattern {
Justin Novosad 2014/08/05 17:31:26 This should be in its own header and I think it sh
Rémi Piotaix 2014/08/06 18:09:14 Done.
+public:
+ BitmapBackedPattern(bool repeatX, bool repeatY, int64_t externalMemoryAllocated = 0);
+ virtual ~BitmapBackedPattern();
+
+ virtual PassRefPtr<SkShader> createShader(SkShader::ShaderLocation preferredLocation) OVERRIDE;
+
+protected:
+ virtual SkImageInfo getBitmapInfo() = 0;
+ virtual void drawBitmapToCanvas(SkCanvas&, SkPaint&) = 0;
};
-} //namespace
+} // namespace
#endif

Powered by Google App Engine
This is Rietveld 408576698