diff options
Diffstat (limited to 'WebCore/html/canvas')
-rw-r--r-- | WebCore/html/canvas/CanvasRenderingContext2D.cpp | 42 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasRenderingContext2D.h | 2 | ||||
-rw-r--r-- | WebCore/html/canvas/WebGLRenderingContext.cpp | 31 | ||||
-rw-r--r-- | WebCore/html/canvas/WebGLTexture.cpp | 1 | ||||
-rw-r--r-- | WebCore/html/canvas/WebGLTexture.h | 12 |
5 files changed, 33 insertions, 55 deletions
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp index 2a7b96a..6df6abf 100644 --- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp +++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -804,8 +804,8 @@ void CanvasRenderingContext2D::fill() if (!m_path.isEmpty()) { c->beginPath(); c->addPath(m_path); - willDraw(m_path.boundingRect()); c->fillPath(); + didDraw(m_path.boundingRect()); } #if ENABLE(DASHBOARD_SUPPORT) @@ -835,9 +835,8 @@ void CanvasRenderingContext2D::stroke() CanvasStrokeStyleApplier strokeApplier(this); FloatRect boundingRect = m_path.strokeBoundingRect(&strokeApplier); #endif - willDraw(boundingRect); - c->strokePath(); + didDraw(boundingRect); } #if ENABLE(DASHBOARD_SUPPORT) @@ -885,8 +884,8 @@ void CanvasRenderingContext2D::clearRect(float x, float y, float width, float he save(); setAllAttributesToDefault(); - willDraw(rect); context->clearRect(rect); + didDraw(rect); restore(); } @@ -909,9 +908,9 @@ void CanvasRenderingContext2D::fillRect(float x, float y, float width, float hei return; FloatRect rect(x, y, width, height); - willDraw(rect); c->fillRect(rect); + didDraw(rect); } void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float height) @@ -939,9 +938,9 @@ void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float h FloatRect boundingRect = rect; boundingRect.inflate(lineWidth / 2); - willDraw(boundingRect); c->strokeRect(rect, lineWidth); + didDraw(boundingRect); } #if PLATFORM(CG) @@ -1198,8 +1197,8 @@ void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRec FloatRect sourceRect = c->roundToDevicePixels(srcRect); FloatRect destRect = c->roundToDevicePixels(dstRect); - willDraw(destRect); c->drawImage(cachedImage->image(), DeviceColorSpace, destRect, sourceRect, state().m_globalComposite); + didDraw(destRect); } void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, float x, float y, ExceptionCode& ec) @@ -1273,8 +1272,7 @@ void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas, const sourceCanvas->makeRenderingResultsAvailable(); c->drawImageBuffer(buffer, DeviceColorSpace, destRect, sourceRect, state().m_globalComposite); - willDraw(destRect); // This call comes after drawImage, since the buffer we draw into may be our own, and we need to make sure it is dirty. - // FIXME: Arguably willDraw should become didDraw and occur after drawing calls and not before them to avoid problems like this. + didDraw(destRect); } #if ENABLE(VIDEO) @@ -1342,7 +1340,6 @@ void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, const FloatRec FloatRect sourceRect = c->roundToDevicePixels(srcRect); FloatRect destRect = c->roundToDevicePixels(dstRect); - willDraw(destRect); c->save(); c->clip(destRect); @@ -1351,6 +1348,7 @@ void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, const FloatRec c->translate(-sourceRect.x(), -sourceRect.y()); video->paintCurrentFrameInContext(c, IntRect(IntPoint(), size(video))); c->restore(); + didDraw(destRect); } #endif @@ -1384,8 +1382,8 @@ void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement* image, op = CompositeSourceOver; FloatRect destRect = FloatRect(dx, dy, dw, dh); - willDraw(destRect); c->drawImage(cachedImage->image(), DeviceColorSpace, destRect, FloatRect(sx, sy, sw, sh), op); + didDraw(destRect); } void CanvasRenderingContext2D::setAlpha(float alpha) @@ -1475,7 +1473,7 @@ PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLCanvasElem return CanvasPattern::create(canvas->copiedImage(), repeatX, repeatY, canvas->originClean()); } -void CanvasRenderingContext2D::willDraw(const FloatRect& r, unsigned options) +void CanvasRenderingContext2D::didDraw(const FloatRect& r, unsigned options) { GraphicsContext* c = drawingContext(); if (!c) @@ -1510,7 +1508,7 @@ void CanvasRenderingContext2D::willDraw(const FloatRect& r, unsigned options) renderBox->layer()->rendererContentChanged(); else #endif - canvas()->willDraw(dirtyRect); + canvas()->didDraw(dirtyRect); } GraphicsContext* CanvasRenderingContext2D::drawingContext() const @@ -1628,11 +1626,11 @@ void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, sourceRect.intersect(IntRect(IntPoint(), buffer->size())); if (sourceRect.isEmpty()) return; - willDraw(sourceRect, 0); // ignore transform, shadow and clip sourceRect.move(-destOffset); IntPoint destPoint(destOffset.width(), destOffset.height()); buffer->putUnmultipliedImageData(data, sourceRect, destPoint); + didDraw(sourceRect, 0); // ignore transform, shadow and clip } String CanvasRenderingContext2D::font() const @@ -1809,14 +1807,6 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo if (!fill) textRect.inflate(c->strokeThickness() / 2); - if (fill) - canvas()->willDraw(textRect); - else { - // When stroking text, pointy miters can extend outside of textRect, so we - // punt and dirty the whole canvas. - canvas()->willDraw(FloatRect(0, 0, canvas()->width(), canvas()->height())); - } - #if PLATFORM(CG) CanvasStyle* drawStyle = fill ? state().m_fillStyle.get() : state().m_strokeStyle.get(); if (drawStyle->canvasGradient() || drawStyle->canvasPattern()) { @@ -1859,6 +1849,14 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo c->drawBidiText(font, textRun, location); + if (fill) + canvas()->didDraw(textRect); + else { + // When stroking text, pointy miters can extend outside of textRect, so we + // punt and dirty the whole canvas. + canvas()->didDraw(FloatRect(0, 0, canvas()->width(), canvas()->height())); + } + #if PLATFORM(QT) Font::setCodePath(oldCodePath); #endif diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.h b/WebCore/html/canvas/CanvasRenderingContext2D.h index f610250..9857344 100644 --- a/WebCore/html/canvas/CanvasRenderingContext2D.h +++ b/WebCore/html/canvas/CanvasRenderingContext2D.h @@ -269,7 +269,7 @@ private: CanvasWillDrawApplyAll = 0xffffffff }; - void willDraw(const FloatRect&, unsigned options = CanvasWillDrawApplyAll); + void didDraw(const FloatRect&, unsigned options = CanvasWillDrawApplyAll); GraphicsContext* drawingContext() const; diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp index 44d3e08..2a1464a 100644 --- a/WebCore/html/canvas/WebGLRenderingContext.cpp +++ b/WebCore/html/canvas/WebGLRenderingContext.cpp @@ -29,6 +29,7 @@ #include "WebGLRenderingContext.h" +#include "CachedImage.h" #include "CanvasPixelArray.h" #include "CheckedInt.h" #include "Console.h" @@ -86,7 +87,8 @@ private: PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElement* canvas, WebGLContextAttributes* attrs) { HostWindow* hostWindow = canvas->document()->view()->root()->hostWindow(); - OwnPtr<GraphicsContext3D> context(GraphicsContext3D::create(attrs->attributes(), hostWindow)); + GraphicsContext3D::Attributes emptyAttributes; + OwnPtr<GraphicsContext3D> context(GraphicsContext3D::create(attrs ? attrs->attributes() : emptyAttributes, hostWindow)); if (!context) return 0; @@ -152,7 +154,7 @@ void WebGLRenderingContext::markContextChanged() else { #endif if (!m_markedCanvasDirty) - canvas()->willDraw(FloatRect(0, 0, canvas()->width(), canvas()->height())); + canvas()->didDraw(FloatRect(0, 0, canvas()->width(), canvas()->height())); #if USE(ACCELERATED_COMPOSITING) } #endif @@ -309,23 +311,14 @@ void WebGLRenderingContext::bindTexture(unsigned long target, WebGLTexture* text if (texture) texture->setTarget(target, maxLevel); - // FIXME: do we want to do this on all platforms? -#if PLATFORM(CHROMIUM) - // FIXME: GL_TEXTURE_WRAP_R isn't exposed in the OpenGL ES 2.0 - // API. On desktop OpenGL implementations it seems necessary to - // set this wrap mode to GL_CLAMP_TO_EDGE to get correct behavior - // of cube maps. - if (texture) { - if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) { - if (!texture->isCubeMapRWrapModeInitialized()) { - static const int textureWrapR = 0x8072; - texParameteri(GraphicsContext3D::TEXTURE_CUBE_MAP, textureWrapR, GraphicsContext3D::CLAMP_TO_EDGE); - texture->setCubeMapRWrapModeInitialized(true); - } - } else - texture->setCubeMapRWrapModeInitialized(false); - } -#endif + // Note: previously we used to automatically set the TEXTURE_WRAP_R + // repeat mode to CLAMP_TO_EDGE for cube map textures, because OpenGL + // ES 2.0 doesn't expose this flag (a bug in the specification) and + // otherwise the application has no control over the seams in this + // dimension. However, it appears that supporting this properly on all + // platforms is fairly involved (will require a HashMap from texture ID + // in all ports), and we have not had any complaints, so the logic has + // been removed. cleanupAfterGraphicsCall(false); } diff --git a/WebCore/html/canvas/WebGLTexture.cpp b/WebCore/html/canvas/WebGLTexture.cpp index 7b2869f..7fc84ad 100644 --- a/WebCore/html/canvas/WebGLTexture.cpp +++ b/WebCore/html/canvas/WebGLTexture.cpp @@ -40,7 +40,6 @@ PassRefPtr<WebGLTexture> WebGLTexture::create(WebGLRenderingContext* ctx) WebGLTexture::WebGLTexture(WebGLRenderingContext* ctx) : WebGLObject(ctx) - , cubeMapRWrapModeInitialized(false) , m_target(0) , m_minFilter(GraphicsContext3D::NEAREST_MIPMAP_LINEAR) , m_magFilter(GraphicsContext3D::LINEAR) diff --git a/WebCore/html/canvas/WebGLTexture.h b/WebCore/html/canvas/WebGLTexture.h index a1ce348..191957d 100644 --- a/WebCore/html/canvas/WebGLTexture.h +++ b/WebCore/html/canvas/WebGLTexture.h @@ -40,16 +40,6 @@ public: static PassRefPtr<WebGLTexture> create(WebGLRenderingContext*); - bool isCubeMapRWrapModeInitialized() - { - return cubeMapRWrapModeInitialized; - } - - void setCubeMapRWrapModeInitialized(bool initialized) - { - cubeMapRWrapModeInitialized = initialized; - } - void setTarget(unsigned long target, int maxLevel); void setParameteri(unsigned long pname, int param); void setParameterf(unsigned long pname, float param); @@ -83,8 +73,6 @@ private: int mapTargetToIndex(unsigned long); - bool cubeMapRWrapModeInitialized; - unsigned long m_target; int m_minFilter; |