Commit 45edb34c authored by bdakin's avatar bdakin

Reviewed by Darin.

        Fix for <rdar://problem/4537274> HiDPI: <canvas> needs to apply a 
        scale. <canvas> needs to scale itself along with whatever scale 
        factor is set on the window.

        * html/HTMLCanvasElement.cpp:
        (WebCore::HTMLCanvasElement::createDrawingContext): Get the scale 
        factor and use it to create a larger buffer and to scale the 
        CGContext.
        * platform/Widget.h: Provide a new function that returns the user 
        space scale factor.
        * platform/mac/WidgetMac.mm:
        (WebCore::Widget::scaleFactor): Get the scale factor from the 
        window and return it.
        * platform/win/WidgetWin.cpp:
        (WebCore::Widget::scaleFactor): Just return 1.0f for now.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14711 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 76ffa516
2006-06-03 Beth Dakin <bdakin@apple.com>
Reviewed by Darin.
Fix for <rdar://problem/4537274> HiDPI: <canvas> needs to apply a
scale. <canvas> needs to scale itself along with whatever scale
factor is set on the window.
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::createDrawingContext): Get the scale
factor and use it to create a larger buffer and to scale the
CGContext.
* platform/Widget.h: Provide a new function that returns the user
space scale factor.
* platform/mac/WidgetMac.mm:
(WebCore::Widget::scaleFactor): Get the scale factor from the
window and return it.
* platform/win/WidgetWin.cpp:
(WebCore::Widget::scaleFactor): Just return 1.0f for now.
2006-06-03 Steve Falkenburg <sfalken@apple.com>
Reviewed by hyatt.
......
......@@ -30,6 +30,8 @@
#include "CanvasPattern.h"
#include "CanvasRenderingContext2D.h"
#include "CanvasStyle.h"
#include "Document.h"
#include "FrameView.h"
#include "GraphicsContext.h"
#include "HTMLNames.h"
#include "RenderHTMLCanvas.h"
......@@ -149,18 +151,28 @@ void HTMLCanvasElement::createDrawingContext() const
m_createdDrawingContext = true;
if (width() <= 0 || height() <= 0)
float unscaledWidth = width();
float unscaledHeight = height();
float scaleFactor = document()->view() ? document()->view()->scaleFactor() : 1.0f;
float wf = ceilf(unscaledWidth * scaleFactor);
float hf = ceilf(unscaledHeight * scaleFactor);
if (!(wf > 0 && wf < UINT_MAX && hf > 0 && hf < UINT_MAX))
return;
unsigned w = width();
unsigned w = static_cast<unsigned>(wf);
unsigned h = static_cast<unsigned>(hf);
size_t bytesPerRow = w * 4;
if (bytesPerRow / 4 != w) // check for overflow
return;
m_data = fastCalloc(height(), bytesPerRow);
m_data = fastCalloc(h, bytesPerRow);
if (!m_data)
return;
#if __APPLE__
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef bitmapContext = CGBitmapContextCreate(m_data, w, height(), 8, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
CGContextRef bitmapContext = CGBitmapContextCreate(m_data, w, h, 8, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
CGContextScaleCTM(bitmapContext, w / unscaledWidth, h / unscaledHeight);
CGColorSpaceRelease(colorSpace);
m_drawingContext = new GraphicsContext(bitmapContext);
CGContextRelease(bitmapContext);
......
......@@ -136,6 +136,8 @@ namespace WebCore {
NSView* getView() const;
NSView* getOuterView() const;
void setView(NSView*);
float scaleFactor() const;
void sendConsumedMouseUp();
......
......@@ -295,6 +295,11 @@ void Widget::setView(NSView* view)
END_BLOCK_OBJC_EXCEPTIONS;
}
float Widget::scaleFactor() const
{
return [[getView() window] userSpaceScaleFactor];
}
NSView* Widget::getOuterView() const
{
// If this widget's view is a WebCoreFrameView the we resize its containing view, a WebFrameView.
......
......@@ -151,4 +151,9 @@ IntPoint Widget::mapFromGlobal(const IntPoint &p) const
return point;
}
float Widget::scaleFactor() const
{
return 1.0f;
}
}
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