Text rendered with a simple (i.e. 0px blur) shadow inside a transparency layer has a double shadow

https://bugs.webkit.org/show_bug.cgi?id=67543
<rdar://problem/10070536>

Reviewed by Darin Adler.

Source/WebCore:

Generalize (begin|end)TransparencyLayer, which now forward
through to (begin|end)PlatformTransparencyLayer, so that
isInTransparencyLayer can exist on every platform.

Make use of isInTransparencyLayer in FontMac to disable
"simple" shadow drawing when the text is being rendered
into a transparency layer.

Test: svg/custom/simple-text-double-shadow.svg

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::~GraphicsContext):
(WebCore::GraphicsContext::beginTransparencyLayer):
(WebCore::GraphicsContext::endTransparencyLayer):
(WebCore::GraphicsContext::isInTransparencyLayer):
* platform/graphics/GraphicsContext.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
(WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
* platform/graphics/haiku/GraphicsContextHaiku.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::drawGlyphs):
* platform/graphics/openvg/GraphicsContextOpenVG.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/qt/GraphicsContextQt.cpp:
(WebCore::GraphicsContext::isInTransparencyLayer):
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/win/FontCGWin.cpp:
(WebCore::drawGDIGlyphs):
* platform/graphics/win/GraphicsContextCGWin.cpp:
(WebCore::GraphicsContext::releaseWindowsContext):
* platform/graphics/win/GraphicsContextCairoWin.cpp:
(WebCore::GraphicsContext::releaseWindowsContext):
* platform/graphics/win/GraphicsContextWin.cpp:
(WebCore::GraphicsContext::getWindowsContext):
* platform/graphics/wince/GraphicsContextWinCE.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/wx/GraphicsContextWx.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/win/ScrollbarThemeWin.cpp:
* plugins/win/PluginViewWin.cpp:
* rendering/RenderThemeWin.cpp:

LayoutTests:

Add a test ensuring that text with 0px blur CSS shadow doesn't get rendered
with a second shadow when inside a transparency layer.

