⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 155476 in webkit


Ignore:
Timestamp:
Sep 10, 2013, 2:40:21 PM (13 years ago)
Author:
Brent Fulgham
Message:

[Windows] Create SharedGDIObject Class Template
https://bugs.webkit.org/show_bug.cgi?id=121037

Reviewed by Anders Carlsson.

Source/WebCore:

  • WebCore.vcxproj/WebCore.vcxproj: Remove RefCountedGDIHandle.h, and

add new SharedGDIObject.h file.

  • WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
  • platform/graphics/FontPlatformData.h:

(WebCore::FontPlatformData::hfont): Switch to new SharedGDIObject.

  • platform/graphics/win/FontPlatformDataCGWin.cpp:

(WebCore::FontPlatformData::FontPlatformData): Ditto.

  • platform/graphics/win/FontPlatformDataCairoWin.cpp:

(WebCore::FontPlatformData::FontPlatformData): Ditto.

  • platform/graphics/win/FontPlatformDataWin.cpp:

(WebCore::FontPlatformData::FontPlatformData): Ditto.

  • platform/graphics/win/RefCountedGDIHandle.h: Removed.
  • platform/graphics/win/SharedGDIObject.h: Added.

(WebCore::SharedGDIObject::create):
(WebCore::SharedGDIObject::get):
(WebCore::SharedGDIObject::hash):
(WebCore::SharedGDIObject::SharedGDIObject):

Source/WebKit/win:

  • WebView.cpp: Change implementations to use the new SharedGDIObject

class.
(WebView::addToDirtyRegion):
(WebView::scrollBackingStore):
(WebView::updateBackingStore):
(WebView::performLayeredWindowUpdate):
(WebView::paint):
(WebView::backingStore):

  • WebView.h: Ditto.

Source/WTF:

Now that the SharedGDIObject class exists we can get rid of
the Windows-specific code in OwnPtr.

  • WTF.vcxproj/WTF.vcxproj: Remove OwnPtrWin.cpp.
  • WTF.vcxproj/WTF.vcxproj.filters: Ditto.
  • wtf/OwnPtrCommon.h:

(WTF::deleteOwnedPtr): Remove Windows declarations that
are no longer needed.

  • wtf/win/GDIObject.h:

(WTF::GDIObject::get): Change to 'const' to match
signature (and use cases) elsewhere in the code base for
our smart pointer classes.

  • wtf/win/OwnPtrWin.cpp: Removed.
