| Differences between
and this patch
- WebCore/ChangeLog +23 lines
Lines 1-3 WebCore/ChangeLog_sec1
1
2009-06-17  Brent Fulgham  <bfulgham@webkit.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Final cleanups in this refactoring:
6
        (1) Move WindowsBitmap implementation from CG-specific file to
7
            the platform-common GraphicsContextWin.cpp, since it is
8
            equally useful on both platforms.
9
        (2) Revise the TransformationMatrix logic as suggested by
10
            Adam Roben in his review comments to Part #2 of this
11
            refactoring.
12
13
        * platform/graphics/win/GraphicsContextCGWin.cpp:
14
        * platform/graphics/win/GraphicsContextWin.cpp:
15
        (WebCore::GraphicsContext::WindowsBitmap::WindowsBitmap):
16
        (WebCore::GraphicsContext::WindowsBitmap::~WindowsBitmap):
17
        (WebCore::GraphicsContext::createWindowsBitmap):
18
        (WebCore::GraphicsContext::getWindowsContext):
19
        (WebCore::GraphicsContextPlatformPrivate::scale):
20
        (WebCore::GraphicsContextPlatformPrivate::rotate):
21
        (WebCore::GraphicsContextPlatformPrivate::translate):
22
        (WebCore::GraphicsContextPlatformPrivate::concatCTM):
23
1
2009-06-17  Brent Fulgham  <bfulgham@webkit.org>
24
2009-06-17  Brent Fulgham  <bfulgham@webkit.org>
2
25
3
        Reviewed by Eric Seidel.
26
        Reviewed by Eric Seidel.
- WebCore/platform/graphics/win/GraphicsContextCGWin.cpp -36 lines
Lines 26-32 WebCore/platform/graphics/win/GraphicsContextCGWin.cpp_sec1
26
#include "config.h"
26
#include "config.h"
27
#include "GraphicsContext.h"
27
#include "GraphicsContext.h"
28
28
29
#include "BitmapInfo.h"
30
#include "TransformationMatrix.h"
29
#include "TransformationMatrix.h"
31
#include "Path.h"
30
#include "Path.h"
32
31
Lines 113-153 void GraphicsContext::releaseWindowsCont WebCore/platform/graphics/win/GraphicsContextCGWin.cpp_sec2
113
    m_data->restore();
112
    m_data->restore();
114
}
113
}
115
114
116
GraphicsContext::WindowsBitmap::WindowsBitmap(HDC hdc, IntSize size)
117
    : m_hdc(0)
118
    , m_size(size)
119
{
120
    BitmapInfo bitmapInfo = BitmapInfo::create(m_size);
121
122
    m_bitmap = CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, reinterpret_cast<void**>(&m_bitmapBuffer), 0, 0);
123
    if (!m_bitmap)
124
        return;
125
126
    m_hdc = CreateCompatibleDC(hdc);
127
    SelectObject(m_hdc, m_bitmap);
128
129
    BITMAP bmpInfo;
130
    GetObject(m_bitmap, sizeof(bmpInfo), &bmpInfo);
131
    m_bytesPerRow = bmpInfo.bmWidthBytes;
132
    m_bitmapBufferLength = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
133
134
    SetGraphicsMode(m_hdc, GM_ADVANCED);
135
}
136
137
GraphicsContext::WindowsBitmap::~WindowsBitmap()
138
{
139
    if (!m_bitmap)
140
        return;
141
142
    DeleteDC(m_hdc);
143
    DeleteObject(m_bitmap);
144
}
145
146
GraphicsContext::WindowsBitmap* GraphicsContext::createWindowsBitmap(IntSize size)
147
{
148
    return new WindowsBitmap(m_data->m_hdc, size);
149
}
150
151
void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& point)
115
void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& point)
152
{
116
{
153
    RetainPtr<CGColorSpaceRef> deviceRGB(AdoptCF, CGColorSpaceCreateDeviceRGB());
117
    RetainPtr<CGColorSpaceRef> deviceRGB(AdoptCF, CGColorSpaceCreateDeviceRGB());
- WebCore/platform/graphics/win/GraphicsContextWin.cpp -16 / +39 lines
Lines 64-69 bool GraphicsContext::shouldIncludeChild WebCore/platform/graphics/win/GraphicsContextWin.cpp_sec1
64
    return m_data->m_shouldIncludeChildWindows;
64
    return m_data->m_shouldIncludeChildWindows;
65
}
65
}
66
66
67
GraphicsContext::WindowsBitmap::WindowsBitmap(HDC hdc, IntSize size)
68
    : m_hdc(0)
