diff options
Diffstat (limited to 'WebCore/platform/graphics/win/GraphicsContextCGWin.cpp')
-rw-r--r-- | WebCore/platform/graphics/win/GraphicsContextCGWin.cpp | 126 |
1 files changed, 5 insertions, 121 deletions
diff --git a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp index 917631b..9eaf54b 100644 --- a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp +++ b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp @@ -77,64 +77,6 @@ GraphicsContext::GraphicsContext(HDC hdc, bool hasAlpha) // FIXME: Is it possible to merge getWindowsContext and createWindowsBitmap into a single API // suitable for all clients? -HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap) -{ - // FIXME: Should a bitmap be created also when a shadow is set? - if (mayCreateBitmap && inTransparencyLayer()) { - if (dstRect.isEmpty()) - return 0; - - // Create a bitmap DC in which to draw. - BITMAPINFO bitmapInfo; - bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bitmapInfo.bmiHeader.biWidth = dstRect.width(); - bitmapInfo.bmiHeader.biHeight = dstRect.height(); - bitmapInfo.bmiHeader.biPlanes = 1; - bitmapInfo.bmiHeader.biBitCount = 32; - bitmapInfo.bmiHeader.biCompression = BI_RGB; - bitmapInfo.bmiHeader.biSizeImage = 0; - bitmapInfo.bmiHeader.biXPelsPerMeter = 0; - bitmapInfo.bmiHeader.biYPelsPerMeter = 0; - bitmapInfo.bmiHeader.biClrUsed = 0; - bitmapInfo.bmiHeader.biClrImportant = 0; - - void* pixels = 0; - HBITMAP bitmap = ::CreateDIBSection(NULL, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0); - if (!bitmap) - return 0; - - HDC bitmapDC = ::CreateCompatibleDC(m_data->m_hdc); - ::SelectObject(bitmapDC, bitmap); - - // Fill our buffer with clear if we're going to alpha blend. - if (supportAlphaBlend) { - BITMAP bmpInfo; - GetObject(bitmap, sizeof(bmpInfo), &bmpInfo); - int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight; - memset(bmpInfo.bmBits, 0, bufferSize); - } - - // Make sure we can do world transforms. - SetGraphicsMode(bitmapDC, GM_ADVANCED); - - // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap. - XFORM xform; - xform.eM11 = 1.0f; - xform.eM12 = 0.0f; - xform.eM21 = 0.0f; - xform.eM22 = 1.0f; - xform.eDx = -dstRect.x(); - xform.eDy = -dstRect.y(); - ::SetWorldTransform(bitmapDC, &xform); - - return bitmapDC; - } - - CGContextFlush(platformContext()); - m_data->save(); - return m_data->m_hdc; -} - void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap) { if (mayCreateBitmap && hdc && inTransparencyLayer()) { @@ -170,52 +112,6 @@ void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, boo m_data->restore(); } -GraphicsContext::WindowsBitmap::WindowsBitmap(HDC hdc, IntSize size) - : m_hdc(0) - , m_size(size) -{ - BITMAPINFO bitmapInfo; - bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bitmapInfo.bmiHeader.biWidth = m_size.width(); - bitmapInfo.bmiHeader.biHeight = m_size.height(); - bitmapInfo.bmiHeader.biPlanes = 1; - bitmapInfo.bmiHeader.biBitCount = 32; - bitmapInfo.bmiHeader.biCompression = BI_RGB; - bitmapInfo.bmiHeader.biSizeImage = 0; - bitmapInfo.bmiHeader.biXPelsPerMeter = 0; - bitmapInfo.bmiHeader.biYPelsPerMeter = 0; - bitmapInfo.bmiHeader.biClrUsed = 0; - bitmapInfo.bmiHeader.biClrImportant = 0; - - m_bitmap = CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, reinterpret_cast<void**>(&m_bitmapBuffer), 0, 0); - if (!m_bitmap) - return; - - m_hdc = CreateCompatibleDC(hdc); - SelectObject(m_hdc, m_bitmap); - - BITMAP bmpInfo; - GetObject(m_bitmap, sizeof(bmpInfo), &bmpInfo); - m_bytesPerRow = bmpInfo.bmWidthBytes; - m_bitmapBufferLength = bmpInfo.bmWidthBytes * bmpInfo.bmHeight; - - SetGraphicsMode(m_hdc, GM_ADVANCED); -} - -GraphicsContext::WindowsBitmap::~WindowsBitmap() -{ - if (!m_bitmap) - return; - - DeleteDC(m_hdc); - DeleteObject(m_bitmap); -} - -GraphicsContext::WindowsBitmap* GraphicsContext::createWindowsBitmap(IntSize size) -{ - return new WindowsBitmap(m_data->m_hdc, size); -} - void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& point) { RetainPtr<CGColorSpaceRef> deviceRGB(AdoptCF, CGColorSpaceCreateDeviceRGB()); @@ -228,23 +124,6 @@ void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& po CGContextDrawImage(m_data->m_cgContext, CGRectMake(point.x(), point.y(), image->size().width(), image->size().height()), cgImage.get()); } -void GraphicsContextPlatformPrivate::concatCTM(const TransformationMatrix& transform) -{ - if (!m_hdc) - return; - - CGAffineTransform mat = transform; - XFORM xform; - xform.eM11 = mat.a; - xform.eM12 = mat.b; - xform.eM21 = mat.c; - xform.eM22 = mat.d; - xform.eDx = mat.tx; - xform.eDy = mat.ty; - - ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY); -} - void GraphicsContext::drawFocusRing(const Color& color) { if (paintingDisabled()) @@ -362,4 +241,9 @@ void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& point, CGContextRestoreGState(context); } +void GraphicsContextPlatformPrivate::flush() +{ + CGContextFlush(m_cgContext); +} + } |