get the bits of the complete page
hi, iam working on the gtk port of webkit and have a need to get the bitmap of the entire page without actually rendering it. Is there an easy way to get in the current implementation. one of the ways i thought was to create a cairo surface over a memory buffer (instead of the drawing window in webkit_page_expose_event) and pass it to the scrollview::paint with a complete rectangle. Not sure if this is the right track to solve this issue (also this could be performance/memory intensive) Any inputs would be greatly helpful. thanks, Zaheer
zaheer ahmad wrote:
hi, iam working on the gtk port of webkit and have a need to get the bitmap of the entire page without actually rendering it. Is there an easy way to get in the current implementation. one of the ways i thought was to create a cairo surface over a memory buffer (instead of the drawing window in webkit_page_expose_event) and pass it to the scrollview::paint with a complete rectangle. Not sure if this is the right track to solve this issue (also this could be performance/memory intensive)
There's no public API to render content to an arbitrary graphics context yet. There are a few examples showing how to do it in places like webkitgtkpage.cpp or the experimental printing patch (bug #15576) though, if you're willing to use internal API. Can you give an idea of what you need this for? It might help provide direction for how to expose this in the API, or it might turn out there's a simpler way of doing what you want.
hi alp, i need it to show a resized layout of the complete page that can fit the screen. iam able to do it right now by giving an alternative surface and render it in that. cairo_surface_t *sur =cairo_image_surface_create(CAIRO_FORMAT_RGB24,frame->view()->contentsWidth(),frame->view( )->contentsHeight()); cairo_t* cr_sur = cairo_create(sur); GraphicsContext ctx_sur(cr_sur); IntRect rect(clip.x, clip.y, frame->view()->contentsWidth(), frame->view()->contentsHeight()); frame->paint(&ctx_sur, rect); this seems to be performance intensive, though. thanks, Zaheer On Nov 23, 2007 1:42 PM, Alp Toker <alp@atoker.com> wrote:
zaheer ahmad wrote:
hi, iam working on the gtk port of webkit and have a need to get the bitmap of the entire page without actually rendering it. Is there an easy way to get in the current implementation. one of the ways i thought was to create a cairo surface over a memory buffer (instead of the drawing window in webkit_page_expose_event) and pass it to the scrollview::paint with a complete rectangle. Not sure if this is the right track to solve this issue (also this could be performance/memory intensive)
There's no public API to render content to an arbitrary graphics context yet. There are a few examples showing how to do it in places like webkitgtkpage.cpp or the experimental printing patch (bug #15576) though, if you're willing to use internal API.
Can you give an idea of what you need this for? It might help provide direction for how to expose this in the API, or it might turn out there's a simpler way of doing what you want.
Zaheer, If you really need full page zooming so much and can't wait for the bug to get fixed, try something like this (untested): void webkit_frame_set_scale(WebKitFrame* frame, double scale) { g_return_if_fail(WEBKIT_IS_FRAME(frame)); WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(frame); Frame* wframe = frameData->frame; Document* document = wframe->document(); HTMLElement* root = reinterpret_cast<HTMLElement*>(document->documentElement()); RenderObject* renderer = root->renderer(); RenderStyle* style = renderer->style(); TransformOperations ops; ScaleTransformOperation* scaleOp = new ScaleTransformOperation(scale, scale); ops.append(scaleOp); style->setTransform(ops); renderer->setStyle(style); }
hi alp, thanks a lot for the inputs.. i will try it. regards, Zaheer On Nov 30, 2007 4:47 PM, Alp Toker <alp@atoker.com> wrote:
Zaheer,
If you really need full page zooming so much and can't wait for the bug to get fixed, try something like this (untested):
void webkit_frame_set_scale(WebKitFrame* frame, double scale) { g_return_if_fail(WEBKIT_IS_FRAME(frame));
WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(frame); Frame* wframe = frameData->frame; Document* document = wframe->document(); HTMLElement* root = reinterpret_cast<HTMLElement*>(document->documentElement()); RenderObject* renderer = root->renderer(); RenderStyle* style = renderer->style(); TransformOperations ops; ScaleTransformOperation* scaleOp = new ScaleTransformOperation(scale, scale); ops.append(scaleOp); style->setTransform(ops); renderer->setStyle(style); }
hi, The patch does not reposition the changed document to the top of the frame view and also does not alter the documents width/height. The same behavior is seen with transforms from html pages(e..g scaled content goes out of the window) Are these known issues? Setting the transform origin (style->setTransformOriginX(Length(0,Fixed));) should fix the first problem. A force layout with changed width/height for the renderview should solve the second problem. not sure if this is the right thing to do. let us know your comments. thanks, Zaheer On Nov 30, 2007 4:47 PM, Alp Toker <alp@atoker.com> wrote:
Zaheer,
If you really need full page zooming so much and can't wait for the bug to get fixed, try something like this (untested):
void webkit_frame_set_scale(WebKitFrame* frame, double scale) { g_return_if_fail(WEBKIT_IS_FRAME(frame));
WebKitFramePrivate* frameData = WEBKIT_FRAME_GET_PRIVATE(frame); Frame* wframe = frameData->frame; Document* document = wframe->document(); HTMLElement* root = reinterpret_cast<HTMLElement*>(document->documentElement()); RenderObject* renderer = root->renderer(); RenderStyle* style = renderer->style(); TransformOperations ops; ScaleTransformOperation* scaleOp = new ScaleTransformOperation(scale, scale); ops.append(scaleOp); style->setTransform(ops); renderer->setStyle(style); }
participants (2)
-
Alp Toker
-
zaheer ahmad