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

Side by Side Diff: Source/core/html/canvas/CanvasStyle.cpp

Issue 365653002: Oilpan: move 2D Canvas and WebGL objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Smaller adjustments Created 6 years, 5 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 /* 1 /*
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 { 105 {
106 } 106 }
107 107
108 CanvasStyle::CanvasStyle(float c, float m, float y, float k, float a) 108 CanvasStyle::CanvasStyle(float c, float m, float y, float k, float a)
109 : m_type(CMYKA) 109 : m_type(CMYKA)
110 , m_rgba(makeRGBAFromCMYKA(c, m, y, k, a)) 110 , m_rgba(makeRGBAFromCMYKA(c, m, y, k, a))
111 , m_cmyka(c, m, y, k, a) 111 , m_cmyka(c, m, y, k, a)
112 { 112 {
113 } 113 }
114 114
115 CanvasStyle::CanvasStyle(PassRefPtr<CanvasGradient> gradient) 115 CanvasStyle::CanvasStyle(PassRefPtrWillBeRawPtr<CanvasGradient> gradient)
116 : m_type(Gradient) 116 : m_type(Gradient)
117 , m_gradient(gradient) 117 , m_gradient(gradient)
118 { 118 {
119 } 119 }
120 120
121 CanvasStyle::CanvasStyle(PassRefPtr<CanvasPattern> pattern) 121 CanvasStyle::CanvasStyle(PassRefPtrWillBeRawPtr<CanvasPattern> pattern)
122 : m_type(ImagePattern) 122 : m_type(ImagePattern)
123 , m_pattern(pattern) 123 , m_pattern(pattern)
124 { 124 {
125 } 125 }
126 126
127 PassRefPtr<CanvasStyle> CanvasStyle::createFromString(const String& color) 127 PassRefPtrWillBeRawPtr<CanvasStyle> CanvasStyle::createFromString(const String& color)
128 { 128 {
129 RGBA32 rgba; 129 RGBA32 rgba;
130 ColorParseResult parseResult = parseColor(rgba, color); 130 ColorParseResult parseResult = parseColor(rgba, color);
131 switch (parseResult) { 131 switch (parseResult) {
132 case ParsedRGBA: 132 case ParsedRGBA:
133 case ParsedSystemColor: 133 case ParsedSystemColor:
134 return adoptRef(new CanvasStyle(rgba)); 134 return adoptRefWillBeNoop(new CanvasStyle(rgba));
135 case ParsedCurrentColor: 135 case ParsedCurrentColor:
136 return adoptRef(new CanvasStyle(CurrentColor)); 136 return adoptRefWillBeNoop(new CanvasStyle(CurrentColor));
137 case ParseFailed: 137 case ParseFailed:
138 return nullptr; 138 return nullptr;
139 default: 139 default:
140 ASSERT_NOT_REACHED(); 140 ASSERT_NOT_REACHED();
141 return nullptr; 141 return nullptr;
142 } 142 }
143 } 143 }
144 144
145 PassRefPtr<CanvasStyle> CanvasStyle::createFromStringWithOverrideAlpha(const Str ing& color, float alpha) 145 PassRefPtrWillBeRawPtr<CanvasStyle> CanvasStyle::createFromStringWithOverrideAlp ha(const String& color, float alpha)
146 { 146 {
147 RGBA32 rgba; 147 RGBA32 rgba;
148 ColorParseResult parseResult = parseColor(rgba, color); 148 ColorParseResult parseResult = parseColor(rgba, color);
149 switch (parseResult) { 149 switch (parseResult) {
150 case ParsedRGBA: 150 case ParsedRGBA:
151 return adoptRef(new CanvasStyle(colorWithOverrideAlpha(rgba, alpha))); 151 return adoptRefWillBeNoop(new CanvasStyle(colorWithOverrideAlpha(rgba, a lpha)));
152 case ParsedCurrentColor: 152 case ParsedCurrentColor:
153 return adoptRef(new CanvasStyle(CurrentColorWithOverrideAlpha, alpha)); 153 return adoptRefWillBeNoop(new CanvasStyle(CurrentColorWithOverrideAlpha, alpha));
154 case ParseFailed: 154 case ParseFailed:
155 return nullptr; 155 return nullptr;
156 default: 156 default:
157 ASSERT_NOT_REACHED(); 157 ASSERT_NOT_REACHED();
158 return nullptr; 158 return nullptr;
159 } 159 }
160 } 160 }
161 161
162 PassRefPtr<CanvasStyle> CanvasStyle::createFromGradient(PassRefPtr<CanvasGradien t> gradient) 162 PassRefPtrWillBeRawPtr<CanvasStyle> CanvasStyle::createFromGradient(PassRefPtrWi llBeRawPtr<CanvasGradient> gradient)
163 { 163 {
164 if (!gradient) 164 if (!gradient)
165 return nullptr; 165 return nullptr;
166 return adoptRef(new CanvasStyle(gradient)); 166 return adoptRefWillBeNoop(new CanvasStyle(gradient));
167 } 167 }
168 168
169 PassRefPtr<CanvasStyle> CanvasStyle::createFromPattern(PassRefPtr<CanvasPattern> pattern) 169 PassRefPtrWillBeRawPtr<CanvasStyle> CanvasStyle::createFromPattern(PassRefPtrWil lBeRawPtr<CanvasPattern> pattern)
170 { 170 {
171 if (!pattern) 171 if (!pattern)
172 return nullptr; 172 return nullptr;
173 return adoptRef(new CanvasStyle(pattern)); 173 return adoptRefWillBeNoop(new CanvasStyle(pattern));
174 } 174 }
175 175
176 bool CanvasStyle::isEquivalentColor(const CanvasStyle& other) const 176 bool CanvasStyle::isEquivalentColor(const CanvasStyle& other) const
177 { 177 {
178 if (m_type != other.m_type) 178 if (m_type != other.m_type)
179 return false; 179 return false;
180 180
181 switch (m_type) { 181 switch (m_type) {
182 case RGBA: 182 case RGBA:
183 return m_rgba == other.m_rgba; 183 return m_rgba == other.m_rgba;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 case ImagePattern: 265 case ImagePattern:
266 context->setFillPattern(canvasPattern()->pattern()); 266 context->setFillPattern(canvasPattern()->pattern());
267 break; 267 break;
268 case CurrentColor: 268 case CurrentColor:
269 case CurrentColorWithOverrideAlpha: 269 case CurrentColorWithOverrideAlpha:
270 ASSERT_NOT_REACHED(); 270 ASSERT_NOT_REACHED();
271 break; 271 break;
272 } 272 }
273 } 273 }
274 274
275 void CanvasStyle::trace(Visitor* visitor)
276 {
277 visitor->trace(m_gradient);
278 visitor->trace(m_pattern);
275 } 279 }
280
281 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698