2011-03-15 Simon Fraser <simon.fraser@apple.com>

        Reviewed by Dan Bernstein.

        Disable ShadowBlur shadow drawing in accelerated contexts
        https://bugs.webkit.org/show_bug.cgi?id=56392

        When drawing into a graphics context that is accelerated, don't use
        ShadowBlur, because it may be slower.

        * platform/graphics/GraphicsContext.h:
        * platform/graphics/cg/GraphicsContextCG.cpp:
        (WebCore::GraphicsContext::fillRect):
        (WebCore::GraphicsContext::fillRoundedRect):
        (WebCore::GraphicsContext::fillRectWithRoundedHole):
        (WebCore::GraphicsContext::setIsCALayerContext):
        (WebCore::GraphicsContext::isCALayerContext):
        (WebCore::GraphicsContext::setIsAcceleratedContext):
        (WebCore::GraphicsContext::isAcceleratedContext):
        * platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
        * platform/graphics/mac/WebLayer.mm:
        (drawLayerContents):

git-svn-id: svn://svn.chromium.org/blink/trunk@81161 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8ad1e467
2011-03-15 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dan Bernstein.
Disable ShadowBlur shadow drawing in accelerated contexts
https://bugs.webkit.org/show_bug.cgi?id=56392
When drawing into a graphics context that is accelerated, don't use
ShadowBlur, because it may be slower.
* platform/graphics/GraphicsContext.h:
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::fillRoundedRect):
(WebCore::GraphicsContext::fillRectWithRoundedHole):
(WebCore::GraphicsContext::setIsCALayerContext):
(WebCore::GraphicsContext::isCALayerContext):
(WebCore::GraphicsContext::setIsAcceleratedContext):
(WebCore::GraphicsContext::isAcceleratedContext):
* platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
(WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
* platform/graphics/mac/WebLayer.mm:
(drawLayerContents):
2011-03-15 Beth Dakin <bdakin@apple.com>
Reviewed by Simon Fraser.
......
......@@ -271,6 +271,9 @@ namespace WebCore {
void setIsCALayerContext(bool);
bool isCALayerContext() const;
void setIsAcceleratedContext(bool);
bool isAcceleratedContext() const;
#endif
void save();
......
......@@ -695,7 +695,7 @@ void GraphicsContext::fillRect(const FloatRect& rect)
if (m_state.fillPattern)
applyFillPattern();
bool drawOwnShadow = hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
if (drawOwnShadow) {
float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
// Turn off CG shadows.
......@@ -724,7 +724,7 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS
if (oldFillColor != color || oldColorSpace != colorSpace)
setCGFillColor(context, color, colorSpace);
bool drawOwnShadow = hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
if (drawOwnShadow) {
float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
// Turn off CG shadows.
......@@ -759,7 +759,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef
Path path;
path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
bool drawOwnShadow = hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
if (drawOwnShadow) {
float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
......@@ -803,7 +803,7 @@ void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const Rounded
setFillColor(color, colorSpace);
// fillRectWithRoundedHole() assumes that the edges of rect are clipped out, so we only care about shadows cast around inside the hole.
bool drawOwnShadow = hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms;
bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms;
if (drawOwnShadow) {
float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
......@@ -1345,14 +1345,30 @@ void GraphicsContext::setAllowsFontSmoothing(bool allowsFontSmoothing)
#endif
}
void GraphicsContext::setIsCALayerContext(bool)
void GraphicsContext::setIsCALayerContext(bool isLayerContext)
{
m_data->m_isCALayerContext = true;
if (isLayerContext)
m_data->m_contextFlags |= IsLayerCGContext;
else
m_data->m_contextFlags &= ~IsLayerCGContext;
}
bool GraphicsContext::isCALayerContext() const
{
return m_data->m_isCALayerContext;
return m_data->m_contextFlags & IsLayerCGContext;
}
void GraphicsContext::setIsAcceleratedContext(bool isAccelerated)
{
if (isAccelerated)
m_data->m_contextFlags |= IsAcceleratedCGContext;
else
m_data->m_contextFlags &= ~IsAcceleratedCGContext;
}
bool GraphicsContext::isAcceleratedContext() const
{
return m_data->m_contextFlags & IsAcceleratedCGContext;
}
void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode)
......
......@@ -31,9 +31,16 @@
namespace WebCore {
enum GraphicsContextCGFlag {
IsLayerCGContext = 1 << 0,
IsAcceleratedCGContext = 1 << 1
};
typedef unsigned GraphicsContextCGFlags;
class GraphicsContextPlatformPrivate {
public:
GraphicsContextPlatformPrivate(CGContextRef cgContext, bool isLayerContext = false)
GraphicsContextPlatformPrivate(CGContextRef cgContext, GraphicsContextCGFlags flags = 0)
: m_cgContext(cgContext)
#if PLATFORM(WIN)
, m_hdc(0)
......@@ -41,7 +48,7 @@ public:
, m_shouldIncludeChildWindows(false)
#endif
, m_userToDeviceTransformKnownToBeIdentity(false)
, m_isCALayerContext(isLayerContext)
, m_contextFlags(flags)
{
}
......@@ -87,7 +94,7 @@ public:
RetainPtr<CGContextRef> m_cgContext;
bool m_userToDeviceTransformKnownToBeIdentity;
bool m_isCALayerContext;
GraphicsContextCGFlags m_contextFlags;
};
}
......
......@@ -62,6 +62,9 @@ void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::PlatformCA
GraphicsContext graphicsContext(context);
graphicsContext.setIsCALayerContext(true);
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
graphicsContext.setIsAcceleratedContext([layer acceleratesDrawing]);
#endif
if (!layerContents->platformCALayerContentsOpaque()) {
// Turn off font smoothing to improve the appearance of text rendered onto a transparent background.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment