Changeset 70129 in webkit
- Timestamp:
- Oct 19, 2010 11:36:00 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70118 r70129 1 2010-10-19 Adam Roben <aroben@apple.com> 2 3 Remove uses of CACFContextRef and CARender* from WebCore 4 5 These types are now wrapped in a WKCACFContext type exported by 6 WebKitSystemInterface. 7 8 Fixes <http://webkit.org/b/43244>. 9 10 Reviewed by Sam Weinig. 11 12 * platform/graphics/win/WKCACFContextFlusher.cpp: 13 (WebCore::WKCACFContextFlusher::addContext): 14 (WebCore::WKCACFContextFlusher::removeContext): 15 (WebCore::WKCACFContextFlusher::flushAllContexts): 16 * platform/graphics/win/WKCACFContextFlusher.h: 17 Changed to use WKCACFContext. We don't retain/release the context when 18 putting it into/taking it out of the set. WKCACFContext is not a 19 ref-counted type, so we can't retain/release it, but the 20 retain/release was also unnecessary as WKCACFLayerRenderer calls 21 removeContext before the context is destroyed. 22 23 * platform/graphics/win/WKCACFLayer.cpp: 24 (WebCore::WKCACFLayer::becomeRootLayerForContext): 25 * platform/graphics/win/WKCACFLayer.h: 26 Changed to use WKCACFContext. 27 28 * platform/graphics/win/WKCACFLayerRenderer.cpp: 29 (WebCore::WKCACFLayerRenderer::didFlushContext): 30 (WebCore::WKCACFLayerRenderer::WKCACFLayerRenderer): 31 (WebCore::WKCACFLayerRenderer::~WKCACFLayerRenderer): 32 (WebCore::WKCACFLayerRenderer::layerTreeDidChange): 33 (WebCore::WKCACFLayerRenderer::createRenderer): 34 (WebCore::WKCACFLayerRenderer::destroyRenderer): 35 (WebCore::WKCACFLayerRenderer::render): Also replaced uses of 36 CGSRegion with WebKitSystemInterface functions/types. 37 (WebCore::WKCACFLayerRenderer::resetDevice): 38 * platform/graphics/win/WKCACFLayerRenderer.h: 39 Replaced our CACFContextRef, CARenderContext, and CARenderOGLContext 40 with a single WKCACFContext, which wraps all three. We hold a bare 41 pointer to it and destroy it in our destructor. 42 1 43 2010-10-19 Yongjun Zhang <yongjun_zhang@apple.com> 2 44 -
trunk/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp
r64364 r70129 30 30 #include "WKCACFContextFlusher.h" 31 31 32 #include <WebKitSystemInterface/WebKitSystemInterface.h> 32 33 #include <wtf/StdLibExtras.h> 33 #include <QuartzCore/CACFContext.h>34 34 35 35 namespace WebCore { … … 49 49 } 50 50 51 void WKCACFContextFlusher::addContext( CACFContextRefcontext)51 void WKCACFContextFlusher::addContext(WKCACFContext* context) 52 52 { 53 53 ASSERT(context); 54 54 55 if (m_contexts.add(context).second) 56 CFRetain(context); 55 m_contexts.add(context); 57 56 } 58 57 59 void WKCACFContextFlusher::removeContext( CACFContextRefcontext)58 void WKCACFContextFlusher::removeContext(WKCACFContext* context) 60 59 { 61 60 ASSERT(context); 62 61 63 ContextSet::iterator found = m_contexts.find(context); 64 if (found == m_contexts.end()) 65 return; 66 67 CFRelease(*found); 68 m_contexts.remove(found); 62 m_contexts.remove(context); 69 63 } 70 64 … … 77 71 78 72 ContextSet::const_iterator end = contextsToFlush.end(); 79 for (ContextSet::const_iterator it = contextsToFlush.begin(); it != end; ++it) { 80 CACFContextRef context = *it; 81 CACFContextFlush(context); 82 CFRelease(context); 83 } 73 for (ContextSet::const_iterator it = contextsToFlush.begin(); it != end; ++it) 74 wkCACFContextFlush(*it); 84 75 } 85 76 -
trunk/WebCore/platform/graphics/win/WKCACFContextFlusher.h
r64364 r70129 33 33 #include <wtf/HashSet.h> 34 34 35 typedef struct _CACFContext* CACFContextRef;35 struct WKCACFContext; 36 36 37 37 namespace WebCore { … … 41 41 static WKCACFContextFlusher& shared(); 42 42 43 void addContext( CACFContextRef);44 void removeContext( CACFContextRef);43 void addContext(WKCACFContext*); 44 void removeContext(WKCACFContext*); 45 45 46 46 void flushAllContexts(); … … 50 50 ~WKCACFContextFlusher(); 51 51 52 typedef HashSet< CACFContextRef> ContextSet;52 typedef HashSet<WKCACFContext*> ContextSet; 53 53 ContextSet m_contexts; 54 54 }; -
trunk/WebCore/platform/graphics/win/WKCACFLayer.cpp
r67285 r70129 31 31 32 32 #include "WKCACFLayerRenderer.h" 33 #include <WebKitSystemInterface/WebKitSystemInterface.h> 34 #include <stdio.h> 35 #include <wtf/CurrentTime.h> 33 36 #include <wtf/text/CString.h> 34 35 #include <stdio.h>36 #include <QuartzCore/CACFContext.h>37 #include <QuartzCore/CARender.h>38 39 #ifndef NDEBUG40 #include <wtf/CurrentTime.h>41 #endif42 37 43 38 namespace WebCore { … … 191 186 } 192 187 193 void WKCACFLayer::becomeRootLayerForContext( CACFContextRefcontext)194 { 195 CACFContextSetLayer(context, layer());188 void WKCACFLayer::becomeRootLayerForContext(WKCACFContext* context) 189 { 190 wkCACFContextSetLayer(context, layer()); 196 191 setNeedsCommit(); 197 192 } -
trunk/WebCore/platform/graphics/win/WKCACFLayer.h
r66050 r70129 42 42 #include "TransformationMatrix.h" 43 43 44 struct WKCACFContext; 45 44 46 namespace WebCore { 45 47 … … 84 86 85 87 // Makes this layer the root when the passed context is rendered 86 void becomeRootLayerForContext( CACFContextRef);88 void becomeRootLayerForContext(WKCACFContext*); 87 89 88 90 static RetainPtr<CFTypeRef> cfValue(float value) { return RetainPtr<CFTypeRef>(AdoptCF, CFNumberCreate(0, kCFNumberFloat32Type, &value)); } -
trunk/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
r69259 r70129 37 37 #include "WKCACFLayer.h" 38 38 #include "WebCoreInstanceHandle.h" 39 #include <CoreGraphics/CGSRegion.h> 40 #include <QuartzCore/CACFContext.h> 41 #include <QuartzCore/CARenderOGL.h> 39 #include <WebKitSystemInterface/WebKitSystemInterface.h> 42 40 #include <wtf/HashMap.h> 43 41 #include <wtf/OwnArrayPtr.h> … … 109 107 }; 110 108 111 typedef HashMap< CACFContextRef, WKCACFLayerRenderer*> ContextToWindowMap;109 typedef HashMap<WKCACFContext*, WKCACFLayerRenderer*> ContextToWindowMap; 112 110 113 111 static ContextToWindowMap& windowsForContexts() … … 207 205 } 208 206 209 void WKCACFLayerRenderer::didFlushContext( CACFContextRefcontext)207 void WKCACFLayerRenderer::didFlushContext(WKCACFContext* context) 210 208 { 211 209 WKCACFLayerRenderer* window = windowsForContexts().get(context); … … 227 225 , m_mightBeAbleToCreateDeviceLater(true) 228 226 , m_rootLayer(WKCACFRootLayer::create(this)) 229 , m_context(AdoptCF, CACFContextCreate(0)) 230 , m_renderContext(static_cast<CARenderContext*>(CACFContextGetRenderContext(m_context.get()))) 231 , m_renderer(0) 227 , m_context(wkCACFContextCreate()) 232 228 , m_hostWindow(0) 233 229 , m_renderTimer(this, &WKCACFLayerRenderer::renderTimerFired) … … 235 231 , m_mustResetLostDeviceBeforeRendering(false) 236 232 { 237 windowsForContexts().set(m_context .get(), this);233 windowsForContexts().set(m_context, this); 238 234 239 235 // Under the root layer, we have a clipping layer to clip the content, … … 257 253 258 254 if (m_context) 259 m_rootLayer->becomeRootLayerForContext(m_context .get());255 m_rootLayer->becomeRootLayerForContext(m_context); 260 256 261 257 #ifndef NDEBUG … … 268 264 { 269 265 destroyRenderer(); 266 wkCACFContextDestroy(m_context); 270 267 } 271 268 … … 299 296 void WKCACFLayerRenderer::layerTreeDidChange() 300 297 { 301 WKCACFContextFlusher::shared().addContext(m_context .get());298 WKCACFContextFlusher::shared().addContext(m_context); 302 299 renderSoon(); 303 300 } … … 374 371 initD3DGeometry(); 375 372 376 m_renderer = CARenderOGLNew(&kCARenderDX9Callbacks, m_d3dDevice.get(), 0);373 wkCACFContextInitializeD3DDevice(m_context, m_d3dDevice.get()); 377 374 378 375 if (IsWindow(m_hostWindow)) … … 385 382 { 386 383 if (m_context) { 387 CACFContextSetLayer(m_context.get(), 0); 388 windowsForContexts().remove(m_context.get()); 389 WKCACFContextFlusher::shared().removeContext(m_context.get()); 390 } 391 392 if (m_renderer) 393 CARenderOGLDestroy(m_renderer); 394 m_renderer = 0; 384 windowsForContexts().remove(m_context); 385 WKCACFContextFlusher::shared().removeContext(m_context); 386 } 387 395 388 m_d3dDevice = 0; 396 389 if (s_d3d) … … 477 470 } 478 471 479 void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects)472 void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects) 480 473 { 481 474 ASSERT(m_d3dDevice); … … 500 493 501 494 // Give the renderer some space to use. This needs to be valid until the 502 // CARenderUpdateFinish() call below.495 // wkCACFContextFinishUpdate() call below. 503 496 char space[4096]; 504 CARenderUpdate* u = CARenderUpdateBegin(space, sizeof(space), t, 0, 0, &bounds); 505 if (!u) 506 return; 507 508 CARenderContextLock(m_renderContext); 509 CARenderUpdateAddContext(u, m_renderContext); 510 CARenderContextUnlock(m_renderContext); 511 512 for (size_t i = 0; i < dirtyRects.size(); ++i) 513 CARenderUpdateAddRect(u, &dirtyRects[i]); 497 if (!wkCACFContextBeginUpdate(m_context, space, sizeof(space), t, bounds, windowDirtyRects.data(), windowDirtyRects.size())) 498 return; 514 499 515 500 HRESULT err = S_OK; 516 501 do { 517 CGSRegionObj rgn = CARenderUpdateCopyRegion(u); 518 519 if (!rgn) 502 // FIXME: don't need to clear dirty region if layer tree is opaque. 503 504 WKCACFUpdateRectEnumerator* e = wkCACFContextCopyUpdateRectEnumerator(m_context); 505 if (!e) 520 506 break; 521 507 522 // FIXME: don't need to clear dirty region if layer tree is opaque.523 524 508 Vector<D3DRECT, 64> rects; 525 CGSRegionEnumeratorObj e = CGSRegionEnumerator(rgn); 526 for (const CGRect* r = CGSNextRect(e); r; r = CGSNextRect(e)) { 509 for (const CGRect* r = wkCACFUpdateRectEnumeratorNextRect(e); r; r = wkCACFUpdateRectEnumeratorNextRect(e)) { 527 510 D3DRECT rect; 528 511 rect.x1 = r->origin.x; … … 533 516 rects.append(rect); 534 517 } 535 CGSReleaseRegionEnumerator(e); 536 CGSReleaseRegion(rgn); 518 wkCACFUpdateRectEnumeratorRelease(e); 537 519 538 520 if (rects.isEmpty()) … … 542 524 543 525 m_d3dDevice->BeginScene(); 544 CARenderOGLRender(m_renderer, u);526 wkCACFContextRenderUpdate(m_context); 545 527 m_d3dDevice->EndScene(); 546 528 … … 548 530 549 531 if (err == D3DERR_DEVICELOST) { 550 CARenderUpdateAddRect(u, &bounds);532 wkCACFContextAddUpdateRect(m_context, bounds); 551 533 if (!resetDevice(LostDevice)) { 552 534 // We can't reset the device right now. Try again soon. … … 557 539 } while (err == D3DERR_DEVICELOST); 558 540 559 CARenderUpdateFinish(u);541 wkCACFContextFinishUpdate(m_context); 560 542 561 543 #ifndef NDEBUG … … 599 581 { 600 582 ASSERT(m_d3dDevice); 601 ASSERT(m_ renderContext);583 ASSERT(m_context); 602 584 603 585 HRESULT hr = m_d3dDevice->TestCooperativeLevel(); … … 618 600 // We can reset the device. 619 601 620 // We have to purge the CARenderOGLContextwhenever we reset the IDirect3DDevice9 in order to602 // We have to release the context's D3D resrouces whenever we reset the IDirect3DDevice9 in order to 621 603 // destroy any D3DPOOL_DEFAULT resources that Core Animation has allocated (e.g., textures used 622 604 // for mask layers). See <http://msdn.microsoft.com/en-us/library/bb174425(v=VS.85).aspx>. 623 CARenderOGLPurge(m_renderer);605 wkCACFContextReleaseD3DResources(m_context); 624 606 625 607 D3DPRESENT_PARAMETERS parameters = initialPresentationParameters(); -
trunk/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
r68971 r70129 42 42 43 43 interface IDirect3DDevice9; 44 typedef struct _CACFContext* CACFContextRef; 45 typedef struct _CARenderContext CARenderContext; 46 typedef struct _CARenderOGLContext CARenderOGLContext; 44 struct WKCACFContext; 47 45 48 46 namespace WebCore { … … 65 63 66 64 static bool acceleratedCompositingAvailable(); 67 static void didFlushContext( CACFContextRef);65 static void didFlushContext(WKCACFContext*); 68 66 69 67 void setRootContents(CGImageRef); … … 105 103 RefPtr<WKCACFRootLayer> m_rootLayer; 106 104 RefPtr<WKCACFLayer> m_rootChildLayer; 107 RetainPtr<CACFContextRef> m_context; 108 CARenderContext* m_renderContext; 109 CARenderOGLContext* m_renderer; 105 WKCACFContext* m_context; 110 106 HWND m_hostWindow; 111 107 Timer<WKCACFLayerRenderer> m_renderTimer; -
trunk/WebKitLibraries/ChangeLog
r69797 r70129 1 2010-10-19 Adam Roben <aroben@apple.com> 2 3 Add WKCACFContext and related functions 4 5 Fixes <http://webkit.org/b/43244>. 6 7 Reviewed by Sam Weinig. 8 9 * win/lib/WebKitSystemInterface.lib: 10 * win/lib/WebKitSystemInterface_debug.lib: 11 1 12 2010-10-14 Ada Chan <adachan@apple.com> 2 13
Note: See TracChangeset
for help on using the changeset viewer.