Location:
trunk/Source
Files:
1 added
2 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r155474 r155476  
     12013-09-10  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Windows] Create SharedGDIObject Class Template
     4        https://bugs.webkit.org/show_bug.cgi?id=121037
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Now that the SharedGDIObject class exists we can get rid of
     9        the Windows-specific code in OwnPtr.
     10
     11        * WTF.vcxproj/WTF.vcxproj: Remove OwnPtrWin.cpp.
     12        * WTF.vcxproj/WTF.vcxproj.filters: Ditto.
     13        * wtf/OwnPtrCommon.h:
     14        (WTF::deleteOwnedPtr): Remove Windows declarations that
     15        are no longer needed.
     16        * wtf/win/GDIObject.h:
     17        (WTF::GDIObject::get): Change to 'const' to match
     18        signature (and use cases) elsewhere in the code base for
     19        our smart pointer classes.
     20        * wtf/win/OwnPtrWin.cpp: Removed.
     21
    1222013-09-10  Anders Carlsson  <andersca@apple.com>
    223
  • trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj

    r155454 r155476  
    113113    <ClCompile Include="..\wtf\unicode\UTF8.cpp" />
    114114    <ClCompile Include="..\wtf\win\MainThreadWin.cpp" />
    115     <ClCompile Include="..\wtf\win\OwnPtrWin.cpp" />
    116115    <ClCompile Include="..\wtf\WTFThreadData.cpp" />
    117116    <ClCompile Include="..\wtf\SchedulePairCF.cpp" />
  • trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters

    r155454 r155476  
    7777    </ClCompile>
    7878    <ClCompile Include="..\wtf\win\MainThreadWin.cpp">
    79       <Filter>win</Filter>
    80     </ClCompile>
    81     <ClCompile Include="..\wtf\win\OwnPtrWin.cpp">
    8279      <Filter>win</Filter>
    8380    </ClCompile>
  • trunk/Source/WTF/wtf/OwnPtrCommon.h

    r155454 r155476  
    11/*
    2  * Copyright (C) 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
    33 * Copyright (C) 2009 Torch Mobile, Inc.
    44 * Copyright (C) 2010 Company 100 Inc.
     
    2929#define WTF_OwnPtrCommon_h
    3030
    31 #if OS(WINDOWS)
    32 typedef struct HBITMAP__* HBITMAP;
    33 typedef struct HDC__* HDC;
    34 typedef struct HRGN__* HRGN;
    35 #endif
    36 
    3731#if PLATFORM(EFL)
    3832typedef struct _Ecore_Evas Ecore_Evas;
     
    6054    }
    6155
    62 #if OS(WINDOWS)
    63     WTF_EXPORT_PRIVATE void deleteOwnedPtr(HBITMAP);
    64     WTF_EXPORT_PRIVATE void deleteOwnedPtr(HDC);
    65     WTF_EXPORT_PRIVATE void deleteOwnedPtr(HRGN);
    66 #endif
    67 
    6856#if PLATFORM(EFL)
    6957    WTF_EXPORT_PRIVATE void deleteOwnedPtr(Ecore_Evas*);
  • trunk/Source/WTF/wtf/win/GDIObject.h

    r155454 r155476  
    4343    ~GDIObject() { deleteObject<T>(m_object); }
    4444
    45     T get() { return m_object; }
     45    T get() const { return m_object; }
    4646
    4747    void clear();
  • trunk/Source/WebCore/ChangeLog

    r155468 r155476  
     12013-09-10  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Windows] Create SharedGDIObject Class Template
     4        https://bugs.webkit.org/show_bug.cgi?id=121037
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebCore.vcxproj/WebCore.vcxproj: Remove RefCountedGDIHandle.h, and
     9        add new SharedGDIObject.h file.
     10        * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
     11        * platform/graphics/FontPlatformData.h:
     12        (WebCore::FontPlatformData::hfont): Switch to new SharedGDIObject.
     13        * platform/graphics/win/FontPlatformDataCGWin.cpp:
     14        (WebCore::FontPlatformData::FontPlatformData): Ditto.
     15        * platform/graphics/win/FontPlatformDataCairoWin.cpp:
     16        (WebCore::FontPlatformData::FontPlatformData): Ditto.
     17        * platform/graphics/win/FontPlatformDataWin.cpp:
     18        (WebCore::FontPlatformData::FontPlatformData): Ditto.
     19        * platform/graphics/win/RefCountedGDIHandle.h: Removed.
     20        * platform/graphics/win/SharedGDIObject.h: Added.
     21        (WebCore::SharedGDIObject::create):
     22        (WebCore::SharedGDIObject::get):
     23        (WebCore::SharedGDIObject::hash):
     24        (WebCore::SharedGDIObject::SharedGDIObject):
     25
    1262013-09-10  Tim Horton  <timothy_horton@apple.com>
    227
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r155454 r155476  
    1930019300    <ClInclude Include="..\platform\graphics\opengl\GLPlatformSurface.h" />
    1930119301    <ClInclude Include="..\platform\graphics\VideoTrackPrivate.h" />
     19302    <ClInclude Include="..\platform\graphics\win\SharedGDIObject.h" />
    1930219303    <ClInclude Include="..\platform\HistogramSupport.h" />
    1930319304    <ClInclude Include="..\platform\HostWindow.h" />
     
    1946819469    <ClInclude Include="..\platform\graphics\opentype\OpenTypeUtilities.h" />
    1946919470    <ClInclude Include="..\platform\graphics\opentype\OpenTypeVerticalData.h" />
    19470     <ClInclude Include="..\platform\graphics\win\RefCountedGDIHandle.h" />
    1947119471    <ClInclude Include="..\platform\graphics\win\UniscribeController.h" />
    1947219472    <CustomBuildStep Include="..\platform\graphics\win\WKCAImageQueue.h">
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r155454 r155476  
    70987098      <Filter>platform\win</Filter>
    70997099    </ClCompile>
     7100    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSBeforeUnloadEvent.cpp" />
     7101    <ClCompile Include="..\rendering\FloatingObjects.cpp" />
    71007102  </ItemGroup>
    71017103  <ItemGroup>
     
    85828584      <Filter>platform\graphics\win</Filter>
    85838585    </ClInclude>
    8584     <ClInclude Include="..\platform\graphics\win\RefCountedGDIHandle.h">
    8585       <Filter>platform\graphics\win</Filter>
    8586     </ClInclude>
    85878586    <ClInclude Include="..\platform\graphics\win\UniscribeController.h">
    85888587      <Filter>platform\graphics\win</Filter>
     
    1489814897    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\HTMLElementTypeHelpers.h" />
    1489914898    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\SVGElementTypeHelpers.h" />
     14899    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSBeforeUnloadEvent.h" />
     14900    <ClInclude Include="..\rendering\FloatingObjects.h" />
     14901    <ClInclude Include="..\platform\graphics\win\SharedGDIObject.h">
     14902      <Filter>platform\graphics\win</Filter>
     14903    </ClInclude>
    1490014904  </ItemGroup>
    1490114905  <ItemGroup>
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.h

    r155454 r155476  
    4141
    4242#if PLATFORM(WIN)
    43 #include "RefCountedGDIHandle.h"
     43#include "SharedGDIObject.h"
    4444#endif
    4545
     
    113113
    114114#if PLATFORM(WIN)
    115     HFONT hfont() const { return m_font ? m_font->handle() : 0; }
     115    HFONT hfont() const { return m_font ? m_font->get() : 0; }
    116116    bool useGDI() const { return m_useGDI; }
    117117#elif OS(DARWIN)
     
    229229    NSFont* m_font;
    230230#elif PLATFORM(WIN)
    231     RefPtr<RefCountedGDIHandle<HFONT> > m_font;
     231    RefPtr<SharedGDIObject<HFONT>> m_font;
    232232#endif
    233233
  • trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp

    r149716 r155476  
    2525#include "FontPlatformData.h"
    2626
     27#include "SharedGDIObject.h"
    2728#include <ApplicationServices/ApplicationServices.h>
    2829#include <WebKitSystemInterface/WebKitSystemInterface.h>
     
    121122    , m_size(size)
    122123    , m_widthVariant(RegularWidth)
    123     , m_font(RefCountedGDIHandle<HFONT>::create(hfont))
     124    , m_font(SharedGDIObject<HFONT>::create(adoptGDIObject<HFONT>(hfont)))
    124125    , m_cgFont(font)
    125126    , m_isColorBitmapFont(false)
  • trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp

    r151743 r155476  
    5858
    5959FontPlatformData::FontPlatformData(HFONT font, cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
    60     : m_font(RefCountedGDIHandle<HFONT>::create(font))
     60    : m_font(SharedGDIObject<HFONT>::create(adoptGDIObject<HFONT>(font)))
    6161    , m_size(size)
    6262    , m_orientation(Horizontal)
  • trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp

    r136520 r155476  
    3939
    4040FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique, bool useGDI)
    41     : m_font(RefCountedGDIHandle<HFONT>::create(font))
     41    : m_font(SharedGDIObject<HFONT>::create(adoptGDIObject<HFONT>(font)))
    4242    , m_size(size)
    4343    , m_orientation(Horizontal)
  • trunk/Source/WebKit/win/ChangeLog

    r155454 r155476  
     12013-09-10  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Windows] Create SharedGDIObject Class Template
     4        https://bugs.webkit.org/show_bug.cgi?id=121037
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebView.cpp: Change implementations to use the new SharedGDIObject
     9        class.
     10        (WebView::addToDirtyRegion):
     11        (WebView::scrollBackingStore):
     12        (WebView::updateBackingStore):
     13        (WebView::performLayeredWindowUpdate):
     14        (WebView::paint):
     15        (WebView::backingStore):
     16        * WebView.h: Ditto.
     17
    1182013-09-09  Brent Fulgham  <bfulgham@apple.com>
    219
  • trunk/Source/WebKit/win/WebView.cpp

    r155454 r155476  
    824824
    825825        void* pixels = NULL;
    826         m_backingStoreBitmap = RefCountedHBITMAP::create(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0));
     826        m_backingStoreBitmap = SharedGDIObject<HBITMAP>::create(adoptGDIObject(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0)));
    827827        return true;
    828828    }
     
    844844#endif
    845845
    846     HRGN newRegion = ::CreateRectRgn(dirtyRect.x(), dirtyRect.y(),
    847                                      dirtyRect.maxX(), dirtyRect.maxY());
    848     addToDirtyRegion(newRegion);
    849 }
    850 
    851 void WebView::addToDirtyRegion(HRGN newRegion)
     846    auto newRegion = adoptGDIObject(::CreateRectRgn(dirtyRect.x(), dirtyRect.y(),
     847        dirtyRect.maxX(), dirtyRect.maxY()));
     848    addToDirtyRegion(std::move(newRegion));
     849}
     850
     851void WebView::addToDirtyRegion(GDIObject<HRGN> newRegion)
    852852{
    853853#if USE(ACCELERATED_COMPOSITING)
     
    858858
    859859    if (m_backingStoreDirtyRegion) {
    860         HRGN combinedRegion = ::CreateRectRgn(0,0,0,0);
    861         ::CombineRgn(combinedRegion, m_backingStoreDirtyRegion->handle(), newRegion, RGN_OR);
    862         ::DeleteObject(newRegion);
    863         m_backingStoreDirtyRegion = RefCountedHRGN::create(combinedRegion);
     860        auto combinedRegion = adoptGDIObject(::CreateRectRgn(0, 0, 0, 0));
     861        ::CombineRgn(combinedRegion.get(), m_backingStoreDirtyRegion->get(), newRegion.get(), RGN_OR);
     862        m_backingStoreDirtyRegion = SharedGDIObject<HRGN>::create(std::move(combinedRegion));
    864863    } else
    865         m_backingStoreDirtyRegion = RefCountedHRGN::create(newRegion);
     864        m_backingStoreDirtyRegion = SharedGDIObject<HRGN>::create(std::move(newRegion));
    866865
    867866    if (m_uiDelegatePrivate)
     
    891890
    892891    // Make a region to hold the invalidated scroll area.
    893     HRGN updateRegion = ::CreateRectRgn(0, 0, 0, 0);
     892    auto updateRegion = adoptGDIObject(::CreateRectRgn(0, 0, 0, 0));
    894893
    895894    // Collect our device context info and select the bitmap to scroll.
    896895    HWndDC windowDC(m_viewWindow);
    897896    auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(windowDC));
    898     HGDIOBJ oldBitmap = ::SelectObject(bitmapDC.get(), m_backingStoreBitmap->handle());
     897    HGDIOBJ oldBitmap = ::SelectObject(bitmapDC.get(), m_backingStoreBitmap->get());
    899898   
    900899    // Scroll the bitmap.
    901900    RECT scrollRectWin(scrollViewRect);
    902901    RECT clipRectWin(clipRect);
    903     ::ScrollDC(bitmapDC.get(), dx, dy, &scrollRectWin, &clipRectWin, updateRegion, 0);
     902    ::ScrollDC(bitmapDC.get(), dx, dy, &scrollRectWin, &clipRectWin, updateRegion.get(), 0);
    904903    RECT regionBox;
    905     ::GetRgnBox(updateRegion, &regionBox);
     904    ::GetRgnBox(updateRegion.get(), &regionBox);
    906905
    907906    // Flush.
     
    909908
    910909    // Add the dirty region to the backing store's dirty region.
    911     addToDirtyRegion(updateRegion);
     910    addToDirtyRegion(std::move(updateRegion));
    912911
    913912    if (m_uiDelegatePrivate)
     
    996995        bitmapDCObject = adoptGDIObject(::CreateCompatibleDC(windowDC));
    997996        bitmapDC = bitmapDCObject.get();
    998         oldBitmap = ::SelectObject(bitmapDC, m_backingStoreBitmap->handle());
     997        oldBitmap = ::SelectObject(bitmapDC, m_backingStoreBitmap->get());
    999998    }
    1000999
     
    10081007        if (!backingStoreCompletelyDirty && m_backingStoreDirtyRegion) {
    10091008            RECT regionBox;
    1010             ::GetRgnBox(m_backingStoreDirtyRegion->handle(), &regionBox);
    1011             getUpdateRects(m_backingStoreDirtyRegion->handle(), regionBox, paintRects);
     1009            ::GetRgnBox(m_backingStoreDirtyRegion->get(), &regionBox);
     1010            getUpdateRects(m_backingStoreDirtyRegion->get(), regionBox, paintRects);
    10121011        } else {
    10131012            RECT clientRect;
     
    10391038    HWndDC hdcScreen(m_viewWindow);
    10401039    auto hdcMem = adoptGDIObject(::CreateCompatibleDC(hdcScreen));
    1041     HBITMAP hbmOld = static_cast<HBITMAP>(::SelectObject(hdcMem.get(), m_backingStoreBitmap->handle()));
     1040    HBITMAP hbmOld = static_cast<HBITMAP>(::SelectObject(hdcMem.get(), m_backingStoreBitmap->get()));
    10421041
    10431042    BITMAP bmpInfo;
    1044     ::GetObject(m_backingStoreBitmap->handle(), sizeof(bmpInfo), &bmpInfo);
     1043    ::GetObject(m_backingStoreBitmap->get(), sizeof(bmpInfo), &bmpInfo);
    10451044    SIZE windowSize = { bmpInfo.bmWidth, bmpInfo.bmHeight };
    10461045
     
    10811080    RECT rcPaint;
    10821081    HDC hdc;
    1083     OwnPtr<HRGN> region;
     1082    GDIObject<HRGN> region;
    10841083    int regionType = NULLREGION;
    10851084    PAINTSTRUCT ps;
    10861085    WindowsToPaint windowsToPaint;
    10871086    if (!dc) {
    1088         region = adoptPtr(CreateRectRgn(0,0,0,0));
     1087        region = adoptGDIObject(::CreateRectRgn(0, 0, 0, 0));
    10891088        regionType = GetUpdateRgn(m_viewWindow, region.get(), false);
    10901089        hdc = BeginPaint(m_viewWindow, &ps);
     
    11131112
    11141113    auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(hdc));
    1115     HGDIOBJ oldBitmap = ::SelectObject(bitmapDC.get(), m_backingStoreBitmap->handle());
     1114    HGDIOBJ oldBitmap = ::SelectObject(bitmapDC.get(), m_backingStoreBitmap->get());
    11161115
    11171116    // Update our backing store if needed.
     
    59815980    if (!m_backingStoreBitmap)
    59825981        return E_FAIL;
    5983     *hBitmap = reinterpret_cast<OLE_HANDLE>(m_backingStoreBitmap->handle());
     5982    *hBitmap = reinterpret_cast<OLE_HANDLE>(m_backingStoreBitmap->get());
    59845983    return S_OK;
    59855984}
  • trunk/Source/WebKit/win/WebView.h

    r154759 r155476  
    3535#include <WebCore/DragActions.h>
    3636#include <WebCore/IntRect.h>
    37 #include <WebCore/RefCountedGDIHandle.h>
     37#include <WebCore/SharedGDIObject.h>
    3838#include <WebCore/SuspendableTimer.h>
    3939#include <WebCore/WindowMessageListener.h>
     
    7070class WebInspector;
    7171class WebInspectorClient;
    72 
    73 typedef WebCore::RefCountedGDIHandle<HBITMAP> RefCountedHBITMAP;
    74 typedef WebCore::RefCountedGDIHandle<HRGN> RefCountedHRGN;
    7572
    7673WebView* kit(WebCore::Page*);
     
    881878    bool ensureBackingStore();
    882879    void addToDirtyRegion(const WebCore::IntRect&);
    883     void addToDirtyRegion(HRGN);
     880    void addToDirtyRegion(GDIObject<HRGN>);
    884881    void scrollBackingStore(WebCore::FrameView*, int dx, int dy, const WebCore::IntRect& scrollViewRect, const WebCore::IntRect& clipRect);
    885882    void deleteBackingStore();
     
    10871084#endif // ENABLE(INSPECTOR)
    10881085   
    1089     RefPtr<RefCountedHBITMAP> m_backingStoreBitmap;
     1086    RefPtr<WebCore::SharedGDIObject<HBITMAP>> m_backingStoreBitmap;
    10901087    SIZE m_backingStoreSize;
    1091     RefPtr<RefCountedHRGN> m_backingStoreDirtyRegion;
     1088    RefPtr<WebCore::SharedGDIObject<HRGN>> m_backingStoreDirtyRegion;
    10921089
    10931090    COMPtr<IAccessibilityDelegate> m_accessibilityDelegate;
Note: See TracChangeset for help on using the changeset viewer.