[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
jamesr at google.com
jamesr at google.com
Wed Dec 22 13:11:48 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit d92f51f2ba5cb81c4eb10e35d6c1f57954cd689d
Author: jamesr at google.com <jamesr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Sep 8 19:38:43 2010 +0000
2010-09-08 James Robinson <jamesr at chromium.org>
Reviewed by Kenneth Russell.
[chromium] Force canvas 2d draw calls to happen in software if a gradient, pattern, shadow, or clip are active
https://bugs.webkit.org/show_bug.cgi?id=45405
This forces all draw calls to happen in software instead of hardware if there is a fill pattern, gradient,
shadow, or clip applied; at least until we can handle these in hardware. Otherwise the pattern/gradient/etc
is completely ignored by the hardware drawing routine and we render incorrectly.
The test is slightly convervative - for example it will force drawImage() calls to happen in software if a
fill gradient is set even though it's irrelevant. This doesn't seem to be an issue in practice and we
can tighten the checks later if needed.
Tested by fast/canvas/canvas-incremental-repaint.html.
* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContext::canvasClip):
(WebCore::GraphicsContext::fillRect):
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::ImageBuffer::draw):
* platform/graphics/skia/ImageSkia.cpp:
(WebCore::BitmapImage::draw):
(WebCore::BitmapImageSingleFrameSkia::draw):
* platform/graphics/skia/PlatformContextSkia.cpp:
(WebCore::PlatformContextSkia::State::State):
(WebCore::PlatformContextSkia::canvasClipPath):
(WebCore::PlatformContextSkia::canAccelerate):
* platform/graphics/skia/PlatformContextSkia.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67003 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f1273c8..33dd13d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2010-09-08 James Robinson <jamesr at chromium.org>
+
+ Reviewed by Kenneth Russell.
+
+ [chromium] Force canvas 2d draw calls to happen in software if a gradient, pattern, shadow, or clip are active
+ https://bugs.webkit.org/show_bug.cgi?id=45405
+
+ This forces all draw calls to happen in software instead of hardware if there is a fill pattern, gradient,
+ shadow, or clip applied; at least until we can handle these in hardware. Otherwise the pattern/gradient/etc
+ is completely ignored by the hardware drawing routine and we render incorrectly.
+
+ The test is slightly convervative - for example it will force drawImage() calls to happen in software if a
+ fill gradient is set even though it's irrelevant. This doesn't seem to be an issue in practice and we
+ can tighten the checks later if needed.
+
+ Tested by fast/canvas/canvas-incremental-repaint.html.
+
+ * platform/graphics/skia/GraphicsContextSkia.cpp:
+ (WebCore::GraphicsContext::canvasClip):
+ (WebCore::GraphicsContext::fillRect):
+ * platform/graphics/skia/ImageBufferSkia.cpp:
+ (WebCore::ImageBuffer::draw):
+ * platform/graphics/skia/ImageSkia.cpp:
+ (WebCore::BitmapImage::draw):
+ (WebCore::BitmapImageSingleFrameSkia::draw):
+ * platform/graphics/skia/PlatformContextSkia.cpp:
+ (WebCore::PlatformContextSkia::State::State):
+ (WebCore::PlatformContextSkia::canvasClipPath):
+ (WebCore::PlatformContextSkia::canAccelerate):
+ * platform/graphics/skia/PlatformContextSkia.h:
+
2010-09-08 Peter Kasting <pkasting at google.com>
Reviewed by David Hyatt.
diff --git a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
index a7402b9..1f9381d 100644
--- a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
+++ b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
@@ -338,7 +338,7 @@ void GraphicsContext::clearRect(const FloatRect& rect)
if (paintingDisabled())
return;
- if (platformContext()->useGPU()) {
+ if (platformContext()->useGPU() && platformContext()->canAccelerate()) {
platformContext()->prepareForHardwareDraw();
platformContext()->gpuCanvas()->clearRect(rect);
return;
@@ -391,7 +391,7 @@ void GraphicsContext::canvasClip(const Path& path)
if (!isPathSkiaSafe(getCTM(), p))
return;
- platformContext()->canvas()->clipPath(p);
+ platformContext()->canvasClipPath(p);
}
void GraphicsContext::clipOut(const IntRect& rect)
@@ -767,7 +767,7 @@ void GraphicsContext::fillRect(const FloatRect& rect)
ClipRectToCanvas(*platformContext()->canvas(), r, &r);
}
- if (platformContext()->useGPU() && !m_common->state.fillPattern && !m_common->state.fillGradient && !platformContext()->getDrawLooper()) {
+ if (platformContext()->useGPU() && platformContext()->canAccelerate()) {
platformContext()->prepareForHardwareDraw();
platformContext()->gpuCanvas()->fillRect(rect);
return;
@@ -789,7 +789,7 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS
if (paintingDisabled())
return;
- if (platformContext()->useGPU() && !m_common->state.fillPattern && !m_common->state.fillGradient) {
+ if (platformContext()->useGPU() && platformContext()->canAccelerate()) {
platformContext()->prepareForHardwareDraw();
platformContext()->gpuCanvas()->fillRect(rect, color, colorSpace);
return;
diff --git a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
index e0bda03..bb89ac5 100644
--- a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
+++ b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
@@ -111,13 +111,16 @@ void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, con
CompositeOperator op, bool useLowQualityScale)
{
if (m_data.m_platformContext.useGPU() && context->platformContext()->useGPU()) {
- DrawingBuffer* sourceDrawingBuffer = m_data.m_platformContext.gpuCanvas()->drawingBuffer();
- unsigned sourceTexture = sourceDrawingBuffer->getRenderingResultsAsTexture();
- FloatRect destRectFlipped(destRect);
- destRectFlipped.setY(destRect.y() + destRect.height());
- destRectFlipped.setHeight(-destRect.height());
- context->platformContext()->gpuCanvas()->drawTexturedRect(sourceTexture, m_size, srcRect, destRectFlipped, styleColorSpace, op);
- return;
+ if (context->platformContext()->canAccelerate()) {
+ DrawingBuffer* sourceDrawingBuffer = m_data.m_platformContext.gpuCanvas()->drawingBuffer();
+ unsigned sourceTexture = sourceDrawingBuffer->getRenderingResultsAsTexture();
+ FloatRect destRectFlipped(destRect);
+ destRectFlipped.setY(destRect.y() + destRect.height());
+ destRectFlipped.setHeight(-destRect.height());
+ context->platformContext()->gpuCanvas()->drawTexturedRect(sourceTexture, m_size, srcRect, destRectFlipped, styleColorSpace, op);
+ return;
+ }
+ m_data.m_platformContext.syncSoftwareCanvas();
}
RefPtr<Image> image = BitmapImageSingleFrameSkia::create(*m_data.m_platformContext.bitmap(), context == m_context);
diff --git a/WebCore/platform/graphics/skia/ImageSkia.cpp b/WebCore/platform/graphics/skia/ImageSkia.cpp
index 5b5962a..9625b34 100644
--- a/WebCore/platform/graphics/skia/ImageSkia.cpp
+++ b/WebCore/platform/graphics/skia/ImageSkia.cpp
@@ -469,7 +469,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect,
if (normSrcRect.isEmpty() || normDstRect.isEmpty())
return; // Nothing to draw.
- if (ctxt->platformContext()->useGPU()) {
+ if (ctxt->platformContext()->useGPU() && ctxt->platformContext()->canAccelerate()) {
drawBitmapGLES2(ctxt, bm, normSrcRect, normDstRect, colorSpace, compositeOp);
return;
}
@@ -497,7 +497,7 @@ void BitmapImageSingleFrameSkia::draw(GraphicsContext* ctxt,
if (normSrcRect.isEmpty() || normDstRect.isEmpty())
return; // Nothing to draw.
- if (ctxt->platformContext()->useGPU()) {
+ if (ctxt->platformContext()->useGPU() && ctxt->platformContext()->canAccelerate()) {
drawBitmapGLES2(ctxt, &m_nativeImage, srcRect, dstRect, styleColorSpace, compositeOp);
return;
}
diff --git a/WebCore/platform/graphics/skia/PlatformContextSkia.cpp b/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
index 4a2153e..7c58518 100644
--- a/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
+++ b/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
@@ -109,6 +109,9 @@ struct PlatformContextSkia::State {
WTF::Vector<SkPath> m_antiAliasClipPaths;
InterpolationQuality m_interpolationQuality;
+ // If we currently have a canvas (non-antialiased path) clip applied.
+ bool m_canvasClipApplied;
+
PlatformContextSkia::State cloneInheritedProperties();
private:
// Not supported.
@@ -134,6 +137,7 @@ PlatformContextSkia::State::State()
, m_dash(0)
, m_textDrawingMode(cTextFill)
, m_interpolationQuality(InterpolationHigh)
+ , m_canvasClipApplied(false)
{
}
@@ -160,6 +164,7 @@ PlatformContextSkia::State::State(const State& other)
#endif
, m_antiAliasClipPaths(other.m_antiAliasClipPaths)
, m_interpolationQuality(other.m_interpolationQuality)
+ , m_canvasClipApplied(other.m_canvasClipApplied)
{
// Up the ref count of these. saveRef does nothing if 'this' is NULL.
m_looper->safeRef();
@@ -556,6 +561,12 @@ SkPath PlatformContextSkia::currentPathInLocalCoordinates() const
return localPath;
}
+void PlatformContextSkia::canvasClipPath(const SkPath& path)
+{
+ m_state->m_canvasClipApplied = true;
+ m_canvas->clipPath(path);
+}
+
void PlatformContextSkia::setFillRule(SkPath::FillType fr)
{
m_path.setFillType(fr);
@@ -675,6 +686,13 @@ void PlatformContextSkia::applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths)
m_canvas->restore();
}
+bool PlatformContextSkia::canAccelerate() const
+{
+ return !m_state->m_fillShader // Can't accelerate with a fill gradient or pattern.
+ && !m_state->m_looper // Can't accelerate with a shadow.
+ && !m_state->m_canvasClipApplied; // Can't accelerate with a clip to path applied.
+}
+
class WillPublishCallbackImpl : public DrawingBuffer::WillPublishCallback {
public:
static PassOwnPtr<WillPublishCallback> create(PlatformContextSkia* pcs)
diff --git a/WebCore/platform/graphics/skia/PlatformContextSkia.h b/WebCore/platform/graphics/skia/PlatformContextSkia.h
index 2606240..cb9aa71 100644
--- a/WebCore/platform/graphics/skia/PlatformContextSkia.h
+++ b/WebCore/platform/graphics/skia/PlatformContextSkia.h
@@ -143,6 +143,8 @@ public:
void addPath(const SkPath&);
SkPath currentPathInLocalCoordinates() const;
+ void canvasClipPath(const SkPath&);
+
// Returns the fill color. The returned color has it's alpha adjusted
// by the current alpha.
SkColor effectiveFillColor() const;
@@ -180,6 +182,8 @@ public:
void setImageResamplingHint(const IntSize& srcSize, const FloatSize& dstSize);
void clearImageResamplingHint();
bool hasImageResamplingHint() const;
+
+ bool canAccelerate() const;
bool useGPU() { return m_useGPU; }
void setSharedGraphicsContext3D(SharedGraphicsContext3D*, DrawingBuffer*, const IntSize&);
GLES2Canvas* gpuCanvas() const { return m_gpuCanvas.get(); }
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list