- Revision
- 98406
- Author
- [email protected]
- Date
- 2011-10-25 16:10:12 -0700 (Tue, 25 Oct 2011)
Log Message
https://bugs.webkit.org/show_bug.cgi?id=70852
Setting up a HiDPI base-level GraphicsContext should be more straightforward for
WebKit2
Reviewed by Dan Bernstein.
Source/WebCore:
This patch removes the old cg-only GraphicsContext::setBaseCTM() api, and adds
platform-independent GraphicsContext::applyDeviceScaleFactor().
* WebCore.exp.in:
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
(WebCore::GraphicsContext::applyDeviceScaleFactor):
* platform/graphics/GraphicsContext.h:
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
Since this patch removes GraphicsContext::setBaseCTM(), this code has been
reverted to do what it used to do before that was added; it just calls into
WebCoreSystemInterface directly.
* platform/graphics/cg/ImageCG.cpp:
(WebCore::Image::drawPattern):
Source/WebKit2:
When we need a base-level HiDPI GraphicsContext, call into new GraphicsContext api
GraphicsContext::applyDeviceScaleFactor() rather than manually scaling and
adjusting the base CTM.
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::display):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::snapshotInViewCoordinates):
(WebKit::WebPage::scaledSnapshotInDocumentCoordinates):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (98405 => 98406)
--- trunk/Source/WebCore/ChangeLog 2011-10-25 23:06:13 UTC (rev 98405)
+++ trunk/Source/WebCore/ChangeLog 2011-10-25 23:10:12 UTC (rev 98406)
@@ -1,3 +1,27 @@
+2011-10-25 Beth Dakin <[email protected]>
+
+ https://bugs.webkit.org/show_bug.cgi?id=70852
+ Setting up a HiDPI base-level GraphicsContext should be more straightforward for
+ WebKit2
+
+ Reviewed by Dan Bernstein.
+
+ This patch removes the old cg-only GraphicsContext::setBaseCTM() api, and adds
+ platform-independent GraphicsContext::applyDeviceScaleFactor().
+ * WebCore.exp.in:
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
+ (WebCore::GraphicsContext::applyDeviceScaleFactor):
+ * platform/graphics/GraphicsContext.h:
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
+
+ Since this patch removes GraphicsContext::setBaseCTM(), this code has been
+ reverted to do what it used to do before that was added; it just calls into
+ WebCoreSystemInterface directly.
+ * platform/graphics/cg/ImageCG.cpp:
+ (WebCore::Image::drawPattern):
+
2011-10-25 Anders Carlsson <[email protected]>
Plug-ins have to use _javascript_ to find out the current device scale factor
Modified: trunk/Source/WebCore/WebCore.exp.in (98405 => 98406)
--- trunk/Source/WebCore/WebCore.exp.in 2011-10-25 23:06:13 UTC (rev 98405)
+++ trunk/Source/WebCore/WebCore.exp.in 2011-10-25 23:10:12 UTC (rev 98406)
@@ -428,6 +428,7 @@
__ZN7WebCore15GraphicsContext20setShouldSmoothFontsEb
__ZN7WebCore15GraphicsContext20endTransparencyLayerEv
__ZN7WebCore15GraphicsContext21setCompositeOperationENS_17CompositeOperatorE
+__ZN7WebCore15GraphicsContext22applyDeviceScaleFactorEf
__ZN7WebCore15GraphicsContext22beginTransparencyLayerEf
__ZN7WebCore15GraphicsContext28setImageInterpolationQualityENS_20InterpolationQualityE
__ZN7WebCore15GraphicsContext4clipERKNS_4PathE
@@ -1218,7 +1219,6 @@
__ZNK7WebCore14SecurityOrigin18databaseIdentifierEv
__ZNK7WebCore14SecurityOrigin5equalEPKS0_
__ZNK7WebCore15FocusController18focusedOrMainFrameEv
-__ZN7WebCore15GraphicsContext10setBaseCTMERKNS_15AffineTransformE
__ZNK7WebCore15GraphicsContext15platformContextEv
__ZNK7WebCore15GraphicsContext16paintingDisabledEv
__ZNK7WebCore15GraphicsContext20updatingControlTintsEv
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (98405 => 98406)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2011-10-25 23:06:13 UTC (rev 98405)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2011-10-25 23:10:12 UTC (rev 98406)
@@ -764,4 +764,16 @@
return buffer.release();
}
+#if !USE(CG)
+void GraphicsContext::platformApplyDeviceScaleFactor()
+{
}
+#endif
+
+void GraphicsContext::applyDeviceScaleFactor(float deviceScaleFactor)
+{
+ scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
+ platformApplyDeviceScaleFactor();
+}
+
+}
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (98405 => 98406)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2011-10-25 23:06:13 UTC (rev 98405)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2011-10-25 23:10:12 UTC (rev 98406)
@@ -269,8 +269,6 @@
bool isCALayerContext() const;
void setIsAcceleratedContext(bool);
-
- void setBaseCTM(const AffineTransform&);
#endif
bool isAcceleratedContext() const;
@@ -415,6 +413,11 @@
// for drawing into the buffer and then into this context.
PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&) const;
+ // This function applies the device scale factor to the context, making the context capable of
+ // acting as a base-level context for a HiDPI environment.
+ void applyDeviceScaleFactor(float);
+ void platformApplyDeviceScaleFactor();
+
#if OS(WINCE) && !PLATFORM(QT)
void setBitmap(PassRefPtr<SharedBitmap>);
const AffineTransform& affineTransform() const;
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (98405 => 98406)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2011-10-25 23:06:13 UTC (rev 98405)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2011-10-25 23:10:12 UTC (rev 98406)
@@ -1470,11 +1470,6 @@
return m_data->m_contextFlags & IsAcceleratedCGContext;
}
-void GraphicsContext::setBaseCTM(const AffineTransform& transform)
-{
- wkSetBaseCTM(platformContext(), transform);
-}
-
void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode)
{
if (paintingDisabled())
@@ -1597,4 +1592,12 @@
CGContextSetBlendMode(platformContext(), target);
}
+void GraphicsContext::platformApplyDeviceScaleFactor()
+{
+ // CoreGraphics expects the base CTM of a HiDPI context to have the scale factor applied to it.
+ // Failing to change the base level CTM will cause certain CG features, such as focus rings,
+ // to draw with a scale factor of 1 rather than the actual scale factor.
+ wkSetBaseCTM(platformContext(), getCTM());
}
+
+}
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageCG.cpp (98405 => 98406)
--- trunk/Source/WebCore/platform/graphics/cg/ImageCG.cpp 2011-10-25 23:06:13 UTC (rev 98405)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageCG.cpp 2011-10-25 23:10:12 UTC (rev 98406)
@@ -284,9 +284,7 @@
CGContextSetFillColorSpace(context, patternSpace.get());
// FIXME: Really want a public API for this. It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy).
- AffineTransform identity;
- identity.makeIdentity();
- ctxt->setBaseCTM(identity);
+ wkSetBaseCTM(context, CGAffineTransformIdentity);
CGContextSetPatternPhase(context, CGSizeZero);
CGContextSetFillColorWithColor(context, color.get());
Modified: trunk/Source/WebKit2/ChangeLog (98405 => 98406)
--- trunk/Source/WebKit2/ChangeLog 2011-10-25 23:06:13 UTC (rev 98405)
+++ trunk/Source/WebKit2/ChangeLog 2011-10-25 23:10:12 UTC (rev 98406)
@@ -1,3 +1,20 @@
+2011-10-25 Beth Dakin <[email protected]>
+
+ https://bugs.webkit.org/show_bug.cgi?id=70852
+ Setting up a HiDPI base-level GraphicsContext should be more straightforward for
+ WebKit2
+
+ Reviewed by Dan Bernstein.
+
+ When we need a base-level HiDPI GraphicsContext, call into new GraphicsContext api
+ GraphicsContext::applyDeviceScaleFactor() rather than manually scaling and
+ adjusting the base CTM.
+ * WebProcess/WebPage/DrawingAreaImpl.cpp:
+ (WebKit::DrawingAreaImpl::display):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::snapshotInViewCoordinates):
+ (WebKit::WebPage::scaledSnapshotInDocumentCoordinates):
+
2011-10-25 Anders Carlsson <[email protected]>
Plug-ins have to use _javascript_ to find out the current device scale factor
Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp (98405 => 98406)
--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp 2011-10-25 23:06:13 UTC (rev 98405)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp 2011-10-25 23:10:12 UTC (rev 98406)
@@ -646,7 +646,8 @@
ASSERT(m_webPage->bounds().contains(bounds));
IntSize bitmapSize = bounds.size();
- bitmapSize.scale(m_webPage->corePage()->deviceScaleFactor());
+ float deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
+ bitmapSize.scale(deviceScaleFactor);
RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha);
if (!bitmap)
return;
@@ -669,10 +670,7 @@
m_scrollOffset = IntSize();
OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext(bitmap.get());
- graphicsContext->scale(FloatSize(m_webPage->corePage()->deviceScaleFactor(), m_webPage->corePage()->deviceScaleFactor()));
-#if USE(CG)
- graphicsContext->setBaseCTM(graphicsContext->getCTM());
-#endif
+ graphicsContext->applyDeviceScaleFactor(deviceScaleFactor);
updateInfo.updateRectBounds = bounds;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (98405 => 98406)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2011-10-25 23:06:13 UTC (rev 98405)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2011-10-25 23:10:12 UTC (rev 98406)
@@ -943,10 +943,7 @@
return 0;
OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
- graphicsContext->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
-#if USE(CG)
- graphicsContext->setBaseCTM(graphicsContext->getCTM());
-#endif
+ graphicsContext->applyDeviceScaleFactor(deviceScaleFactor);
graphicsContext->translate(-rect.x(), -rect.y());
frameView->updateLayoutAndStyleIfNeededRecursive();
@@ -972,10 +969,7 @@
return 0;
OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
- graphicsContext->scale(FloatSize(combinedScaleFactor, combinedScaleFactor));
-#if USE(CG)
- graphicsContext->setBaseCTM(graphicsContext->getCTM());
-#endif
+ graphicsContext->applyDeviceScaleFactor(combinedScaleFactor);
graphicsContext->translate(-rect.x(), -rect.y());
frameView->updateLayoutAndStyleIfNeededRecursive();