Index: third_party/WebKit/WebCore/platform/graphics/chromium/FontChromiumWin.cpp |
=================================================================== |
--- third_party/WebKit/WebCore/platform/graphics/chromium/FontChromiumWin.cpp (revision 8367) |
+++ third_party/WebKit/WebCore/platform/graphics/chromium/FontChromiumWin.cpp (working copy) |
@@ -174,6 +174,19 @@ |
{ |
PlatformGraphicsContext* context = graphicsContext->platformContext(); |
+ bool canUseGDI = windowsCanHandleTextDrawing(graphicsContext); |
+ bool createdLayer = false; |
+ |
+ if (canUseGDI && context->isDrawingToImageBuffer()) { |
+ // We're drawing to an image buffer and about to render text with GDI. |
+ // We need to start a layer here, otherwise the alpha values rendered |
+ // by GDI are never correctly updated. |
+ // NOTE: this doesn't handle clear type well and should be removed when |
+ // we have better text handling code. |
+ graphicsContext->beginTransparencyLayer(1.0); |
+ createdLayer = true; |
+ } |
+ |
// Max buffer length passed to the underlying windows API. |
const int kMaxBufferLength = 1024; |
// Default size for the buffer. It should be enough for most of cases. |
@@ -205,8 +218,6 @@ |
int x = static_cast<int>(point.x()); |
int lineTop = static_cast<int>(point.y()) - font->ascent(); |
- bool canUseGDI = windowsCanHandleTextDrawing(graphicsContext); |
- |
// We draw the glyphs in chunks to avoid having to do a heap allocation for |
// the arrays of characters and advances. Since ExtTextOut is the |
// lowest-level text output function on Windows, there should be little |
@@ -252,6 +263,8 @@ |
} |
SelectObject(hdc, oldFont); |
+ if (createdLayer) |
+ graphicsContext->endTransparencyLayer(); |
context->canvas()->endPlatformPaint(); |
} |