Get rid of HIGH_DPI_CANVAS leftovers
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Sep 2014 08:28:19 +0000 (08:28 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Sep 2014 08:28:19 +0000 (08:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136491

Reviewed by Benjamin Poulain.

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::HTMLCanvasElement): Removed m_deviceScaleFactor initializer.
(WebCore::HTMLCanvasElement::reset): Removed checking if the scale factor has changed and
updating m_deviceScaleFactor.
(WebCore::HTMLCanvasElement::convertLogicalToDevice): Removed scaling by the device scale
factor.
(WebCore::HTMLCanvasElement::convertDeviceToLogical): Ditto.
(WebCore::HTMLCanvasElement::createImageBuffer): Replaced m_deviceScaleFactor with a literal
1.
(WebCore::HTMLCanvasElement::targetDeviceScaleFactor): Deleted.
* html/HTMLCanvasElement.h: Removed m_deviceScaleFactor member variable and its getter.

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::putImageData): Removed scaling by the device scale
factor.
* html/canvas/CanvasRenderingContext2D.h:
(WebCore::CanvasRenderingContext2D::webkitBackingStorePixelRatio): Changed to return 1.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::texImage2D): Replaced deviceScaleFactor() with 1.
(WebCore::WebGLRenderingContext::texSubImage2D): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173256 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLCanvasElement.h
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.h
Source/WebCore/html/canvas/WebGLRenderingContext.cpp

index e70265c..e783866 100644 (file)
@@ -1,3 +1,32 @@
+2014-09-04  Dan Bernstein  <mitz@apple.com>
+
+        Get rid of HIGH_DPI_CANVAS leftovers
+        https://bugs.webkit.org/show_bug.cgi?id=136491
+
+        Reviewed by Benjamin Poulain.
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::HTMLCanvasElement): Removed m_deviceScaleFactor initializer.
+        (WebCore::HTMLCanvasElement::reset): Removed checking if the scale factor has changed and
+        updating m_deviceScaleFactor.
+        (WebCore::HTMLCanvasElement::convertLogicalToDevice): Removed scaling by the device scale
+        factor.
+        (WebCore::HTMLCanvasElement::convertDeviceToLogical): Ditto.
+        (WebCore::HTMLCanvasElement::createImageBuffer): Replaced m_deviceScaleFactor with a literal
+        1.
+        (WebCore::HTMLCanvasElement::targetDeviceScaleFactor): Deleted.
+        * html/HTMLCanvasElement.h: Removed m_deviceScaleFactor member variable and its getter.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::putImageData): Removed scaling by the device scale
+        factor.
+        * html/canvas/CanvasRenderingContext2D.h:
+        (WebCore::CanvasRenderingContext2D::webkitBackingStorePixelRatio): Changed to return 1.
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::texImage2D): Replaced deviceScaleFactor() with 1.
+        (WebCore::WebGLRenderingContext::texSubImage2D): Ditto.
+
 2014-09-03  Youenn Fablet  <youenn.fablet@crf.canon.fr>
 
         XMLHttpRequest always defaults Content-Type to application/xml, while it should depend on data type
index 6621eba..d92833b 100644 (file)
@@ -79,7 +79,6 @@ HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document& doc
     , m_size(DefaultWidth, DefaultHeight)
     , m_rendererIsCanvas(false)
     , m_ignoreReset(false)
-    , m_deviceScaleFactor(targetDeviceScaleFactor())
     , m_originClean(true)
     , m_hasCreatedImageBuffer(false)
     , m_didClearImageBuffer(false)
@@ -313,18 +312,14 @@ void HTMLCanvasElement::reset()
 
     IntSize oldSize = size();
     IntSize newSize(w, h);
-    float newDeviceScaleFactor = targetDeviceScaleFactor();
-
     // If the size of an existing buffer matches, we can just clear it instead of reallocating.
     // This optimization is only done for 2D canvases for now.
-    if (m_hasCreatedImageBuffer && oldSize == newSize && m_deviceScaleFactor == newDeviceScaleFactor && m_context && m_context->is2d()) {
+    if (m_hasCreatedImageBuffer && oldSize == newSize && m_context && m_context->is2d()) {
         if (!m_didClearImageBuffer)
             clearImageBuffer();
         return;
     }
 
-    m_deviceScaleFactor = newDeviceScaleFactor;
-
     setSurfaceSize(newSize);
 
 #if ENABLE(WEBGL)
@@ -348,11 +343,6 @@ void HTMLCanvasElement::reset()
         (*it)->canvasResized(*this);
 }
 
