⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 97191 in webkit


Ignore:
Timestamp:
Oct 11, 2011, 4:05:33 PM (15 years ago)
Author:
Beth Dakin
Message:

https://bugs.webkit.org/show_bug.cgi?id=69874
WebKit2 snapshot APIs should take the device scale factor into account
-and corresponding-
<rdar://problem/10269112>

Reviewed by Darin Adler.

Add the deviceScaleFactor as a scale on the snapshot's context to create a
snapshot of the appropriate resolution. This matches the manner in which we scale
the context in DrawingAreaImpl::display().

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::snapshotInViewCoordinates):
(WebKit::WebPage::scaledSnapshotInDocumentCoordinates):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r97188 r97191  
     12011-10-11  Beth Dakin  <bdakin@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=69874
     4        WebKit2 snapshot APIs should take the device scale factor into account
     5        -and corresponding-
     6        <rdar://problem/10269112>
     7
     8        Reviewed by Darin Adler.
     9
     10        Add the deviceScaleFactor as a scale on the snapshot's context to create a
     11        snapshot of the appropriate resolution. This matches the manner in which we scale
     12        the context in DrawingAreaImpl::display().
     13        * WebProcess/WebPage/WebPage.cpp:
     14        (WebKit::WebPage::snapshotInViewCoordinates):
     15        (WebKit::WebPage::scaledSnapshotInDocumentCoordinates):
     16
    1172011-10-11  W. James MacLean  <wjmaclean@chromium.org>
    218
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r97167 r97191  
    916916        return 0;
    917917
    918     RefPtr<WebImage> snapshot = WebImage::create(rect.size(), options);
     918    IntSize bitmapSize = rect.size();
     919    float deviceScaleFactor = corePage()->deviceScaleFactor();
     920    bitmapSize.scale(deviceScaleFactor);
     921
     922    RefPtr<WebImage> snapshot = WebImage::create(bitmapSize, options);
    919923    if (!snapshot->bitmap())
    920924        return 0;
    921925   
    922926    OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
     927    graphicsContext->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
    923928    graphicsContext->translate(-rect.x(), -rect.y());
    924929
     
    939944        return 0;
    940945
    941     IntSize size(ceil(rect.width() * scaleFactor), ceil(rect.height() * scaleFactor));
     946    float combinedScaleFactor = scaleFactor * corePage()->deviceScaleFactor();
     947    IntSize size(ceil(rect.width() * combinedScaleFactor), ceil(rect.height() * combinedScaleFactor));
    942948    RefPtr<WebImage> snapshot = WebImage::create(size, options);
    943949    if (!snapshot->bitmap())
     
    945951
    946952    OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
    947     graphicsContext->scale(FloatSize(scaleFactor, scaleFactor));
     953    graphicsContext->scale(FloatSize(combinedScaleFactor, combinedScaleFactor));
    948954    graphicsContext->translate(-rect.x(), -rect.y());
    949955
Note: See TracChangeset for help on using the changeset viewer.