69
    , m_size(size)
70
{
71
    BitmapInfo bitmapInfo = BitmapInfo::create(m_size);
72
73
    m_bitmap = CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, reinterpret_cast<void**>(&m_bitmapBuffer), 0, 0);
74
    if (!m_bitmap)
75
        return;
76
77
    m_hdc = CreateCompatibleDC(hdc);
78
    SelectObject(m_hdc, m_bitmap);
79
80
    BITMAP bmpInfo;
81
    GetObject(m_bitmap, sizeof(bmpInfo), &bmpInfo);
82
    m_bytesPerRow = bmpInfo.bmWidthBytes;
83
    m_bitmapBufferLength = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
84
85
    SetGraphicsMode(m_hdc, GM_ADVANCED);
86
}
87
88
GraphicsContext::WindowsBitmap::~WindowsBitmap()
89
{
90
    if (!m_bitmap)
91
        return;
92
93
    DeleteDC(m_hdc);
94
    DeleteObject(m_bitmap);
95
}
96
97
GraphicsContext::WindowsBitmap* GraphicsContext::createWindowsBitmap(IntSize size)
98
{
99
    return new WindowsBitmap(m_data->m_hdc, size);
100
}
101
67
HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
102
HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
68
{
103
{
69
    // FIXME: Should a bitmap be created also when a shadow is set?
104
    // FIXME: Should a bitmap be created also when a shadow is set?
Lines 90-97 HDC GraphicsContext::getWindowsContext(c WebCore/platform/graphics/win/GraphicsContextWin.cpp_sec2
90
        SetGraphicsMode(bitmapDC, GM_ADVANCED);
125
        SetGraphicsMode(bitmapDC, GM_ADVANCED);
91
126
92
        // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap.
127
        // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap.
93
        TransformationMatrix translate(1.0f, 0.0f, 0.0f, 1.0f, -dstRect.x(), -dstRect.y());
128
        XFORM xform = TransformationMatrix().translate(-dstRect.x(), -dstRect.y());
94
        XFORM xform = translate;
95
129
96
        ::SetWorldTransform(bitmapDC, &xform);
130
        ::SetWorldTransform(bitmapDC, &xform);
97
131
Lines 134-142 void GraphicsContextPlatformPrivate::sca WebCore/platform/graphics/win/GraphicsContextWin.cpp_sec3
134
    if (!m_hdc)
168
    if (!m_hdc)
135
        return;
169
        return;
136
170
137
    TransformationMatrix scale(size.width(), 0.0f, 0.0f, size.height(), 0.0f, 0.0f);
171
    XFORM xform = TransformationMatrix().scale(size.width(), size.height());
138
139
    XFORM xform = scale;
140
    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
172
    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
141
}
173
}
142
174
Lines 144-156 static const double deg2rad = 0.01745329 WebCore/platform/graphics/win/GraphicsContextWin.cpp_sec4
144
176
145
void GraphicsContextPlatformPrivate::rotate(float degreesAngle)
177
void GraphicsContextPlatformPrivate::rotate(float degreesAngle)
146
{
178
{
147
    float radiansAngle = degreesAngle * deg2rad;
179
    XFORM xform = TransformationMatrix().rotate(degreesAngle);
148
    float cosAngle = cosf(radiansAngle);
149
    float sinAngle = sinf(radiansAngle);
150
151
    TransformationMatrix rotate(cosAngle, -sinAngle, sinAngle, cosAngle, 0.0f, 0.0f);
152
153
    XFORM xform = rotate;
154
    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
180
    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
155
}
181
}
156
182
Lines 159-167 void GraphicsContextPlatformPrivate::tra WebCore/platform/graphics/win/GraphicsContextWin.cpp_sec5
159
    if (!m_hdc)
185
    if (!m_hdc)
160
        return;
186
        return;
161
187
162
    TransformationMatrix translate(1.0f, 0.0f, 0.0f, 1.0f, x, y);
188
    XFORM xform = TransformationMatrix().translate(x, y);
163
164
    XFORM xform = translate;
165
    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
189
    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
166
}
190
}
167
191
Lines 171-177 void GraphicsContextPlatformPrivate::con WebCore/platform/graphics/win/GraphicsContextWin.cpp_sec6
171
        return;
195
        return;
172
196
173
    XFORM xform = transform;
197
    XFORM xform = transform;
174
175
    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
198
    ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
176
}
199
}
177
200

Return to Bug 26425