Changeset 64881 in webkit
- Timestamp:
- Aug 6, 2010 4:29:27 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r64874 r64881 1 2010-08-06 James Robinson <jamesr@chromium.org> 2 3 Reviewed by Simon Fraser. 4 5 Accelerated 2d canvases should get compositing layers 6 https://bugs.webkit.org/show_bug.cgi?id=43362 7 8 Allows for 2d canvas rendering contexts to use a GraphicsContext3D for 9 accelerated rendering. The rendering context holds the GraphicsContext3D 10 alive and exposes it to the compositor. The 3d context itself is passed 11 down through the GraphicsContext to use for actual rendering: 12 https://bug-43362-attachments.webkit.org/attachment.cgi?id=63557 13 14 This approach will let us simultaneously prototype accelerated techniques 15 for canvas 2d and revise the design of canvas elements without destabilizing 16 all ports. 17 18 * html/HTMLCanvasElement.cpp: 19 (WebCore::HTMLCanvasElement::getContext): 20 (WebCore::HTMLCanvasElement::willDraw): 21 (WebCore::HTMLCanvasElement::makeRenderingResultsAvailable): 22 * html/canvas/CanvasRenderingContext.h: 23 (WebCore::CanvasRenderingContext::paintRenderingResultsToCanvas): 24 * html/canvas/CanvasRenderingContext2D.cpp: 25 (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D): 26 (WebCore::CanvasRenderingContext2D::isAccelerated): 27 (WebCore::CanvasRenderingContext2D::reset): 28 (WebCore::CanvasRenderingContext2D::willDraw): 29 (WebCore::CanvasRenderingContext2D::paintRenderingResultsToCanvas): 30 * html/canvas/CanvasRenderingContext2D.h: 31 (WebCore::CanvasRenderingContext2D::graphicsContext3D): 32 * html/canvas/WebGLRenderingContext.cpp: 33 (WebCore::WebGLRenderingContext::paintRenderingResultsToCanvas): 34 * html/canvas/WebGLRenderingContext.h: 35 * platform/graphics/GraphicsContext.h: 36 * platform/graphics/skia/GraphicsContextSkia.cpp: 37 (WebCore::GraphicsContext::syncSoftwareCanvas): 38 1 39 2010-08-06 Eric Seidel <eric@webkit.org> 2 40 -
trunk/WebCore/html/HTMLCanvasElement.cpp
r63606 r64881 170 170 #endif 171 171 m_context = new CanvasRenderingContext2D(this, document()->inCompatMode(), usesDashbardCompatibilityMode); 172 #if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING) 173 if (m_context) { 174 // Need to make sure a RenderLayer and compositing layer get created for the Canvas 175 setNeedsStyleRecalc(SyntheticStyleChange); 176 } 177 #endif 172 178 } 173 179 return m_context.get(); … … 217 223 ro->repaintRectangle(enclosingIntRect(m_dirtyRect)); 218 224 } 219 225 220 226 if (m_observer) 221 227 m_observer->canvasChanged(this, rect); … … 300 306 void HTMLCanvasElement::makeRenderingResultsAvailable() 301 307 { 302 #if ENABLE(3D_CANVAS) 303 if (is3D()) { 304 WebGLRenderingContext* context3d = reinterpret_cast<WebGLRenderingContext*>(renderingContext()); 305 context3d->paintRenderingResultsToCanvas(); 306 } 307 #endif 308 if (m_context) 309 m_context->paintRenderingResultsToCanvas(); 308 310 } 309 311 -
trunk/WebCore/html/canvas/CanvasRenderingContext.h
r64685 r64881 54 54 virtual GraphicsContext3D* graphicsContext3D() const { return 0; } 55 55 56 virtual void paintRenderingResultsToCanvas() {} 57 56 58 private: 57 59 HTMLCanvasElement* m_canvas; -
trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r64407 r64881 59 59 #include "TextMetrics.h" 60 60 61 #include <stdio.h> 61 #if ENABLE(ACCELERATED_2D_CANVAS) 62 #include "FrameView.h" 63 #include "GraphicsContext3D.h" 64 #if USE(ACCELERATED_COMPOSITING) 65 #include "RenderLayer.h" 66 #endif 67 #endif 62 68 63 69 #include <wtf/ByteArray.h> … … 101 107 , m_usesDashboardCompatibilityMode(usesDashboardCompatibilityMode) 102 108 #endif 109 #if ENABLE(ACCELERATED_2D_CANVAS) 110 , m_context3D(0) 111 #endif 103 112 { 104 113 #if !ENABLE(DASHBOARD_SUPPORT) … … 109 118 // thickness, it is in sync with the canvas thickness. 110 119 setLineWidth(lineWidth()); 120 121 #if ENABLE(ACCELERATED_2D_CANVAS) 122 Page* p = canvas->document()->page(); 123 if (!p) 124 return; 125 if (!p->settings()->accelerated2dCanvasEnabled()) 126 return; 127 if (FrameView* view = canvas->document()->view()) { 128 if (ScrollView* rootView = view->root()) { 129 if (HostWindow* hostWindow = view->root()->hostWindow()) { 130 // Set up our context 131 GraphicsContext3D::Attributes attr; 132 attr.stencil = true; 133 m_context3D = GraphicsContext3D::create(attr, hostWindow); 134 if (m_context3D) 135 if (GraphicsContext* c = drawingContext()) 136 c->setGraphicsContext3D(m_context3D.get(), IntSize(canvas->width(), canvas->height())); 137 } 138 } 139 } 140 #endif 111 141 } 112 142 113 143 CanvasRenderingContext2D::~CanvasRenderingContext2D() 114 144 { 145 } 146 147 bool CanvasRenderingContext2D::isAccelerated() const 148 { 149 #if ENABLE(ACCELERATED_2D_CANVAS) 150 return m_context3D; 151 #else 152 return false; 153 #endif 115 154 } 116 155 … … 120 159 m_stateStack.first() = State(); 121 160 m_path.clear(); 161 #if ENABLE(ACCELERATED_2D_CANVAS) 162 if (m_context3D) { 163 if (GraphicsContext* c = drawingContext()) 164 c->setGraphicsContext3D(m_context3D.get(), IntSize(canvas()->width(), canvas()->height())); 165 } 166 #endif 122 167 } 123 168 … … 1435 1480 } 1436 1481 1437 canvas()->willDraw(dirtyRect); 1482 #if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING) 1483 // If we are drawing to hardware and we have a composited layer, just call rendererContentChanged(). 1484 RenderBox* renderBox = canvas()->renderBox(); 1485 if (m_context3D && renderBox && renderBox->hasLayer() && renderBox->layer()->hasAcceleratedCompositing()) 1486 renderBox->layer()->rendererContentChanged(); 1487 else 1488 #endif 1489 canvas()->willDraw(dirtyRect); 1438 1490 } 1439 1491 … … 1773 1825 } 1774 1826 1827 void CanvasRenderingContext2D::paintRenderingResultsToCanvas() 1828 { 1829 #if ENABLE(ACCELERATED_2D_CANVAS) 1830 drawingContext()->syncSoftwareCanvas(); 1831 #endif 1832 } 1833 1775 1834 } // namespace WebCore -
trunk/WebCore/html/canvas/CanvasRenderingContext2D.h
r64407 r64881 43 43 #endif 44 44 45 #if USE(ACCELERATED_COMPOSITING) 46 #include "GraphicsLayer.h" 47 #endif 48 45 49 namespace WebCore { 46 50 … … 57 61 class TextMetrics; 58 62 63 #if ENABLE(ACCELERATED_2D_CANVAS) 64 class GraphicsContext3D; 65 #endif 66 59 67 typedef int ExceptionCode; 60 68 … … 66 74 67 75 virtual bool is2d() const { return true; } 76 virtual bool isAccelerated() const; 68 77 69 78 CanvasStyle* strokeStyle() const; … … 212 221 LineCap getLineCap() const { return state().m_lineCap; } 213 222 LineJoin getLineJoin() const { return state().m_lineJoin; } 223 224 virtual void paintRenderingResultsToCanvas(); 225 226 #if ENABLE(ACCELERATED_2D_CANVAS) 227 virtual GraphicsContext3D* graphicsContext3D() const { return m_context3D.get(); } 228 #endif 214 229 215 230 private: … … 282 297 bool m_usesDashboardCompatibilityMode; 283 298 #endif 299 300 #if ENABLE(ACCELERATED_2D_CANVAS) 301 OwnPtr<GraphicsContext3D> m_context3D; 302 #endif 284 303 }; 285 304 -
trunk/WebCore/html/canvas/WebGLRenderingContext.cpp
r64767 r64881 157 157 } 158 158 159 boolWebGLRenderingContext::paintRenderingResultsToCanvas()159 void WebGLRenderingContext::paintRenderingResultsToCanvas() 160 160 { 161 161 if (m_markedCanvasDirty) { … … 165 165 m_markedCanvasDirty = false; 166 166 m_context->paintRenderingResultsToCanvas(this); 167 return true; 168 } 169 return false; 167 } 170 168 } 171 169 -
trunk/WebCore/html/canvas/WebGLRenderingContext.h
r64767 r64881 308 308 void reshape(int width, int height); 309 309 310 // Return value true indicates canvas is updated during the call, 311 // false indicates no updates. 312 bool paintRenderingResultsToCanvas(); 310 virtual void paintRenderingResultsToCanvas(); 313 311 314 312 // Helpers for notification about paint events. -
trunk/WebCore/platform/graphics/GraphicsContext.h
r64584 r64881 117 117 class Generator; 118 118 class Gradient; 119 class GraphicsContext3D; 119 120 class GraphicsContextPlatformPrivate; 120 121 class GraphicsContextPrivate; … … 394 395 #endif 395 396 397 #if PLATFORM(SKIA) 398 void setGraphicsContext3D(GraphicsContext3D*, const IntSize&); 399 void syncSoftwareCanvas(); 400 #endif 401 396 402 private: 397 403 void savePlatformState(); -
trunk/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
r64872 r64881 1277 1277 } 1278 1278 1279 void GraphicsContext::setGraphicsContext3D(GraphicsContext3D* context3D, const IntSize& size) 1280 { 1281 #if USE(GLES2_RENDERING) 1282 platformContext()->setGraphicsContext3D(context3D, size); 1283 #else 1284 UNUSED_PARAM(context3D); 1285 UNUSED_PARAM(size); 1286 #endif 1287 } 1288 1289 void GraphicsContext::syncSoftwareCanvas() 1290 { 1291 #if USE(GLES2_RENDERING) 1292 platformContext()->syncSoftwareCanvas(); 1293 #endif 1294 } 1295 1279 1296 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.