-float HTMLCanvasElement::targetDeviceScaleFactor() const
-{
-    return 1;
-}
-
 bool HTMLCanvasElement::paintsIntoCanvasBuffer() const
 {
     ASSERT(m_context);
@@ -493,7 +483,6 @@ PassRefPtr<ImageData> HTMLCanvasElement::getImageData()
 FloatRect HTMLCanvasElement::convertLogicalToDevice(const FloatRect& logicalRect) const
 {
     FloatRect deviceRect(logicalRect);
-    deviceRect.scale(m_deviceScaleFactor);
 
     float x = floorf(deviceRect.x());
     float y = floorf(deviceRect.y());
@@ -509,15 +498,15 @@ FloatRect HTMLCanvasElement::convertLogicalToDevice(const FloatRect& logicalRect
 
 FloatSize HTMLCanvasElement::convertLogicalToDevice(const FloatSize& logicalSize) const
 {
-    float width = ceilf(logicalSize.width() * m_deviceScaleFactor);
-    float height = ceilf(logicalSize.height() * m_deviceScaleFactor);
+    float width = ceilf(logicalSize.width());
+    float height = ceilf(logicalSize.height());
     return FloatSize(width, height);
 }
 
 FloatSize HTMLCanvasElement::convertDeviceToLogical(const FloatSize& deviceSize) const
 {
-    float width = ceilf(deviceSize.width() / m_deviceScaleFactor);
-    float height = ceilf(deviceSize.height() / m_deviceScaleFactor);
+    float width = ceilf(deviceSize.width());
+    float height = ceilf(deviceSize.height());
     return FloatSize(width, height);
 }
 
@@ -570,7 +559,7 @@ void HTMLCanvasElement::createImageBuffer() const
         return;
 
     RenderingMode renderingMode = shouldAccelerate(bufferSize) ? Accelerated : Unaccelerated;
-    m_imageBuffer = ImageBuffer::create(size(), m_deviceScaleFactor, ColorSpaceDeviceRGB, renderingMode);
+    m_imageBuffer = ImageBuffer::create(size(), 1, ColorSpaceDeviceRGB, renderingMode);
     if (!m_imageBuffer)
         return;
     m_imageBuffer->context()->setShadowsIgnoreTransforms(true);
index ff693a1..8837d08 100644 (file)
@@ -81,7 +81,7 @@ public:
 
     void setSize(const IntSize& newSize)
     { 
-        if (newSize == size() && targetDeviceScaleFactor() == m_deviceScaleFactor)
+        if (newSize == size())
             return;
         m_ignoreReset = true; 
         setWidth(newSize.width());
@@ -135,8 +135,6 @@ public:
 
     bool shouldAccelerate(const IntSize&) const;
 
-    float deviceScaleFactor() const { return m_deviceScaleFactor; }
-
 private:
     HTMLCanvasElement(const QualifiedName&, Document&);
 
@@ -148,8 +146,6 @@ private:
 
     void reset();
 
-    float targetDeviceScaleFactor() const;
-
     void createImageBuffer() const;
     void clearImageBuffer() const;
 
@@ -172,7 +168,6 @@ private:
     bool m_ignoreReset;
     FloatRect m_dirtyRect;
 
-    float m_deviceScaleFactor;
     bool m_originClean;
 
     // m_createdImageBuffer means we tried to malloc the buffer.  We didn't necessarily get it.
index f88f341..460ba40 100755 (executable)
@@ -2023,11 +2023,6 @@ void CanvasRenderingContext2D::putImageData(ImageData* data, ImageBuffer::Coordi
 
     buffer->putByteArray(Unmultiplied, data->data(), IntSize(data->width(), data->height()), sourceRect, IntPoint(destOffset), coordinateSystem);
 
-    if (coordinateSystem == ImageBuffer::BackingStoreCoordinateSystem) {
-        FloatRect dirtyRect = destRect;
-        dirtyRect.scale(1 / canvas()->deviceScaleFactor());
-        destRect = enclosingIntRect(dirtyRect);
-    }
     didDraw(destRect, CanvasDidDrawApplyNone); // ignore transform, shadow and clip
 }
 
index 60617b8..35962da 100644 (file)
@@ -199,7 +199,7 @@ public:
 
     void drawFocusIfNeeded(Element*);
 
-    float webkitBackingStorePixelRatio() const { return canvas()->deviceScaleFactor(); }
+    float webkitBackingStorePixelRatio() const { return 1; }
 
     void reset();
 
index 9345e18..e5bdca3 100644 (file)
@@ -3945,7 +3945,7 @@ void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum
 
     RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer());
     if (imageForRender->isSVGImage())
-        imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width(), image->height(), canvas()->deviceScaleFactor());
+        imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width(), image->height(), 1);
 
     if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLImageElement, target, level, internalformat, imageForRender->width(), imageForRender->height(), 0, format, type, 0, 0))
         return;
@@ -4191,7 +4191,7 @@ void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din
 
     RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer());
     if (imageForRender->isSVGImage())
-        imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width(), image->height(), canvas()->deviceScaleFactor());
+        imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width(), image->height(), 1);
 
     if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLImageElement, target, level, format, imageForRender->width(), imageForRender->height(), 0, format, type, xoffset, yoffset))
         return;