2009-10-26 Simon Fraser <simon.fraser@apple.com>

        Reviewed by Sam Weinig.

        <rdar://problem/6988966> Hardware layers do not show up in page snapshots

        * WebView/WebHTMLViewPrivate.h:
        * WebView/WebHTMLView.mm:
        (-[WebHTMLView _compositingLayersHostingView]):
        Add a private method that returns the NSView used to host compositing layers.

        * platform/graphics/mac/Canvas3DLayer.h:
        * platform/graphics/mac/Canvas3DLayer.mm:
        (-[Canvas3DLayer copyImageSnapshotWithColorSpace:]):
        Add a method that gets called when snapshotting Canvas3DLayers for page snapshots,
        that allows the layer to return a CGImageRef of its contents.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50067 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 940afb7e
2009-10-26 Simon Fraser <simon.fraser@apple.com>
Reviewed by Sam Weinig.
<rdar://problem/6988966> Hardware layers do not show up in page snapshots
Add a method that gets called when snapshotting Canvas3DLayers for page snapshots,
that allows the layer to return a CGImageRef of its contents.
* platform/graphics/mac/Canvas3DLayer.h:
* platform/graphics/mac/Canvas3DLayer.mm:
(-[Canvas3DLayer copyImageSnapshotWithColorSpace:]):
2009-10-26 Yury Semikhatsky <yurys@chromium.org>
Reviewed by Pavel Feldman.
......@@ -41,7 +41,9 @@ namespace WebCore {
GLuint m_texture;
}
-(id)initWithContext:(CGLContextObj)context texture:(GLuint)texture;
- (id)initWithContext:(CGLContextObj)context texture:(GLuint)texture;
- (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace;
@end
......
......@@ -33,6 +33,8 @@
#import "GraphicsLayer.h"
#import <QuartzCore/QuartzCore.h>
#import <OpenGL/OpenGL.h>
#import <wtf/RetainPtr.h>
#include <wtf/FastMalloc.h>
using namespace WebCore;
......@@ -107,6 +109,42 @@ using namespace WebCore;
[super drawInCGLContext:glContext pixelFormat:pixelFormat forLayerTime:timeInterval displayTime:timeStamp];
}
static void freeData(void *, const void *data, size_t /* size */)
{
fastFree(const_cast<void *>(data));
}
-(CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace
{
CGLSetCurrentContext(m_contextObj);
RetainPtr<CGColorSpaceRef> imageColorSpace = colorSpace;
if (!imageColorSpace)
imageColorSpace.adoptCF(CGColorSpaceCreateDeviceRGB());
CGRect layerBounds = CGRectIntegral([self bounds]);
size_t width = layerBounds.size.width;
size_t height = layerBounds.size.height;
size_t rowBytes = (width * 4 + 15) & ~15;
size_t dataSize = rowBytes * height;
void* data = fastMalloc(dataSize);
if (!data)
return 0;
glPixelStorei(GL_PACK_ROW_LENGTH, rowBytes / 4);
glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
CGDataProviderRef provider = CGDataProviderCreateWithData(0, data, dataSize, freeData);
CGImageRef image = CGImageCreate(width, height, 8, 32, rowBytes, imageColorSpace.get(),
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
provider, 0, true,
kCGRenderingIntentDefault);
CGDataProviderRelease(provider);
return image;
}
@end
@implementation Canvas3DLayer(WebLayerAdditions)
......
2009-10-26 Simon Fraser <simon.fraser@apple.com>
Reviewed by Sam Weinig.
<rdar://problem/6988966> Hardware layers do not show up in page snapshots
* WebView/WebHTMLViewPrivate.h:
* WebView/WebHTMLView.mm:
(-[WebHTMLView _compositingLayersHostingView]):
Add a private method that returns the NSView used to host compositing layers.
2009-10-23 Mark Rowe <mrowe@apple.com>
Fix engineering builds in the mysterious future.
......
......@@ -2173,6 +2173,15 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
#endif
}
- (NSView *)_compositingLayersHostingView
{
#if USE(ACCELERATED_COMPOSITING)
return _private->layerHostingView;
#else
return 0;
#endif
}
@end
@implementation NSView (WebHTMLViewFileInternal)
......
......@@ -117,8 +117,8 @@
- (void)_pauseNullEventsForAllNetscapePlugins;
#endif
// SPI for DumpRenderTree
- (BOOL)_isUsingAcceleratedCompositing;
- (NSView *)_compositingLayersHostingView;
// SPI for printing (should be converted to API someday). When the WebHTMLView isn't being printed
// directly, this method must be called before paginating, or the computed height might be incorrect.
......
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