OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
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 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
8 * | 8 * |
9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
10 * modification, are permitted provided that the following conditions | 10 * modification, are permitted provided that the following conditions |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #include "Settings.h" | 59 #include "Settings.h" |
60 #include "StrokeStyleApplier.h" | 60 #include "StrokeStyleApplier.h" |
61 #include "TextMetrics.h" | 61 #include "TextMetrics.h" |
62 #include "TextRun.h" | 62 #include "TextRun.h" |
63 | 63 |
64 #if ENABLE(ACCELERATED_2D_CANVAS) | 64 #if ENABLE(ACCELERATED_2D_CANVAS) |
65 #include "Chrome.h" | 65 #include "Chrome.h" |
66 #include "ChromeClient.h" | 66 #include "ChromeClient.h" |
67 #include "DrawingBuffer.h" | 67 #include "DrawingBuffer.h" |
68 #include "FrameView.h" | 68 #include "FrameView.h" |
| 69 #include "SharedGraphicsContext3D.h" |
69 #if USE(ACCELERATED_COMPOSITING) | 70 #if USE(ACCELERATED_COMPOSITING) |
70 #include "RenderLayer.h" | 71 #include "RenderLayer.h" |
71 #endif | 72 #endif |
72 #endif | 73 #endif |
73 | 74 |
74 #include <wtf/ByteArray.h> | 75 #include <wtf/ByteArray.h> |
75 #include <wtf/MathExtras.h> | 76 #include <wtf/MathExtras.h> |
76 #include <wtf/OwnPtr.h> | 77 #include <wtf/OwnPtr.h> |
77 #include <wtf/UnusedParam.h> | 78 #include <wtf/UnusedParam.h> |
78 | 79 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 CanvasRenderingContext2D* m_canvasContext; | 136 CanvasRenderingContext2D* m_canvasContext; |
136 }; | 137 }; |
137 | 138 |
138 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bo
ol usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode) | 139 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bo
ol usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode) |
139 : CanvasRenderingContext(canvas) | 140 : CanvasRenderingContext(canvas) |
140 , m_stateStack(1) | 141 , m_stateStack(1) |
141 , m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode) | 142 , m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode) |
142 #if ENABLE(DASHBOARD_SUPPORT) | 143 #if ENABLE(DASHBOARD_SUPPORT) |
143 , m_usesDashboardCompatibilityMode(usesDashboardCompatibilityMode) | 144 , m_usesDashboardCompatibilityMode(usesDashboardCompatibilityMode) |
144 #endif | 145 #endif |
145 #if ENABLE(ACCELERATED_2D_CANVAS) | |
146 , m_context3D(0) | |
147 #endif | |
148 { | 146 { |
149 #if !ENABLE(DASHBOARD_SUPPORT) | 147 #if !ENABLE(DASHBOARD_SUPPORT) |
150 ASSERT_UNUSED(usesDashboardCompatibilityMode, !usesDashboardCompatibilityMod
e); | 148 ASSERT_UNUSED(usesDashboardCompatibilityMode, !usesDashboardCompatibilityMod
e); |
151 #endif | 149 #endif |
152 | 150 |
153 // Make sure that even if the drawingContext() has a different default | 151 // Make sure that even if the drawingContext() has a different default |
154 // thickness, it is in sync with the canvas thickness. | 152 // thickness, it is in sync with the canvas thickness. |
155 setLineWidth(lineWidth()); | 153 setLineWidth(lineWidth()); |
156 | 154 |
157 #if ENABLE(ACCELERATED_2D_CANVAS) | 155 #if ENABLE(ACCELERATED_2D_CANVAS) |
(...skipping 30 matching lines...) Expand all Loading... |
188 return m_context3D; | 186 return m_context3D; |
189 #else | 187 #else |
190 return false; | 188 return false; |
191 #endif | 189 #endif |
192 } | 190 } |
193 | 191 |
194 bool CanvasRenderingContext2D::paintsIntoCanvasBuffer() const | 192 bool CanvasRenderingContext2D::paintsIntoCanvasBuffer() const |
195 { | 193 { |
196 #if ENABLE(ACCELERATED_2D_CANVAS) | 194 #if ENABLE(ACCELERATED_2D_CANVAS) |
197 if (m_context3D) | 195 if (m_context3D) |
198 return m_context3D->paintsIntoCanvasBuffer(); | 196 return m_context3D->context()->paintsIntoCanvasBuffer(); |
199 #endif | 197 #endif |
200 return true; | 198 return true; |
201 } | 199 } |
202 | 200 |
203 | 201 |
204 void CanvasRenderingContext2D::reset() | 202 void CanvasRenderingContext2D::reset() |
205 { | 203 { |
206 m_stateStack.resize(1); | 204 m_stateStack.resize(1); |
207 m_stateStack.first() = State(); | 205 m_stateStack.first() = State(); |
208 m_path.clear(); | 206 m_path.clear(); |
(...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2043 | 2041 |
2044 // Try to accelerate. | 2042 // Try to accelerate. |
2045 GraphicsContext* ctx = drawingContext(); | 2043 GraphicsContext* ctx = drawingContext(); |
2046 if (!ctx) { | 2044 if (!ctx) { |
2047 clearAcceleration(); | 2045 clearAcceleration(); |
2048 return; | 2046 return; |
2049 } | 2047 } |
2050 | 2048 |
2051 if (!m_context3D) { | 2049 if (!m_context3D) { |
2052 Page* page = canvas()->document()->page(); | 2050 Page* page = canvas()->document()->page(); |
2053 m_context3D = page->sharedGraphicsContext3D(); | 2051 m_context3D = SharedGraphicsContext3D::create(page->chrome()); |
2054 if (!m_context3D) { | 2052 if (!m_context3D) { |
2055 clearAcceleration(); | 2053 clearAcceleration(); |
2056 return; | 2054 return; |
2057 } | 2055 } |
2058 } | 2056 } |
2059 | 2057 |
2060 if (m_drawingBuffer) { | 2058 if (m_drawingBuffer) { |
2061 if (!m_drawingBuffer->reset(canvas()->size())) { | 2059 if (!m_drawingBuffer->reset(canvas()->size())) { |
2062 clearAcceleration(); | 2060 clearAcceleration(); |
2063 return; | 2061 return; |
2064 } | 2062 } |
2065 } else { | 2063 } else { |
2066 m_drawingBuffer = m_context3D->createDrawingBuffer(canvas()->size()); | 2064 m_drawingBuffer = m_context3D->context()->createDrawingBuffer(canvas()->
size()); |
2067 if (!m_drawingBuffer) { | 2065 if (!m_drawingBuffer) { |
2068 clearAcceleration(); | 2066 clearAcceleration(); |
2069 return; | 2067 return; |
2070 } | 2068 } |
2071 } | 2069 } |
2072 | 2070 |
2073 ctx->setGraphicsContext3D(m_context3D.get(), m_drawingBuffer.get(), canvas()
->size()); | 2071 ctx->setGraphicsContext3D(m_context3D->context(), m_drawingBuffer.get(), can
vas()->size()); |
2074 } | 2072 } |
2075 #endif | 2073 #endif |
2076 | 2074 |
2077 } // namespace WebCore | 2075 } // namespace WebCore |
OLD | NEW |