Changeset 70129 in webkit


Ignore:
Timestamp:
Oct 19, 2010 11:36:00 PM (14 years ago)
Author:
Adam Roben
Message:

Remove uses of CACFContextRef and CARender* from WebCore

These types are now wrapped in a WKCACFContext type exported by
WebKitSystemInterface.

Fixes <http://webkit.org/b/43244>.

Reviewed by Sam Weinig.

WebCore:

  • platform/graphics/win/WKCACFContextFlusher.cpp:

(WebCore::WKCACFContextFlusher::addContext):
(WebCore::WKCACFContextFlusher::removeContext):
(WebCore::WKCACFContextFlusher::flushAllContexts):

  • platform/graphics/win/WKCACFContextFlusher.h:

Changed to use WKCACFContext. We don't retain/release the context when
putting it into/taking it out of the set. WKCACFContext is not a
ref-counted type, so we can't retain/release it, but the
retain/release was also unnecessary as WKCACFLayerRenderer calls
removeContext before the context is destroyed.

  • platform/graphics/win/WKCACFLayer.cpp:

(WebCore::WKCACFLayer::becomeRootLayerForContext):

  • platform/graphics/win/WKCACFLayer.h:

Changed to use WKCACFContext.

  • platform/graphics/win/WKCACFLayerRenderer.cpp:

(WebCore::WKCACFLayerRenderer::didFlushContext):
(WebCore::WKCACFLayerRenderer::WKCACFLayerRenderer):
(WebCore::WKCACFLayerRenderer::~WKCACFLayerRenderer):
(WebCore::WKCACFLayerRenderer::layerTreeDidChange):
(WebCore::WKCACFLayerRenderer::createRenderer):
(WebCore::WKCACFLayerRenderer::destroyRenderer):
(WebCore::WKCACFLayerRenderer::render): Also replaced uses of
CGSRegion with WebKitSystemInterface functions/types.
(WebCore::WKCACFLayerRenderer::resetDevice):

  • platform/graphics/win/WKCACFLayerRenderer.h:

Replaced our CACFContextRef, CARenderContext, and CARenderOGLContext
with a single WKCACFContext, which wraps all three. We hold a bare
pointer to it and destroy it in our destructor.

WebKitLibraries:

