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

Side by Side Diff: Source/core/platform/graphics/GraphicsContextState.h

Issue 17448009: Use skia::RefPtr to avoid having to manually refcount GraphicsContextState::m_looper. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: switch to skia::RefPtr, remove superfluous copy of m_imageBufferClip Created 7 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (C) 2013 Google Inc. All rights reserved. 1 // Copyright (C) 2013 Google Inc. All rights reserved.
2 // 2 //
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer 10 // copyright notice, this list of conditions and the following disclaimer
(...skipping 16 matching lines...) Expand all
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 #ifndef GraphicsContextState_h 29 #ifndef GraphicsContextState_h
30 #define GraphicsContextState_h 30 #define GraphicsContextState_h
31 31
32 #include "core/platform/graphics/Gradient.h" 32 #include "core/platform/graphics/Gradient.h"
33 #include "core/platform/graphics/GraphicsTypes.h" 33 #include "core/platform/graphics/GraphicsTypes.h"
34 #include "core/platform/graphics/Path.h" 34 #include "core/platform/graphics/Path.h"
35 #include "core/platform/graphics/Pattern.h" 35 #include "core/platform/graphics/Pattern.h"
36 #include "core/platform/graphics/StrokeData.h" 36 #include "core/platform/graphics/StrokeData.h"
37 37 #include "skia/ext/refptr.h"
38 #include "third_party/skia/include/core/SkColorPriv.h" 38 #include "third_party/skia/include/core/SkColorPriv.h"
39 #include "third_party/skia/include/core/SkDrawLooper.h" 39 #include "third_party/skia/include/core/SkDrawLooper.h"
40 #include "third_party/skia/include/effects/SkDashPathEffect.h" 40 #include "third_party/skia/include/effects/SkDashPathEffect.h"
41
42 #include "wtf/PassOwnPtr.h" 41 #include "wtf/PassOwnPtr.h"
43 42
44 namespace WebCore { 43 namespace WebCore {
45 44
46 // Encapsulates the state information we store for each pushed graphics state. 45 // Encapsulates the state information we store for each pushed graphics state.
47 // Only GraphicsContext can use this class. 46 // Only GraphicsContext can use this class.
48 class GraphicsContextState { 47 class GraphicsContextState {
49 public: 48 public:
50 ~GraphicsContextState() 49 ~GraphicsContextState() { }
51 {
52 SkSafeUnref(m_looper);
53 }
54 50
55 private: 51 private:
56 friend class GraphicsContext; 52 friend class GraphicsContext;
57 53
58 GraphicsContextState() 54 GraphicsContextState()
59 : m_fillColor(Color::black) 55 : m_fillColor(Color::black)
60 , m_fillRule(RULE_NONZERO) 56 , m_fillRule(RULE_NONZERO)
61 , m_looper(0)
62 , m_textDrawingMode(TextModeFill) 57 , m_textDrawingMode(TextModeFill)
63 , m_alpha(1) 58 , m_alpha(1)
64 , m_xferMode(SkXfermode::kSrcOver_Mode) 59 , m_xferMode(SkXfermode::kSrcOver_Mode)
65 , m_compositeOperator(CompositeSourceOver) 60 , m_compositeOperator(CompositeSourceOver)
66 , m_blendMode(BlendModeNormal) 61 , m_blendMode(BlendModeNormal)
67 , m_clip(SkRect::MakeEmpty()) 62 , m_clip(SkRect::MakeEmpty())
68 #if USE(LOW_QUALITY_IMAGE_INTERPOLATION) 63 #if USE(LOW_QUALITY_IMAGE_INTERPOLATION)
69 , m_interpolationQuality(InterpolationLow) 64 , m_interpolationQuality(InterpolationLow)
70 #else 65 #else
71 , m_interpolationQuality(InterpolationHigh) 66 , m_interpolationQuality(InterpolationHigh)
72 #endif 67 #endif
73 , m_shouldAntialias(true) 68 , m_shouldAntialias(true)
74 , m_shouldSmoothFonts(true) 69 , m_shouldSmoothFonts(true)
75 , m_shadowsIgnoreTransforms(false) 70 , m_shadowsIgnoreTransforms(false)
76 { 71 {
77 } 72 }
78 73
79 GraphicsContextState(const GraphicsContextState& other) 74 GraphicsContextState(const GraphicsContextState& other)
80 : m_strokeData(other.m_strokeData) 75 : m_strokeData(other.m_strokeData)
81 , m_fillColor(other.m_fillColor) 76 , m_fillColor(other.m_fillColor)
82 , m_fillRule(other.m_fillRule) 77 , m_fillRule(other.m_fillRule)
83 , m_fillGradient(other.m_fillGradient) 78 , m_fillGradient(other.m_fillGradient)
84 , m_fillPattern(other.m_fillPattern) 79 , m_fillPattern(other.m_fillPattern)
85 , m_looper(other.m_looper) 80 , m_looper(other.m_looper)
86 , m_textDrawingMode(other.m_textDrawingMode) 81 , m_textDrawingMode(other.m_textDrawingMode)
87 , m_alpha(other.m_alpha) 82 , m_alpha(other.m_alpha)
88 , m_xferMode(other.m_xferMode) 83 , m_xferMode(other.m_xferMode)
89 , m_compositeOperator(other.m_compositeOperator) 84 , m_compositeOperator(other.m_compositeOperator)
90 , m_blendMode(other.m_blendMode) 85 , m_blendMode(other.m_blendMode)
91 , m_imageBufferClip(other.m_imageBufferClip)
92 , m_clip(other.m_clip) 86 , m_clip(other.m_clip)
93 , m_interpolationQuality(other.m_interpolationQuality) 87 , m_interpolationQuality(other.m_interpolationQuality)
94 , m_shouldAntialias(other.m_shouldAntialias) 88 , m_shouldAntialias(other.m_shouldAntialias)
95 , m_shouldSmoothFonts(other.m_shouldSmoothFonts) 89 , m_shouldSmoothFonts(other.m_shouldSmoothFonts)
96 , m_shadowsIgnoreTransforms(other.m_shadowsIgnoreTransforms) 90 , m_shadowsIgnoreTransforms(other.m_shadowsIgnoreTransforms)
97 { 91 {
98 // Up the ref count of these. SkSafeRef does nothing if its argument is 0.
99 SkSafeRef(m_looper);
100
101 // The clip image only needs to be applied once. Reset the image so that we
102 // don't attempt to clip multiple times.
103 m_imageBufferClip.reset();
104 } 92 }
105 93
106 // Helper function for applying the state's alpha value to the given input 94 // Helper function for applying the state's alpha value to the given input
107 // color to produce a new output color. 95 // color to produce a new output color.
108 SkColor applyAlpha(SkColor c) const 96 SkColor applyAlpha(SkColor c) const
109 { 97 {
110 int s = roundf(m_alpha * 256); 98 int s = roundf(m_alpha * 256);
111 if (s >= 256) 99 if (s >= 256)
112 return c; 100 return c;
113 if (s < 0) 101 if (s < 0)
(...skipping 12 matching lines...) Expand all
126 // Stroke. 114 // Stroke.
127 StrokeData m_strokeData; 115 StrokeData m_strokeData;
128 116
129 // Fill. 117 // Fill.
130 Color m_fillColor; 118 Color m_fillColor;
131 WindRule m_fillRule; 119 WindRule m_fillRule;
132 RefPtr<Gradient> m_fillGradient; 120 RefPtr<Gradient> m_fillGradient;
133 RefPtr<Pattern> m_fillPattern; 121 RefPtr<Pattern> m_fillPattern;
134 122
135 // Shadow. (This will need tweaking if we use draw loopers for other things. ) 123 // Shadow. (This will need tweaking if we use draw loopers for other things. )
136 SkDrawLooper* m_looper; 124 skia::RefPtr<SkDrawLooper> m_looper;
137 125
138 // Text. (See TextModeFill & friends.) 126 // Text. (See TextModeFill & friends.)
139 TextDrawingModeFlags m_textDrawingMode; 127 TextDrawingModeFlags m_textDrawingMode;
140 128
141 // Common shader state. 129 // Common shader state.
142 float m_alpha; 130 float m_alpha;
143 SkXfermode::Mode m_xferMode; 131 SkXfermode::Mode m_xferMode;
144 132
145 // Compositing control, for the CSS and Canvas compositing spec. 133 // Compositing control, for the CSS and Canvas compositing spec.
146 CompositeOperator m_compositeOperator; 134 CompositeOperator m_compositeOperator;
(...skipping 10 matching lines...) Expand all
157 145
158 bool m_shouldAntialias : 1; 146 bool m_shouldAntialias : 1;
159 bool m_shouldSmoothFonts : 1; 147 bool m_shouldSmoothFonts : 1;
160 bool m_shadowsIgnoreTransforms : 1; 148 bool m_shadowsIgnoreTransforms : 1;
161 }; 149 };
162 150
163 } // namespace WebCore 151 } // namespace WebCore
164 152
165 #endif // GraphicsContextState_h 153 #endif // GraphicsContextState_h
166 154
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698