OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 ContextTypeCount, | 161 ContextTypeCount, |
162 }; | 162 }; |
163 | 163 |
164 // FIXME - The code depends on the context not going away once created, to p
revent JS from | 164 // FIXME - The code depends on the context not going away once created, to p
revent JS from |
165 // seeing a dangling pointer. So for now we will disallow the context from b
eing changed | 165 // seeing a dangling pointer. So for now we will disallow the context from b
eing changed |
166 // once it is created. | 166 // once it is created. |
167 if (type == "2d") { | 167 if (type == "2d") { |
168 if (m_context && !m_context->is2d()) | 168 if (m_context && !m_context->is2d()) |
169 return 0; | 169 return 0; |
170 if (!m_context) { | 170 if (!m_context) { |
171 WebKit::Platform::current()->histogramEnumeration("Canvas.ContextTyp
e", Context2d, ContextTypeCount); | 171 blink::Platform::current()->histogramEnumeration("Canvas.ContextType
", Context2d, ContextTypeCount); |
172 m_context = CanvasRenderingContext2D::create(this, static_cast<Canva
s2DContextAttributes*>(attrs), document().inQuirksMode()); | 172 m_context = CanvasRenderingContext2D::create(this, static_cast<Canva
s2DContextAttributes*>(attrs), document().inQuirksMode()); |
173 if (m_context) | 173 if (m_context) |
174 scheduleLayerUpdate(); | 174 scheduleLayerUpdate(); |
175 } | 175 } |
176 return m_context.get(); | 176 return m_context.get(); |
177 } | 177 } |
178 | 178 |
179 Settings* settings = document().settings(); | 179 Settings* settings = document().settings(); |
180 if (settings && settings->webGLEnabled()) { | 180 if (settings && settings->webGLEnabled()) { |
181 // Accept the legacy "webkit-3d" name as well as the provisional "experi
mental-webgl" name. | 181 // Accept the legacy "webkit-3d" name as well as the provisional "experi
mental-webgl" name. |
182 // Now that WebGL is ratified, we will also accept "webgl" as the contex
t name in Chrome. | 182 // Now that WebGL is ratified, we will also accept "webgl" as the contex
t name in Chrome. |
183 ContextType contextType; | 183 ContextType contextType; |
184 bool is3dContext = true; | 184 bool is3dContext = true; |
185 if (type == "webkit-3d") | 185 if (type == "webkit-3d") |
186 contextType = ContextWebkit3d; | 186 contextType = ContextWebkit3d; |
187 else if (type == "experimental-webgl") | 187 else if (type == "experimental-webgl") |
188 contextType = ContextExperimentalWebgl; | 188 contextType = ContextExperimentalWebgl; |
189 else if (type == "webgl") | 189 else if (type == "webgl") |
190 contextType = ContextWebgl; | 190 contextType = ContextWebgl; |
191 else | 191 else |
192 is3dContext = false; | 192 is3dContext = false; |
193 | 193 |
194 if (is3dContext) { | 194 if (is3dContext) { |
195 if (m_context && !m_context->is3d()) | 195 if (m_context && !m_context->is3d()) |
196 return 0; | 196 return 0; |
197 if (!m_context) { | 197 if (!m_context) { |
198 WebKit::Platform::current()->histogramEnumeration("Canvas.Contex
tType", contextType, ContextTypeCount); | 198 blink::Platform::current()->histogramEnumeration("Canvas.Context
Type", contextType, ContextTypeCount); |
199 m_context = WebGLRenderingContext::create(this, static_cast<WebG
LContextAttributes*>(attrs)); | 199 m_context = WebGLRenderingContext::create(this, static_cast<WebG
LContextAttributes*>(attrs)); |
200 if (m_context) | 200 if (m_context) |
201 scheduleLayerUpdate(); | 201 scheduleLayerUpdate(); |
202 } | 202 } |
203 return m_context.get(); | 203 return m_context.get(); |
204 } | 204 } |
205 } | 205 } |
206 return 0; | 206 return 0; |
207 } | 207 } |
208 | 208 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 return false; | 436 return false; |
437 | 437 |
438 Settings* settings = document().settings(); | 438 Settings* settings = document().settings(); |
439 if (!settings || !settings->accelerated2dCanvasEnabled()) | 439 if (!settings || !settings->accelerated2dCanvasEnabled()) |
440 return false; | 440 return false; |
441 | 441 |
442 // Do not use acceleration for small canvas. | 442 // Do not use acceleration for small canvas. |
443 if (size.width() * size.height() < settings->minimumAccelerated2dCanvasSize(
)) | 443 if (size.width() * size.height() < settings->minimumAccelerated2dCanvasSize(
)) |
444 return false; | 444 return false; |
445 | 445 |
446 if (!WebKit::Platform::current()->canAccelerate2dCanvas()) | 446 if (!blink::Platform::current()->canAccelerate2dCanvas()) |
447 return false; | 447 return false; |
448 | 448 |
449 return true; | 449 return true; |
450 } | 450 } |
451 | 451 |
452 void HTMLCanvasElement::createImageBuffer() | 452 void HTMLCanvasElement::createImageBuffer() |
453 { | 453 { |
454 ASSERT(!m_imageBuffer); | 454 ASSERT(!m_imageBuffer); |
455 | 455 |
456 m_hasCreatedImageBuffer = true; | 456 m_hasCreatedImageBuffer = true; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 ASSERT(m_hasCreatedImageBuffer); | 555 ASSERT(m_hasCreatedImageBuffer); |
556 IntSize unscaledSize = size(); | 556 IntSize unscaledSize = size(); |
557 IntSize size = convertLogicalToDevice(unscaledSize); | 557 IntSize size = convertLogicalToDevice(unscaledSize); |
558 AffineTransform transform; | 558 AffineTransform transform; |
559 if (size.width() && size.height()) | 559 if (size.width() && size.height()) |
560 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig
ht() / unscaledSize.height()); | 560 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig
ht() / unscaledSize.height()); |
561 return m_imageBuffer->baseTransform() * transform; | 561 return m_imageBuffer->baseTransform() * transform; |
562 } | 562 } |
563 | 563 |
564 } | 564 } |
OLD | NEW |