Title: [174414] trunk/Source/WebCore
- Revision
- 174414
- Author
- [email protected]
- Date
- 2014-10-07 19:23:10 -0700 (Tue, 07 Oct 2014)
Log Message
Safari 8 on OSX 10.10 does not run WebGL in Retina HiDPI mode.
https://bugs.webkit.org/show_bug.cgi?id=134854
<rdar://problem/18465263>
Reviewed by Tim Horton.
The NSOpenGLLayer has to have its contentScale property
set accordingly when on a retina display. Do this by
adding another value to the GraphicsContext3D creation
attribute dictionary, representing the device pixel ratio.
Then, when we come to draw into the layer, make sure
we set our GL viewport to the correct value.
This is currently untestable because:
- we can't just read from the GL buffer as it is always correct
- WebGL isn't working in reftests
- a layer dump doesn't show the change since it was done in a CALayer subclass.
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::create): Pass the devicePixelRatio into the attribute dictionary.
* platform/graphics/GraphicsContext3D.h:
(WebCore::GraphicsContext3D::Attributes::Attributes): Add a devicePixelRatio attribute.
* platform/graphics/mac/WebGLLayer.h: New property to save us looking up the attributes
each frame.
* platform/graphics/mac/WebGLLayer.mm:
(-[WebGLLayer initWithGraphicsContext3D:]): Store the devicePixelRatio, and set our
contents scale appropriately.
(-[WebGLLayer drawInCGLContext:pixelFormat:forLayerTime:displayTime:]): Draw into
a correctly sized backbuffer.
(-[WebGLLayer copyImageSnapshotWithColorSpace:]): Generate an image of the correct size.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (174413 => 174414)
--- trunk/Source/WebCore/ChangeLog 2014-10-08 00:41:42 UTC (rev 174413)
+++ trunk/Source/WebCore/ChangeLog 2014-10-08 02:23:10 UTC (rev 174414)
@@ -1,3 +1,36 @@
+2014-10-08 Dean Jackson <[email protected]>
+
+ Safari 8 on OSX 10.10 does not run WebGL in Retina HiDPI mode.
+ https://bugs.webkit.org/show_bug.cgi?id=134854
+ <rdar://problem/18465263>
+
+ Reviewed by Tim Horton.
+
+ The NSOpenGLLayer has to have its contentScale property
+ set accordingly when on a retina display. Do this by
+ adding another value to the GraphicsContext3D creation
+ attribute dictionary, representing the device pixel ratio.
+ Then, when we come to draw into the layer, make sure
+ we set our GL viewport to the correct value.
+
+ This is currently untestable because:
+ - we can't just read from the GL buffer as it is always correct
+ - WebGL isn't working in reftests
+ - a layer dump doesn't show the change since it was done in a CALayer subclass.
+
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::create): Pass the devicePixelRatio into the attribute dictionary.
+ * platform/graphics/GraphicsContext3D.h:
+ (WebCore::GraphicsContext3D::Attributes::Attributes): Add a devicePixelRatio attribute.
+ * platform/graphics/mac/WebGLLayer.h: New property to save us looking up the attributes
+ each frame.
+ * platform/graphics/mac/WebGLLayer.mm:
+ (-[WebGLLayer initWithGraphicsContext3D:]): Store the devicePixelRatio, and set our
+ contents scale appropriately.
+ (-[WebGLLayer drawInCGLContext:pixelFormat:forLayerTime:displayTime:]): Draw into
+ a correctly sized backbuffer.
+ (-[WebGLLayer copyImageSnapshotWithColorSpace:]): Generate an image of the correct size.
+
2014-10-07 Simon Fraser <[email protected]>
Roll-over Changelogs.
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (174413 => 174414)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2014-10-08 00:41:42 UTC (rev 174413)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2014-10-08 02:23:10 UTC (rev 174414)
@@ -434,6 +434,9 @@
if (frame->settings().forceSoftwareWebGLRendering())
attributes.forceSoftwareRenderer = true;
+ if (page)
+ attributes.devicePixelRatio = page->deviceScaleFactor();
+
if (isPendingPolicyResolution) {
LOG(WebGL, "Create a WebGL context that looks real, but will require a policy resolution if used.");
std::unique_ptr<WebGLRenderingContext> renderingContext(new WebGLRenderingContext(canvas, attributes));
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (174413 => 174414)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2014-10-08 00:41:42 UTC (rev 174413)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2014-10-08 02:23:10 UTC (rev 174414)
@@ -442,6 +442,7 @@
, shareResources(true)
, preferDiscreteGPU(false)
, forceSoftwareRenderer(false)
+ , devicePixelRatio(1)
{
}
@@ -455,6 +456,7 @@
bool shareResources;
bool preferDiscreteGPU;
bool forceSoftwareRenderer;
+ float devicePixelRatio;
};
enum RenderStyle {
Modified: trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.h (174413 => 174414)
--- trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.h 2014-10-08 00:41:42 UTC (rev 174413)
+++ trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.h 2014-10-08 02:23:10 UTC (rev 174414)
@@ -40,6 +40,7 @@
#endif
{
WebCore::GraphicsContext3D* _context;
+ float _devicePixelRatio;
}
@property (nonatomic) WebCore::GraphicsContext3D* context;
Modified: trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.mm (174413 => 174414)
--- trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.mm 2014-10-08 00:41:42 UTC (rev 174413)
+++ trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.mm 2014-10-08 02:23:10 UTC (rev 174414)
@@ -48,6 +48,10 @@
{
_context = context;
self = [super init];
+ _devicePixelRatio = context->getContextAttributes().devicePixelRatio;
+#if !PLATFORM(IOS)
+ self.contentsScale = _devicePixelRatio;
+#endif
return self;
}
@@ -81,7 +85,9 @@
CGLSetCurrentContext(glContext);
CGRect frame = [self frame];
-
+ frame.size.width *= _devicePixelRatio;
+ frame.size.height *= _devicePixelRatio;
+
// draw the FBO into the layer
glViewport(0, 0, frame.size.width, frame.size.height);
glMatrixMode(GL_PROJECTION);
@@ -134,8 +140,8 @@
CGRect layerBounds = CGRectIntegral([self bounds]);
- size_t width = layerBounds.size.width;
- size_t height = layerBounds.size.height;
+ size_t width = layerBounds.size.width * _devicePixelRatio;
+ size_t height = layerBounds.size.height * _devicePixelRatio;
size_t rowBytes = (width * 4 + 15) & ~15;
size_t dataSize = rowBytes * height;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes