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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Pattern.h

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
4 * Copyright (C) 2007-2008 Torch Mobile, Inc. 4 * Copyright (C) 2007-2008 Torch Mobile, Inc.
5 * Copyright (C) 2013 Google, Inc. All rights reserved. 5 * Copyright (C) 2013 Google, Inc. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 13 matching lines...) Expand all
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef Pattern_h 29 #ifndef Pattern_h
30 #define Pattern_h 30 #define Pattern_h
31 31
32 #include "platform/PlatformExport.h" 32 #include "platform/PlatformExport.h"
33 #include "platform/graphics/Image.h" 33 #include "platform/graphics/Image.h"
34 #include "skia/ext/cdl_common.h"
34 #include "third_party/skia/include/core/SkRefCnt.h" 35 #include "third_party/skia/include/core/SkRefCnt.h"
35 36
36 #include "wtf/Noncopyable.h" 37 #include "wtf/Noncopyable.h"
37 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
38 #include "wtf/RefCounted.h" 39 #include "wtf/RefCounted.h"
39 40
40 class SkMatrix; 41 class SkMatrix;
41 class SkPaint;
42 class SkPicture;
43 42
44 namespace blink { 43 namespace blink {
45 44
46 class PLATFORM_EXPORT Pattern : public RefCounted<Pattern> { 45 class PLATFORM_EXPORT Pattern : public RefCounted<Pattern> {
47 WTF_MAKE_NONCOPYABLE(Pattern); 46 WTF_MAKE_NONCOPYABLE(Pattern);
48 47
49 public: 48 public:
50 enum RepeatMode { 49 enum RepeatMode {
51 RepeatModeX = 1 << 0, 50 RepeatModeX = 1 << 0,
52 RepeatModeY = 1 << 1, 51 RepeatModeY = 1 << 1,
53 52
54 RepeatModeNone = 0, 53 RepeatModeNone = 0,
55 RepeatModeXY = RepeatModeX | RepeatModeY 54 RepeatModeXY = RepeatModeX | RepeatModeY
56 }; 55 };
57 56
58 static PassRefPtr<Pattern> createImagePattern(PassRefPtr<Image>, 57 static PassRefPtr<Pattern> createImagePattern(PassRefPtr<Image>,
59 RepeatMode = RepeatModeXY); 58 RepeatMode = RepeatModeXY);
60 static PassRefPtr<Pattern> createPicturePattern(sk_sp<SkPicture>, 59 static PassRefPtr<Pattern> createPicturePattern(sk_sp<CdlPicture>,
61 RepeatMode = RepeatModeXY); 60 RepeatMode = RepeatModeXY);
62 virtual ~Pattern(); 61 virtual ~Pattern();
63 62
64 void applyToPaint(SkPaint&, const SkMatrix&); 63 void applyToPaint(CdlPaint&, const SkMatrix&);
65 64
66 bool isRepeatX() const { return m_repeatMode & RepeatModeX; } 65 bool isRepeatX() const { return m_repeatMode & RepeatModeX; }
67 bool isRepeatY() const { return m_repeatMode & RepeatModeY; } 66 bool isRepeatY() const { return m_repeatMode & RepeatModeY; }
68 bool isRepeatXY() const { return m_repeatMode == RepeatModeXY; } 67 bool isRepeatXY() const { return m_repeatMode == RepeatModeXY; }
69 68
70 virtual bool isTextureBacked() const { return false; } 69 virtual bool isTextureBacked() const { return false; }
71 70
72 protected: 71 protected:
73 virtual sk_sp<SkShader> createShader(const SkMatrix&) = 0; 72 virtual sk_sp<CdlShader> createShader(const SkMatrix&) = 0;
74 virtual bool isLocalMatrixChanged(const SkMatrix&) const; 73 virtual bool isLocalMatrixChanged(const SkMatrix&) const;
75 74
76 void adjustExternalMemoryAllocated(int64_t delta); 75 void adjustExternalMemoryAllocated(int64_t delta);
77 76
78 RepeatMode m_repeatMode; 77 RepeatMode m_repeatMode;
79 78
80 Pattern(RepeatMode, int64_t externalMemoryAllocated = 0); 79 Pattern(RepeatMode, int64_t externalMemoryAllocated = 0);
81 mutable sk_sp<SkShader> m_cachedShader; 80 mutable sk_sp<CdlShader> m_cachedShader;
82 81
83 private: 82 private:
84 int64_t m_externalMemoryAllocated; 83 int64_t m_externalMemoryAllocated;
85 }; 84 };
86 85
87 } // namespace blink 86 } // namespace blink
88 87
89 #endif 88 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Path.cpp ('k') | third_party/WebKit/Source/platform/graphics/Pattern.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698