Add WKCACFContext and related functions

  • win/lib/WebKitSystemInterface.lib:
  • win/lib/WebKitSystemInterface_debug.lib:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r70118 r70129  
     12010-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
    1432010-10-19  Yongjun Zhang  <yongjun_zhang@apple.com>
    244
  • trunk/WebCore/platform/graphics/win/WKCACFContextFlusher.cpp

    r64364 r70129  
    3030#include "WKCACFContextFlusher.h"
    3131
     32#include <WebKitSystemInterface/WebKitSystemInterface.h>
    3233#include <wtf/StdLibExtras.h>
    33 #include <QuartzCore/CACFContext.h>
    3434
    3535namespace WebCore {
     
    4949}
    5050
    51 void WKCACFContextFlusher::addContext(CACFContextRef context)
     51void WKCACFContextFlusher::addContext(WKCACFContext* context)
    5252{
    5353    ASSERT(context);
    5454
    55     if (m_contexts.add(context).second)
    56         CFRetain(context);
     55    m_contexts.add(context);
    5756}
    5857
    59 void WKCACFContextFlusher::removeContext(CACFContextRef context)
     58void WKCACFContextFlusher::removeContext(WKCACFContext* context)
    6059{
    6160    ASSERT(context);
    6261
    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);
    6963}
    7064
     
    7771
    7872    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);
    8475}
    8576
  • trunk/WebCore/platform/graphics/win/WKCACFContextFlusher.h

    r64364 r70129  
    3333#include <wtf/HashSet.h>
    3434
    35 typedef struct _CACFContext* CACFContextRef;
     35struct WKCACFContext;
    3636
    3737namespace WebCore {
     
    4141    static WKCACFContextFlusher& shared();
    4242
    43     void addContext(CACFContextRef);
    44     void removeContext(CACFContextRef);
     43    void addContext(WKCACFContext*);
     44    void removeContext(WKCACFContext*);
    4545
    4646    void flushAllContexts();
     
    5050    ~WKCACFContextFlusher();
    5151
    52     typedef HashSet<CACFContextRef> ContextSet;
     52    typedef HashSet<WKCACFContext*> ContextSet;
    5353    ContextSet m_contexts;
    5454};
  • trunk/WebCore/platform/graphics/win/WKCACFLayer.cpp

    r67285 r70129  
    3131
    3232#include "WKCACFLayerRenderer.h"
     33#include <WebKitSystemInterface/WebKitSystemInterface.h>
     34#include <stdio.h>
     35#include <wtf/CurrentTime.h>
    3336#include <wtf/text/CString.h>
    34 
    35 #include <stdio.h>
    36 #include <QuartzCore/CACFContext.h>
    37 #include <QuartzCore/CARender.h>
    38 
    39 #ifndef NDEBUG
    40 #include <wtf/CurrentTime.h>
    41 #endif
    4237
    4338namespace WebCore {
     
    191186}
    192187
    193 void WKCACFLayer::becomeRootLayerForContext(CACFContextRef context)
    194 {
    195     CACFContextSetLayer(context, layer());
     188void WKCACFLayer::becomeRootLayerForContext(WKCACFContext* context)
     189{
     190    wkCACFContextSetLayer(context, layer());
    196191    setNeedsCommit();
    197192}
  • trunk/WebCore/platform/graphics/win/WKCACFLayer.h

    r66050 r70129  
    4242#include "TransformationMatrix.h"
    4343
     44struct WKCACFContext;
     45
    4446namespace WebCore {
    4547
     
    8486
    8587    // Makes this layer the root when the passed context is rendered
    86     void becomeRootLayerForContext(CACFContextRef);
     88    void becomeRootLayerForContext(WKCACFContext*);
    8789
    8890    static RetainPtr<CFTypeRef> cfValue(float value) { return RetainPtr<CFTypeRef>(AdoptCF, CFNumberCreate(0, kCFNumberFloat32Type, &value)); }
  • trunk/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp

    r69259 r70129  
    3737#include "WKCACFLayer.h"
    3838#include "WebCoreInstanceHandle.h"
    39 #include <CoreGraphics/CGSRegion.h>
    40 #include <QuartzCore/CACFContext.h>
    41 #include <QuartzCore/CARenderOGL.h>
     39#include <WebKitSystemInterface/WebKitSystemInterface.h>
    4240#include <wtf/HashMap.h>
    4341#include <wtf/OwnArrayPtr.h>
     
    109107};
    110108
    111 typedef HashMap<CACFContextRef, WKCACFLayerRenderer*> ContextToWindowMap;
     109typedef HashMap<WKCACFContext*, WKCACFLayerRenderer*> ContextToWindowMap;
    112110
    113111static ContextToWindowMap& windowsForContexts()
     
    207205}
    208206
    209 void WKCACFLayerRenderer::didFlushContext(CACFContextRef context)
     207void WKCACFLayerRenderer::didFlushContext(WKCACFContext* context)
    210208{
    211209    WKCACFLayerRenderer* window = windowsForContexts().get(context);
     
    227225    , m_mightBeAbleToCreateDeviceLater(true)
    228226    , 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())
    232228    , m_hostWindow(0)
    233229    , m_renderTimer(this, &WKCACFLayerRenderer::renderTimerFired)
     
    235231    , m_mustResetLostDeviceBeforeRendering(false)
    236232{
    237     windowsForContexts().set(m_context.get(), this);
     233    windowsForContexts().set(m_context, this);
    238234
    239235    // Under the root layer, we have a clipping layer to clip the content,
     
    257253
    258254    if (m_context)
    259         m_rootLayer->becomeRootLayerForContext(m_context.get());
     255        m_rootLayer->becomeRootLayerForContext(m_context);
    260256
    261257#ifndef NDEBUG
     
    268264{
    269265    destroyRenderer();
     266    wkCACFContextDestroy(m_context);
    270267}
    271268
     
    299296void WKCACFLayerRenderer::layerTreeDidChange()
    300297{
    301     WKCACFContextFlusher::shared().addContext(m_context.get());
     298    WKCACFContextFlusher::shared().addContext(m_context);
    302299    renderSoon();
    303300}
     
    374371    initD3DGeometry();
    375372
    376     m_renderer = CARenderOGLNew(&kCARenderDX9Callbacks, m_d3dDevice.get(), 0);
     373    wkCACFContextInitializeD3DDevice(m_context, m_d3dDevice.get());
    377374
    378375    if (IsWindow(m_hostWindow))
     
    385382{
    386383    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
    395388    m_d3dDevice = 0;
    396389    if (s_d3d)
     
    477470}
    478471
    479 void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects)
     472void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects)
    480473{
    481474    ASSERT(m_d3dDevice);
     
    500493
    501494    // Give the renderer some space to use. This needs to be valid until the
    502     // CARenderUpdateFinish() call below.
     495    // wkCACFContextFinishUpdate() call below.
    503496    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;
    514499
    515500    HRESULT err = S_OK;
    516501    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)
    520506            break;
    521507
    522         // FIXME: don't need to clear dirty region if layer tree is opaque.
    523 
    524508        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)) {
    527510            D3DRECT rect;
    528511            rect.x1 = r->origin.x;
     
    533516            rects.append(rect);
    534517        }
    535         CGSReleaseRegionEnumerator(e);
    536         CGSReleaseRegion(rgn);
     518        wkCACFUpdateRectEnumeratorRelease(e);
    537519
    538520        if (rects.isEmpty())
     
    542524
    543525        m_d3dDevice->BeginScene();
    544         CARenderOGLRender(m_renderer, u);
     526        wkCACFContextRenderUpdate(m_context);
    545527        m_d3dDevice->EndScene();
    546528
     
    548530
    549531        if (err == D3DERR_DEVICELOST) {
    550             CARenderUpdateAddRect(u, &bounds);
     532            wkCACFContextAddUpdateRect(m_context, bounds);
    551533            if (!resetDevice(LostDevice)) {
    552534                // We can't reset the device right now. Try again soon.
     
    557539    } while (err == D3DERR_DEVICELOST);
    558540
    559     CARenderUpdateFinish(u);
     541    wkCACFContextFinishUpdate(m_context);
    560542
    561543#ifndef NDEBUG
     
    599581{
    600582    ASSERT(m_d3dDevice);
    601     ASSERT(m_renderContext);
     583    ASSERT(m_context);
    602584
    603585    HRESULT hr = m_d3dDevice->TestCooperativeLevel();
     
    618600    // We can reset the device.
    619601
    620     // We have to purge the CARenderOGLContext whenever we reset the IDirect3DDevice9 in order to
     602    // We have to release the context's D3D resrouces whenever we reset the IDirect3DDevice9 in order to
    621603    // destroy any D3DPOOL_DEFAULT resources that Core Animation has allocated (e.g., textures used
    622604    // for mask layers). See <http://msdn.microsoft.com/en-us/library/bb174425(v=VS.85).aspx>.
    623     CARenderOGLPurge(m_renderer);
     605    wkCACFContextReleaseD3DResources(m_context);
    624606
    625607    D3DPRESENT_PARAMETERS parameters = initialPresentationParameters();
  • trunk/WebCore/platform/graphics/win/WKCACFLayerRenderer.h

    r68971 r70129  
    4242
    4343interface IDirect3DDevice9;
    44 typedef struct _CACFContext* CACFContextRef;
    45 typedef struct _CARenderContext CARenderContext;
    46 typedef struct _CARenderOGLContext CARenderOGLContext;
     44struct WKCACFContext;
    4745
    4846namespace WebCore {
     
    6563
    6664    static bool acceleratedCompositingAvailable();
    67     static void didFlushContext(CACFContextRef);
     65    static void didFlushContext(WKCACFContext*);
    6866
    6967    void setRootContents(CGImageRef);
     
    105103    RefPtr<WKCACFRootLayer> m_rootLayer;
    106104    RefPtr<WKCACFLayer> m_rootChildLayer;
    107     RetainPtr<CACFContextRef> m_context;
    108     CARenderContext* m_renderContext;
    109     CARenderOGLContext* m_renderer;
     105    WKCACFContext* m_context;
    110106    HWND m_hostWindow;
    111107    Timer<WKCACFLayerRenderer> m_renderTimer;
  • trunk/WebKitLibraries/ChangeLog

    r69797 r70129  
     12010-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
    1122010-10-14  Ada Chan  <adachan@apple.com>
    213
Note: See TracChangeset for help on using the changeset viewer.