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

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: 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
« no previous file with comments | « Source/core/platform/graphics/GraphicsContext.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 19 matching lines...) Expand all
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
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/core/SkRefCnt.h"
40 #include "third_party/skia/include/effects/SkDashPathEffect.h" 41 #include "third_party/skia/include/effects/SkDashPathEffect.h"
41 42
42 #include "wtf/PassOwnPtr.h" 43 #include "wtf/PassOwnPtr.h"
43 44
44 namespace WebCore { 45 namespace WebCore {
45 46
46 // Encapsulates the state information we store for each pushed graphics state. 47 // Encapsulates the state information we store for each pushed graphics state.
47 // Only GraphicsContext can use this class. 48 // Only GraphicsContext can use this class.
48 class GraphicsContextState { 49 class GraphicsContextState {
49 public: 50 public:
50 ~GraphicsContextState() 51 ~GraphicsContextState() { }
51 {
52 SkSafeUnref(m_looper);
53 }
54 52
55 private: 53 private:
56 friend class GraphicsContext; 54 friend class GraphicsContext;
57 55
58 GraphicsContextState() 56 GraphicsContextState()
59 : m_fillColor(Color::black) 57 : m_fillColor(Color::black)
60 , m_fillRule(RULE_NONZERO) 58 , m_fillRule(RULE_NONZERO)
61 , m_looper(0)
62 , m_textDrawingMode(TextModeFill) 59 , m_textDrawingMode(TextModeFill)
63 , m_alpha(1) 60 , m_alpha(1)
64 , m_xferMode(SkXfermode::kSrcOver_Mode) 61 , m_xferMode(SkXfermode::kSrcOver_Mode)
65 , m_compositeOperator(CompositeSourceOver) 62 , m_compositeOperator(CompositeSourceOver)
66 , m_blendMode(BlendModeNormal) 63 , m_blendMode(BlendModeNormal)
67 , m_clip(SkRect::MakeEmpty()) 64 , m_clip(SkRect::MakeEmpty())
68 #if USE(LOW_QUALITY_IMAGE_INTERPOLATION) 65 #if USE(LOW_QUALITY_IMAGE_INTERPOLATION)
69 , m_interpolationQuality(InterpolationLow) 66 , m_interpolationQuality(InterpolationLow)
70 #else 67 #else
71 , m_interpolationQuality(InterpolationHigh) 68 , m_interpolationQuality(InterpolationHigh)
(...skipping 16 matching lines...) Expand all
88 , m_xferMode(other.m_xferMode) 85 , m_xferMode(other.m_xferMode)
89 , m_compositeOperator(other.m_compositeOperator) 86 , m_compositeOperator(other.m_compositeOperator)
90 , m_blendMode(other.m_blendMode) 87 , m_blendMode(other.m_blendMode)
91 , m_imageBufferClip(other.m_imageBufferClip) 88 , m_imageBufferClip(other.m_imageBufferClip)
92 , m_clip(other.m_clip) 89 , m_clip(other.m_clip)
93 , m_interpolationQuality(other.m_interpolationQuality) 90 , m_interpolationQuality(other.m_interpolationQuality)
94 , m_shouldAntialias(other.m_shouldAntialias) 91 , m_shouldAntialias(other.m_shouldAntialias)
95 , m_shouldSmoothFonts(other.m_shouldSmoothFonts) 92 , m_shouldSmoothFonts(other.m_shouldSmoothFonts)
96 , m_shadowsIgnoreTransforms(other.m_shadowsIgnoreTransforms) 93 , m_shadowsIgnoreTransforms(other.m_shadowsIgnoreTransforms)
97 { 94 {
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 95 // The clip image only needs to be applied once. Reset the image so that we
102 // don't attempt to clip multiple times. 96 // don't attempt to clip multiple times.
103 m_imageBufferClip.reset(); 97 m_imageBufferClip.reset();
104 } 98 }
105 99
106 // Helper function for applying the state's alpha value to the given input 100 // Helper function for applying the state's alpha value to the given input
107 // color to produce a new output color. 101 // color to produce a new output color.
108 SkColor applyAlpha(SkColor c) const 102 SkColor applyAlpha(SkColor c) const
109 { 103 {
110 int s = roundf(m_alpha * 256); 104 int s = roundf(m_alpha * 256);
(...skipping 15 matching lines...) Expand all
126 // Stroke. 120 // Stroke.
127 StrokeData m_strokeData; 121 StrokeData m_strokeData;
128 122
129 // Fill. 123 // Fill.
130 Color m_fillColor; 124 Color m_fillColor;
131 WindRule m_fillRule; 125 WindRule m_fillRule;
132 RefPtr<Gradient> m_fillGradient; 126 RefPtr<Gradient> m_fillGradient;
133 RefPtr<Pattern> m_fillPattern; 127 RefPtr<Pattern> m_fillPattern;
134 128
135 // Shadow. (This will need tweaking if we use draw loopers for other things. ) 129 // Shadow. (This will need tweaking if we use draw loopers for other things. )
136 SkDrawLooper* m_looper; 130 SkRefPtr<SkDrawLooper> m_looper;
danakj 2013/06/19 15:47:13 I believe you want to use SKAutoTUnref instead. Sk
137 131
138 // Text. (See TextModeFill & friends.) 132 // Text. (See TextModeFill & friends.)
139 TextDrawingModeFlags m_textDrawingMode; 133 TextDrawingModeFlags m_textDrawingMode;
140 134
141 // Common shader state. 135 // Common shader state.
142 float m_alpha; 136 float m_alpha;
143 SkXfermode::Mode m_xferMode; 137 SkXfermode::Mode m_xferMode;
144 138
145 // Compositing control, for the CSS and Canvas compositing spec. 139 // Compositing control, for the CSS and Canvas compositing spec.
146 CompositeOperator m_compositeOperator; 140 CompositeOperator m_compositeOperator;
(...skipping 10 matching lines...) Expand all
157 151
158 bool m_shouldAntialias : 1; 152 bool m_shouldAntialias : 1;
159 bool m_shouldSmoothFonts : 1; 153 bool m_shouldSmoothFonts : 1;
160 bool m_shadowsIgnoreTransforms : 1; 154 bool m_shadowsIgnoreTransforms : 1;
161 }; 155 };
162 156
163 } // namespace WebCore 157 } // namespace WebCore
164 158
165 #endif // GraphicsContextState_h 159 #endif // GraphicsContextState_h
166 160
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/GraphicsContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698