* platform/mac/svg/custom/simple-text-double-shadow-expected.png: Added.
* platform/mac/svg/custom/simple-text-double-shadow-expected.txt: Added.
* svg/custom/simple-text-double-shadow.svg: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94897 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent decdcef3
2011-09-09 Tim Horton <timothy_horton@apple.com>
Text rendered with a simple (i.e. 0px blur) shadow inside a transparency layer has a double shadow
https://bugs.webkit.org/show_bug.cgi?id=67543
<rdar://problem/10070536>
Reviewed by Darin Adler.
Add a test ensuring that text with 0px blur CSS shadow doesn't get rendered
with a second shadow when inside a transparency layer.
* platform/mac/svg/custom/simple-text-double-shadow-expected.png: Added.
* platform/mac/svg/custom/simple-text-double-shadow-expected.txt: Added.
* svg/custom/simple-text-double-shadow.svg: Added.
2011-09-09 Matthew Delaney <mdelaney@apple.com>
Update Skipped lists for mac and mac-lion w.r.t. canvas
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderSVGRoot {svg} at (20,26) size 380x194
RenderSVGText {text} at (20,26) size 217x18 contains 1 chunk(s)
RenderSVGInlineText {#text} at (0,0) size 217x18
chunk 1 text run 1 at (20.00,40.00) startOffset 0 endOffset 34 width 217.00: "This text should appear only twice"
RenderSVGPath {rect} at (100,100) size 250x70 [fill={[type=SOLID] [color=#0000FF]}] [x=100.00] [y=100.00] [width=200.00] [height=20.00]
<svg xmlns="http://www.w3.org/2000/svg" id="asdf" style="-webkit-svg-shadow: 50px 50px 0px red;">
<text x="20" y="40" fill="black">This text should appear only twice</text>
<rect x="100" y="100" height="20" width="200" fill="blue" />
</svg>
\ No newline at end of file
2011-09-09 Tim Horton <timothy_horton@apple.com>
Text rendered with a simple (i.e. 0px blur) shadow inside a transparency layer has a double shadow
https://bugs.webkit.org/show_bug.cgi?id=67543
<rdar://problem/10070536>
Reviewed by Darin Adler.
Generalize (begin|end)TransparencyLayer, which now forward
through to (begin|end)PlatformTransparencyLayer, so that
isInTransparencyLayer can exist on every platform.
Make use of isInTransparencyLayer in FontMac to disable
"simple" shadow drawing when the text is being rendered
into a transparency layer.
Test: svg/custom/simple-text-double-shadow.svg
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::~GraphicsContext):
(WebCore::GraphicsContext::beginTransparencyLayer):
(WebCore::GraphicsContext::endTransparencyLayer):
(WebCore::GraphicsContext::isInTransparencyLayer):
* platform/graphics/GraphicsContext.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
(WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
* platform/graphics/haiku/GraphicsContextHaiku.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::drawGlyphs):
* platform/graphics/openvg/GraphicsContextOpenVG.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/qt/GraphicsContextQt.cpp:
(WebCore::GraphicsContext::isInTransparencyLayer):
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/win/FontCGWin.cpp:
(WebCore::drawGDIGlyphs):
* platform/graphics/win/GraphicsContextCGWin.cpp:
(WebCore::GraphicsContext::releaseWindowsContext):
* platform/graphics/win/GraphicsContextCairoWin.cpp:
(WebCore::GraphicsContext::releaseWindowsContext):
* platform/graphics/win/GraphicsContextWin.cpp:
(WebCore::GraphicsContext::getWindowsContext):
* platform/graphics/wince/GraphicsContextWinCE.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/graphics/wx/GraphicsContextWx.cpp:
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::supportsTransparencyLayers):
* platform/win/ScrollbarThemeWin.cpp:
* plugins/win/PluginViewWin.cpp:
* rendering/RenderThemeWin.cpp:
2011-09-09 Julien Chaffraix <jchaffraix@webkit.org>
[V8] V8WebKitPoint::constructorCallback leaks
......@@ -34,6 +34,8 @@
#include "RoundedRect.h"
#include "TextRun.h"
#include "stdio.h"
using namespace std;
namespace WebCore {
......@@ -78,6 +80,7 @@ private:
GraphicsContext::GraphicsContext(PlatformGraphicsContext* platformGraphicsContext)
: m_updatingControlTints(false)
, m_transparencyCount(0)
{
platformInit(platformGraphicsContext);
}
......@@ -85,6 +88,7 @@ GraphicsContext::GraphicsContext(PlatformGraphicsContext* platformGraphicsContex
GraphicsContext::~GraphicsContext()
{
ASSERT(m_stack.isEmpty());
ASSERT(!m_transparencyCount);
platformDestroy();
}
......@@ -330,6 +334,26 @@ bool GraphicsContext::shadowsIgnoreTransforms() const
return m_state.shadowsIgnoreTransforms;
}
void GraphicsContext::beginTransparencyLayer(float opacity)
{
beginPlatformTransparencyLayer(opacity);
++m_transparencyCount;
}
void GraphicsContext::endTransparencyLayer()
{
endPlatformTransparencyLayer();
ASSERT(m_transparencyCount > 0);
--m_transparencyCount;
}
#if !PLATFORM(QT)
bool GraphicsContext::isInTransparencyLayer() const
{
return (m_transparencyCount > 0) && supportsTransparencyLayers();
}
#endif
bool GraphicsContext::updatingControlTints() const
{
return m_updatingControlTints;
......
......@@ -370,6 +370,7 @@ namespace WebCore {
void beginTransparencyLayer(float opacity);
void endTransparencyLayer();
bool isInTransparencyLayer() const;
bool hasShadow() const;
void setShadow(const FloatSize&, float blur, const Color&, ColorSpace);
......@@ -425,13 +426,11 @@ namespace WebCore {
void drawBitmap(SharedBitmap*, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp);
void drawBitmapPattern(SharedBitmap*, const FloatRect& tileRectIn, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize);
void drawIcon(HICON icon, const IntRect& dstRect, UINT flags);
bool inTransparencyLayer() const { return false; }
HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = false, bool mayCreateBitmap = true); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = false, bool mayCreateBitmap = true); // The passed in HDC should be the one handed back by getWindowsContext.
void drawRoundCorner(bool newClip, RECT clipRect, RECT rectWin, HDC dc, int width, int height);
#elif PLATFORM(WIN)
GraphicsContext(HDC, bool hasAlpha = false); // FIXME: To be removed.
bool inTransparencyLayer() const;
HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true); // The passed in HDC should be the one handed back by getWindowsContext.
......@@ -481,11 +480,9 @@ namespace WebCore {
// This is needed because of a bug whereby getting an HDC from a GDI+ context
// loses the scale operations applied to the context.
FloatSize currentScale();
bool inTransparencyLayer() const { return false; }
#endif
#if PLATFORM(QT)
bool inTransparencyLayer() const;
void pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask);
void takeOwnershipOfPlatformContext();
#endif
......@@ -538,11 +535,16 @@ namespace WebCore {
void setPlatformCompositeOperation(CompositeOperator);
void beginPlatformTransparencyLayer(float opacity);
void endPlatformTransparencyLayer();
static bool supportsTransparencyLayers();
GraphicsContextPlatformPrivate* m_data;
GraphicsContextState m_state;
Vector<GraphicsContextState> m_stack;
bool m_updatingControlTints;
unsigned m_transparencyCount;
};
class GraphicsContextStateSaver {
......
......@@ -174,7 +174,8 @@ static inline void shadowAndStrokeCurrentCairoPath(GraphicsContext* context)
}
GraphicsContext::GraphicsContext(cairo_t* cr)
: m_updatingControlTints(false)
: m_updatingControlTints(false),
m_transparencyCount(0)
{
m_data = new GraphicsContextPlatformPrivateToplevel(new PlatformContextCairo(cr));
}
......@@ -879,7 +880,7 @@ void GraphicsContext::clearPlatformShadow()
platformContext()->shadowBlur().clear();
}
void GraphicsContext::beginTransparencyLayer(float opacity)
void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
{
if (paintingDisabled())
return;
......@@ -887,10 +888,9 @@ void GraphicsContext::beginTransparencyLayer(float opacity)
cairo_t* cr = platformContext()->cr();
cairo_push_group(cr);
m_data->layers.append(opacity);
m_data->beginTransparencyLayer();
}
void GraphicsContext::endTransparencyLayer()
void GraphicsContext::endPlatformTransparencyLayer()
{
if (paintingDisabled())
return;
......@@ -900,7 +900,11 @@ void GraphicsContext::endTransparencyLayer()
cairo_pop_group_to_source(cr);
cairo_paint_with_alpha(cr, m_data->layers.last());
m_data->layers.removeLast();
m_data->endTransparencyLayer();
}
bool GraphicsContext::supportsTransparencyLayers()
{
return true;
}
void GraphicsContext::clearRect(const FloatRect& rect)
......
......@@ -55,7 +55,6 @@ public:
#elif PLATFORM(WIN)
// NOTE: These may note be needed: review and remove once Cairo implementation is complete
, m_hdc(0)
, m_transparencyCount(0)
, m_shouldIncludeChildWindows(false)
#endif
{
......@@ -77,8 +76,6 @@ public:
void translate(float, float);
void concatCTM(const AffineTransform&);
void setCTM(const AffineTransform&);
void beginTransparencyLayer() { m_transparencyCount++; }
void endTransparencyLayer() { m_transparencyCount--; }
void syncContext(cairo_t* cr);
#else
// On everything else, we do nothing.
......@@ -92,8 +89,6 @@ public:
void translate(float, float) {}
void concatCTM(const AffineTransform&) {}
void setCTM(const AffineTransform&) {}
void beginTransparencyLayer() {}
void endTransparencyLayer() {}
void syncContext(cairo_t* cr) {}
#endif
......@@ -105,7 +100,6 @@ public:
GdkEventExpose* expose;
#elif PLATFORM(WIN)
HDC m_hdc;
unsigned m_transparencyCount;
bool m_shouldIncludeChildWindows;
#endif
};
......
......@@ -963,7 +963,7 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness
CGContextEOClip(context);
}
void GraphicsContext::beginTransparencyLayer(float opacity)
void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
{
if (paintingDisabled())
return;
......@@ -973,21 +973,24 @@ void GraphicsContext::beginTransparencyLayer(float opacity)
CGContextRef context = platformContext();
CGContextSetAlpha(context, opacity);
CGContextBeginTransparencyLayer(context, 0);
m_data->beginTransparencyLayer();
m_data->m_userToDeviceTransformKnownToBeIdentity = false;
}
void GraphicsContext::endTransparencyLayer()
void GraphicsContext::endPlatformTransparencyLayer()
{
if (paintingDisabled())
return;
CGContextRef context = platformContext();
CGContextEndTransparencyLayer(context);
m_data->endTransparencyLayer();
restore();
}
bool GraphicsContext::supportsTransparencyLayers()
{
return true;
}
void GraphicsContext::setPlatformShadow(const FloatSize& offset, float blur, const Color& color, ColorSpace colorSpace)
{
if (paintingDisabled())
......
......@@ -45,19 +45,11 @@ public:
#if PLATFORM(WIN)
, m_hdc(0)
, m_shouldIncludeChildWindows(false)
#endif
#if PLATFORM(WIN) || !ASSERT_DISABLED
, m_transparencyCount(0)
#endif
, m_userToDeviceTransformKnownToBeIdentity(false)
, m_contextFlags(flags)
{
}
~GraphicsContextPlatformPrivate()
{
ASSERT(!m_transparencyCount);
}
#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
// These methods do nothing on Mac.
......@@ -90,24 +82,7 @@ public:
bool m_shouldIncludeChildWindows;
#endif
void beginTransparencyLayer()
{
#if PLATFORM(WIN) || !ASSERT_DISABLED
m_transparencyCount++;
#endif
}
void endTransparencyLayer()
{
#if PLATFORM(WIN) || !ASSERT_DISABLED
ASSERT(m_transparencyCount > 0);
m_transparencyCount--;
#endif
}
RetainPtr<CGContextRef> m_cgContext;
#if PLATFORM(WIN) || !ASSERT_DISABLED
int m_transparencyCount;
#endif
bool m_userToDeviceTransformKnownToBeIdentity;
GraphicsContextCGFlags m_contextFlags;
};
......
......@@ -249,7 +249,7 @@ FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
return rect;
}
void GraphicsContext::beginTransparencyLayer(float opacity)
void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
{
if (paintingDisabled())
return;
......@@ -257,7 +257,7 @@ void GraphicsContext::beginTransparencyLayer(float opacity)
notImplemented();
}
void GraphicsContext::endTransparencyLayer()
void GraphicsContext::endPlatformTransparencyLayer()
{
if (paintingDisabled())
return;
......@@ -265,6 +265,11 @@ void GraphicsContext::endTransparencyLayer()
notImplemented();
}
bool GraphicsContext::supportsTransparencyLayers()
{
return false;
}
void GraphicsContext::clearRect(const FloatRect& rect)
{
if (paintingDisabled())
......
......@@ -222,7 +222,7 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
ColorSpace fillColorSpace = context->fillColorSpace();
context->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
bool hasSimpleShadow = context->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && !platformData.isColorBitmapFont() && (!context->shadowsIgnoreTransforms() || context->getCTM().isIdentityOrTranslationOrFlipped());
bool hasSimpleShadow = context->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && !platformData.isColorBitmapFont() && (!context->shadowsIgnoreTransforms() || context->getCTM().isIdentityOrTranslationOrFlipped()) && !context->isInTransparencyLayer();
if (hasSimpleShadow) {
// Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
context->clearShadow();
......
......@@ -285,7 +285,7 @@ void GraphicsContext::clearPlatformShadow()
notImplemented();
}
void GraphicsContext::beginTransparencyLayer(float opacity)
void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
{
if (paintingDisabled())
return;
......@@ -294,7 +294,7 @@ void GraphicsContext::beginTransparencyLayer(float opacity)
UNUSED_PARAM(opacity);
}
void GraphicsContext::endTransparencyLayer()
void GraphicsContext::endPlatformTransparencyLayer()
{
if (paintingDisabled())
return;
......@@ -302,6 +302,11 @@ void GraphicsContext::endTransparencyLayer()
notImplemented();
}
bool GraphicsContext::supportsTransparencyLayers()
{
return false;
}
void GraphicsContext::clearRect(const FloatRect& rect)
{
if (paintingDisabled())
......
......@@ -186,7 +186,7 @@ public:
bool antiAliasingForRectsAndLines;
QStack<TransparencyLayer*> layers;
// Counting real layers. Required by inTransparencyLayer() calls
// Counting real layers. Required by isInTransparencyLayer() calls
// For example, layers with valid alphaMask are not real layers
int layerCount;
......@@ -763,7 +763,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef
p->fillPath(path.platformPath(), QColor(color));
}
bool GraphicsContext::inTransparencyLayer() const
bool GraphicsContext::isInTransparencyLayer() const
{
return m_data->layerCount;
}
......@@ -1060,7 +1060,7 @@ void GraphicsContext::pushTransparencyLayerInternal(const QRect &rect, qreal opa
m_data->layers.push(new TransparencyLayer(p, deviceClip, 1.0, alphaMask));
}
void GraphicsContext::beginTransparencyLayer(float opacity)
void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
{
if (paintingDisabled())
return;
......@@ -1084,7 +1084,7 @@ void GraphicsContext::beginTransparencyLayer(float opacity)
++m_data->layerCount;
}
void GraphicsContext::endTransparencyLayer()
void GraphicsContext::endPlatformTransparencyLayer()
{
if (paintingDisabled())
return;
......@@ -1108,6 +1108,11 @@ void GraphicsContext::endTransparencyLayer()
delete layer;
}
bool GraphicsContext::supportsTransparencyLayers()
{
return true;
}
void GraphicsContext::clearRect(const FloatRect& rect)
{
if (paintingDisabled())
......
......@@ -262,7 +262,7 @@ void GraphicsContext::restorePlatformState()
platformContext()->restore();
}
void GraphicsContext::beginTransparencyLayer(float opacity)
void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
{
if (paintingDisabled())
return;
......@@ -283,13 +283,18 @@ void GraphicsContext::beginTransparencyLayer(float opacity)
SkCanvas::kFullColorLayer_SaveFlag));
}
void GraphicsContext::endTransparencyLayer()
void GraphicsContext::endPlatformTransparencyLayer()
{
if (paintingDisabled())
return;
platformContext()->canvas()->restore();
}
bool GraphicsContext::supportsTransparencyLayers()
{
return true;
}
// Graphics primitives ---------------------------------------------------------
void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
......
......@@ -138,7 +138,7 @@ static void drawGDIGlyphs(GraphicsContext* graphicsContext, const SimpleFontData
if (!fillColor.alpha())
return;
drawIntoBitmap = fillColor.alpha() != 255 || graphicsContext->inTransparencyLayer();
drawIntoBitmap = fillColor.alpha() != 255 || graphicsContext->isInTransparencyLayer();
if (!drawIntoBitmap) {
FloatSize offset;
float blur;
......
......@@ -67,7 +67,8 @@ static CGContextRef CGContextWithHDC(HDC hdc, bool hasAlpha)
}
GraphicsContext::GraphicsContext(HDC hdc, bool hasAlpha)
: m_updatingControlTints(false)
: m_updatingControlTints(false),
m_transparencyCount(0)
{
platformInit(hdc, hasAlpha);
}
......@@ -89,7 +90,7 @@ void GraphicsContext::platformInit(HDC hdc, bool hasAlpha)
// suitable for all clients?
void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
{
bool createdBitmap = mayCreateBitmap && (!m_data->m_hdc || inTransparencyLayer());
bool createdBitmap = mayCreateBitmap && (!m_data->m_hdc || isInTransparencyLayer());
if (!createdBitmap) {
m_data->restore();
return;
......
......@@ -65,7 +65,8 @@ static cairo_t* createCairoContextWithHDC(HDC hdc, bool hasAlpha)
}
GraphicsContext::GraphicsContext(HDC dc, bool hasAlpha)
: m_updatingControlTints(false)
: m_updatingControlTints(false),
m_transparencyCount(0)
{
platformInit(dc, hasAlpha);
}
......@@ -122,7 +123,7 @@ static void drawBitmapToContext(GraphicsContextPlatformPrivate* context, cairo_t
void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
{
bool createdBitmap = mayCreateBitmap && (!m_data->m_hdc || inTransparencyLayer());
bool createdBitmap = mayCreateBitmap && (!m_data->m_hdc || isInTransparencyLayer());
if (!hdc || !createdBitmap) {
m_data->restore();
return;
......
......@@ -51,8 +51,6 @@ static void fillWithClearColor(HBITMAP bitmap)
memset(bmpInfo.bmBits, 0, bufferSize);
}
bool GraphicsContext::inTransparencyLayer() const { return m_data->m_transparencyCount; }
void GraphicsContext::setShouldIncludeChildWindows(bool include)
{
m_data->m_shouldIncludeChildWindows = include;
......@@ -100,7 +98,7 @@ PassOwnPtr<GraphicsContext::WindowsBitmap> GraphicsContext::createWindowsBitmap(
HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
{
// FIXME: Should a bitmap be created also when a shadow is set?
if (mayCreateBitmap && (!m_data->m_hdc || inTransparencyLayer())) {
if (mayCreateBitmap && (!m_data->m_hdc || isInTransparencyLayer())) {
if (dstRect.isEmpty())
return 0;
......
......@@ -1113,17 +1113,22 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float width)
SelectObject(dc, oldPen);
}
void GraphicsContext::beginTransparencyLayer(float opacity)
void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
{
m_data->save();
m_data->m_opacity *= opacity;
}
void GraphicsContext::endTransparencyLayer()
void GraphicsContext::endPlatformTransparencyLayer()
{
m_data->restore();
}
bool GraphicsContext::supportsTransparencyLayers()
{
return true;
}
void GraphicsContext::concatCTM(const AffineTransform& transform)
{
m_data->concatCTM(transform);
......
......@@ -665,16 +665,21 @@ void GraphicsContext::clearPlatformShadow()
notImplemented();
}
void GraphicsContext::beginTransparencyLayer(float)
void GraphicsContext::beginPlatformTransparencyLayer(float)
{
notImplemented();
}