Changeset 64361 in webkit
- Timestamp:
- Jul 30, 2010 10:37:55 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r64360 r64361 1 2010-07-30 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-07-30 Adam Roben <aroben@apple.com> 2 44 -
trunk/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp
r59897 r64361 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
r51371 r64361 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
r64360 r64361 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 { … … 166 161 } 167 162 168 void WKCACFLayer::becomeRootLayerForContext( CACFContextRefcontext)169 { 170 CACFContextSetLayer(context, layer());163 void WKCACFLayer::becomeRootLayerForContext(WKCACFContext* context) 164 { 165 wkCACFContextSetLayer(context, layer()); 171 166 setNeedsCommit(); 172 167 } -
trunk/WebCore/platform/graphics/win/WKCACFLayer.h
r64295 r64361 43 43 #include "TransformationMatrix.h" 44 44 45 struct WKCACFContext; 46 45 47 namespace WebCore { 46 48 … … 81 83 82 84 // Makes this layer the root when the passed context is rendered 83 void becomeRootLayerForContext( CACFContextRef);85 void becomeRootLayerForContext(WKCACFContext*); 84 86 85 87 static RetainPtr<CFTypeRef> cfValue(float value) { return RetainPtr<CFTypeRef>(AdoptCF, CFNumberCreate(0, kCFNumberFloat32Type, &value)); } -
trunk/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
r64360 r64361 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); … … 229 227 , m_scrollLayer(WKCACFLayer::create(WKCACFLayer::Layer)) 230 228 , m_clipLayer(WKCACFLayer::create(WKCACFLayer::Layer)) 231 , m_context(AdoptCF, CACFContextCreate(0)) 232 , m_renderContext(static_cast<CARenderContext*>(CACFContextGetRenderContext(m_context.get()))) 233 , m_renderer(0) 229 , m_context(wkCACFContextCreate()) 234 230 , m_hostWindow(0) 235 231 , m_renderTimer(this, &WKCACFLayerRenderer::renderTimerFired) … … 239 235 , m_mustResetLostDeviceBeforeRendering(false) 240 236 { 241 windowsForContexts().set(m_context .get(), this);237 windowsForContexts().set(m_context, this); 242 238 243 239 // Under the root layer, we have a clipping layer to clip the content, … … 268 264 269 265 if (m_context) 270 m_rootLayer->becomeRootLayerForContext(m_context .get());266 m_rootLayer->becomeRootLayerForContext(m_context); 271 267 272 268 #ifndef NDEBUG … … 279 275 { 280 276 destroyRenderer(); 277 wkCACFContextDestroy(m_context); 281 278 } 282 279 … … 336 333 void WKCACFLayerRenderer::layerTreeDidChange() 337 334 { 338 WKCACFContextFlusher::shared().addContext(m_context .get());335 WKCACFContextFlusher::shared().addContext(m_context); 339 336 renderSoon(); 340 337 } … … 414 411 m_d3dDevice->SetTransform(D3DTS_PROJECTION, &projection); 415 412 416 m_renderer = CARenderOGLNew(&kCARenderDX9Callbacks, m_d3dDevice.get(), 0);413 wkCACFContextInitializeD3DDevice(m_context, m_d3dDevice.get()); 417 414 418 415 if (IsWindow(m_hostWindow)) … … 425 422 { 426 423 if (m_context) { 427 CACFContextSetLayer(m_context.get(), 0); 428 windowsForContexts().remove(m_context.get()); 429 WKCACFContextFlusher::shared().removeContext(m_context.get()); 430 } 431 432 if (m_renderer) 433 CARenderOGLDestroy(m_renderer); 434 m_renderer = 0; 424 windowsForContexts().remove(m_context); 425 WKCACFContextFlusher::shared().removeContext(m_context); 426 } 427 435 428 m_d3dDevice = 0; 436 429 if (s_d3d) … … 520 513 } 521 514 522 void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects)515 void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects) 523 516 { 524 517 ASSERT(m_d3dDevice); … … 543 536 544 537 // Give the renderer some space to use. This needs to be valid until the 545 // CARenderUpdateFinish() call below.538 // wkCACFContextFinishUpdate() call below. 546 539 char space[4096]; 547 CARenderUpdate* u = CARenderUpdateBegin(space, sizeof(space), t, 0, 0, &bounds); 548 if (!u) 549 return; 550 551 CARenderContextLock(m_renderContext); 552 CARenderUpdateAddContext(u, m_renderContext); 553 CARenderContextUnlock(m_renderContext); 554 555 for (size_t i = 0; i < dirtyRects.size(); ++i) 556 CARenderUpdateAddRect(u, &dirtyRects[i]); 540 if (!wkCACFContextBeginUpdate(m_context, space, sizeof(space), t, bounds, windowDirtyRects.data(), windowDirtyRects.size())) 541 return; 557 542 558 543 HRESULT err = S_OK; 559 544 do { 560 CGSRegionObj rgn = CARenderUpdateCopyRegion(u); 561 562 if (!rgn) 545 // FIXME: don't need to clear dirty region if layer tree is opaque. 546 547 WKCACFUpdateRectEnumerator* e = wkCACFContextCopyUpdateRectEnumerator(m_context); 548 if (!e) 563 549 break; 564 550 565 // FIXME: don't need to clear dirty region if layer tree is opaque.566 567 551 Vector<D3DRECT, 64> rects; 568 CGSRegionEnumeratorObj e = CGSRegionEnumerator(rgn); 569 for (const CGRect* r = CGSNextRect(e); r; r = CGSNextRect(e)) { 552 for (const CGRect* r = wkCACFUpdateRectEnumeratorNextRect(e); r; r = wkCACFUpdateRectEnumeratorNextRect(e)) { 570 553 D3DRECT rect; 571 554 rect.x1 = r->origin.x; … … 576 559 rects.append(rect); 577 560 } 578 CGSReleaseRegionEnumerator(e); 579 CGSReleaseRegion(rgn); 561 wkCACFUpdateRectEnumeratorRelease(e); 580 562 581 563 if (rects.isEmpty()) … … 585 567 586 568 m_d3dDevice->BeginScene(); 587 CARenderOGLRender(m_renderer, u);569 wkCACFContextRenderUpdate(m_context); 588 570 m_d3dDevice->EndScene(); 589 571 … … 591 573 592 574 if (err == D3DERR_DEVICELOST) { 593 CARenderUpdateAddRect(u, &bounds);575 wkCACFContextAddUpdateRect(m_context, bounds); 594 576 if (!resetDevice(LostDevice)) { 595 577 // We can't reset the device right now. Try again soon. … … 600 582 } while (err == D3DERR_DEVICELOST); 601 583 602 CARenderUpdateFinish(u);584 wkCACFContextFinishUpdate(m_context); 603 585 604 586 #ifndef NDEBUG … … 642 624 { 643 625 ASSERT(m_d3dDevice); 644 ASSERT(m_ renderContext);626 ASSERT(m_context); 645 627 646 628 HRESULT hr = m_d3dDevice->TestCooperativeLevel(); … … 661 643 // We can reset the device. 662 644 663 // We have to purge the CARenderOGLContextwhenever we reset the IDirect3DDevice9 in order to645 // We have to release the context's D3D resrouces whenever we reset the IDirect3DDevice9 in order to 664 646 // destroy any D3DPOOL_DEFAULT resources that Core Animation has allocated (e.g., textures used 665 647 // for mask layers). See <http://msdn.microsoft.com/en-us/library/bb174425(v=VS.85).aspx>. 666 CARenderOGLPurge(m_renderer);648 wkCACFContextReleaseD3DResources(m_context); 667 649 668 650 D3DPRESENT_PARAMETERS parameters = initialPresentationParameters(); -
trunk/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
r64360 r64361 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 setScrollFrame(const IntPoint&, const IntSize&); … … 109 107 RefPtr<WKCACFLayer> m_rootChildLayer; 110 108 RefPtr<WKCACFLayer> m_clipLayer; 111 RetainPtr<CACFContextRef> m_context; 112 CARenderContext* m_renderContext; 113 CARenderOGLContext* m_renderer; 109 WKCACFContext* m_context; 114 110 HWND m_hostWindow; 115 111 Timer<WKCACFLayerRenderer> m_renderTimer; -
trunk/WebKitLibraries/ChangeLog
r64189 r64361 1 2010-07-30 Adam Roben <aroben@apple.com> 2 3 Add WKCACFContext and related functions 4 5 Also added some functions used by WKCAImageQueue. 6 7 Fixes <http://webkit.org/b/43244>. 8 9 Reviewed by Sam Weinig. 10 11 * win/include/WebKitSystemInterface/WebKitSystemInterface.h: 12 * win/lib/WebKitSystemInterface.lib: 13 * win/lib/WebKitSystemInterface_debug.lib: 14 1 15 2010-07-27 Kinuko Yasuda <kinuko@chromium.org> 2 16 -
trunk/WebKitLibraries/win/include/WebKitSystemInterface/WebKitSystemInterface.h
r60115 r64361 29 29 struct CGAffineTransform; 30 30 struct CGPoint; 31 struct CGRect; 31 32 struct CGSize; 33 struct IDirect3DDevice9; 34 struct WKCACFContext; 35 struct WKCACFUpdateRectEnumerator; 32 36 37 typedef struct _CACFLayer* CACFLayerRef; 33 38 typedef const struct __CFData* CFDataRef; 34 39 typedef const struct __CFString* CFStringRef; 40 typedef double CFTimeInterval; 35 41 typedef struct CGColor* CGColorRef; 36 42 typedef struct CGContext* CGContextRef; … … 39 45 typedef CGFontIndex CGGlyph; 40 46 typedef wchar_t UChar; 47 typedef struct _CFURLCredential* CFURLCredentialRef; 41 48 typedef struct _CFURLResponse* CFURLResponseRef; 42 49 typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef; 43 50 typedef struct _CFURLRequest* CFMutableURLRequestRef; 44 51 typedef const struct _CFURLRequest* CFURLRequestRef; 45 typedef struct _CFURLCredential* CFURLCredentialRef;46 52 typedef struct __CFHTTPMessage* CFHTTPMessageRef; 47 53 typedef const struct __CFNumber* CFNumberRef; … … 51 57 typedef struct tagLOGFONTW LOGFONTW; 52 58 typedef LOGFONTW LOGFONT; 59 typedef struct _CACFLayer *CACFLayerRef; 60 typedef struct __CVBuffer *CVBufferRef; 61 typedef CVBufferRef CVImageBufferRef; 62 typedef CVImageBufferRef CVPixelBufferRef; 63 typedef struct _CAImageQueue *CAImageQueueRef; 64 typedef unsigned long CFTypeID; 53 65 54 66 void wkSetFontSmoothingLevel(int type); … … 90 102 CFStringRef wkCFNetworkErrorGetLocalizedDescription(CFIndex errorCode); 91 103 104 105 enum wkCAImageQueueFlags { 106 kWKCAImageQueueAsync = 1U << 0, 107 kWKCAImageQueueFill = 1U << 1, 108 kWKCAImageQueueProtected = 1U << 2, 109 kWKCAImageQueueUseCleanAperture = 1U << 3, 110 kWKCAImageQueueUseAspectRatio = 1U << 4, 111 kWKCAImageQueueLowQualityColor = 1U << 5, 112 }; 113 114 enum wkWKCAImageQueueImageType { 115 kWKCAImageQueueNil = 1, 116 kWKCAImageQueueSurface, 117 kWKCAImageQueueBuffer, 118 kWKCAImageQueueIOSurface, 119 }; 120 121 enum wkWKCAImageQueueImageFlags { 122 kWKCAImageQueueOpaque = 1U << 0, 123 kWKCAImageQueueFlush = 1U << 1, 124 kWKCAImageQueueWillFlush = 1U << 2, 125 kWKCAImageQueueFlipped = 1U << 3, 126 kWKCAImageQueueWaitGPU = 1U << 4, 127 }; 128 129 typedef void (*wkCAImageQueueReleaseCallback)(unsigned int type, uint64_t id, void *info); 130 CAImageQueueRef wkCAImageQueueCreate(uint32_t width, uint32_t height, uint32_t capacity); 131 void wkCAImageQueueInvalidate(CAImageQueueRef iq); 132 size_t wkCAImageQueueCollect(CAImageQueueRef iq); 133 bool wkCAImageQueueInsertImage(CAImageQueueRef iq, CFTimeInterval t, unsigned int type, uint64_t id, uint32_t flags, wkCAImageQueueReleaseCallback release, void *info); 134 uint64_t wkCAImageQueueRegisterPixelBuffer(CAImageQueueRef iq, void *data, size_t data_size, size_t rowbytes, size_t width, size_t height, OSType pixel_format, CFDictionaryRef attachments, uint32_t flags); 135 void wkCAImageQueueSetFlags(CAImageQueueRef iq, uint32_t mask, uint32_t flags); 136 uint32_t wkCAImageQueueGetFlags(CAImageQueueRef iq); 137 CFTypeID wkCAImageQueueGetTypeID(void); 138 139 WKCACFContext* wkCACFContextCreate(); 140 void wkCACFContextDestroy(WKCACFContext*); 141 142 void wkCACFContextSetLayer(WKCACFContext*, CACFLayerRef); 143 void wkCACFContextFlush(WKCACFContext*); 144 145 void wkCACFContextInitializeD3DDevice(WKCACFContext*, IDirect3DDevice9*); 146 void wkCACFContextReleaseD3DResources(WKCACFContext*); 147 148 bool wkCACFContextBeginUpdate(WKCACFContext*, void* buffer, size_t bufferSize, CFTimeInterval time, const CGRect& bounds, const CGRect dirtyRects[], size_t dirtyRectCount); 149 void wkCACFContextRenderUpdate(WKCACFContext*); 150 void wkCACFContextFinishUpdate(WKCACFContext*); 151 void wkCACFContextAddUpdateRect(WKCACFContext*, const CGRect&); 152 153 WKCACFUpdateRectEnumerator* wkCACFContextCopyUpdateRectEnumerator(WKCACFContext*); 154 const CGRect* wkCACFUpdateRectEnumeratorNextRect(WKCACFUpdateRectEnumerator*); 155 void wkCACFUpdateRectEnumeratorRelease(WKCACFUpdateRectEnumerator*); 156 92 157 #endif // WebKitSystemInterface_h
Note: See TracChangeset
for help on using the changeset viewer.