WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
62406
[chromium] Printing does not work for accelerated <canvas>
https://bugs.webkit.org/show_bug.cgi?id=62406
Summary
[chromium] Printing does not work for accelerated <canvas>
Stephen White
Reported
2011-06-09 14:36:05 PDT
When accelerated canvas is enabled, canvas elements are omitted from the printed output.
Attachments
Patch
(5.67 KB, patch)
2011-06-09 14:47 PDT
,
Stephen White
no flags
Details
Formatted Diff
Diff
Patch
(4.43 KB, patch)
2011-06-09 15:31 PDT
,
Stephen White
no flags
Details
Formatted Diff
Diff
Patch
(2.62 KB, patch)
2011-06-09 17:46 PDT
,
Stephen White
no flags
Details
Formatted Diff
Diff
Patch
(2.78 KB, patch)
2011-06-10 12:03 PDT
,
Stephen White
no flags
Details
Formatted Diff
Diff
Patch
(2.27 KB, patch)
2011-07-27 12:18 PDT
,
Stephen White
no flags
Details
Formatted Diff
Diff
Patch
(2.54 KB, patch)
2011-07-27 12:25 PDT
,
Stephen White
jamesr
: review+
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Stephen White
Comment 1
2011-06-09 14:36:23 PDT
See also
http://code.google.com/p/chromium/issues/detail?id=55927
Stephen White
Comment 2
2011-06-09 14:47:40 PDT
Created
attachment 96648
[details]
Patch
Stephen White
Comment 3
2011-06-09 15:31:16 PDT
Created
attachment 96654
[details]
Patch
James Robinson
Comment 4
2011-06-09 16:04:40 PDT
Comment on
attachment 96654
[details]
Patch Is there any way we can hide this in paintsIntoCanvasBuffer() or something? Sucks to modify the GraphicsContext interface just for this...
Stephen White
Comment 5
2011-06-09 16:54:38 PDT
(In reply to
comment #4
)
> (From update of
attachment 96654
[details]
) > Is there any way we can hide this in paintsIntoCanvasBuffer() or something? Sucks to modify the GraphicsContext interface just for this...
Unfortunately, no. paintsIntoCanvasBuffer() is on the source GraphicsContext3D/SharedGraphicsContext3D, whereas we need to check the destination GraphicsContext. Even if SGC3D had access to the GraphicsContext, it would be the wrong one.
James Robinson
Comment 6
2011-06-09 16:57:02 PDT
Le suck - what about asking our Document if we're printing? I believe the only time we'll try to paint a canvas when printing is when it's in the DOM, and Document already has a printing() accessor. Remember to null check on the way to the Document.
Stephen White
Comment 7
2011-06-09 17:39:54 PDT
(In reply to
comment #6
)
> Le suck - what about asking our Document if we're printing? I believe the only time we'll try to paint a canvas when printing is when it's in the DOM, and Document already has a printing() accessor. Remember to null check on the way to the Document.
Great idea. Will give that a shot.
Stephen White
Comment 8
2011-06-09 17:46:20 PDT
Created
attachment 96677
[details]
Patch
James Robinson
Comment 9
2011-06-09 17:53:55 PDT
Comment on
attachment 96677
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=96677&action=review
R=me
> Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:139 > + if (!bitmap.getPixels()) {
can you leave some sort of comment indicating when getPixels() returns NULL and why we gotta do a readPixels() when it does?
Mike Reed
Comment 10
2011-06-10 04:33:44 PDT
can we not pass srcRect to the readPixels call, to avoid reading back more than we need?
Stephen White
Comment 11
2011-06-10 07:22:04 PDT
(In reply to
comment #10
)
> can we not pass srcRect to the readPixels call, to avoid reading back more than we need?
See the FIXME. I was going to do this in a followup just to make sure I didn't screw up the resulting srcRect adjustment, but I'll give it a shot now.
Mike Reed
Comment 12
2011-06-10 09:21:58 PDT
Skia fix in sight. Monday or Tuesday.
Stephen White
Comment 13
2011-06-10 12:03:52 PDT
Created
attachment 96770
[details]
Patch
James Robinson
Comment 14
2011-06-10 12:08:45 PDT
Comment on
attachment 96770
[details]
Patch R=me. Sounds like we'll be able to get rid of this soon with a skia change, tho, right?
Stephen White
Comment 15
2011-06-10 12:13:28 PDT
(In reply to
comment #14
)
> (From update of
attachment 96770
[details]
) > R=me. Sounds like we'll be able to get rid of this soon with a skia change, tho, right?
Yes, that's my understanding. Note that further testing has revealed that this is not a complete fix -- it works for Maps directions and some simple pages, but doesn't work for more complex pages. I'm guessing this is because although canvas is doing a readback, the compositor isn't. I might look into that before committing this.
Stephen White
Comment 16
2011-07-27 12:18:55 PDT
Created
attachment 102166
[details]
Patch
Stephen White
Comment 17
2011-07-27 12:25:55 PDT
Created
attachment 102169
[details]
Patch
Stephen White
Comment 18
2011-07-27 12:28:01 PDT
(In reply to
comment #17
)
> Created an attachment (id=102169) [details] > Patch
Updated to recent WebKit and to use the pixel readback now built-in to SkBitmap::lockPixels().
James Robinson
Comment 19
2011-07-27 12:31:33 PDT
Comment on
attachment 102169
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=102169&action=review
Looks good
> Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:119 > context->platformContext()->makeGrContextCurrent();
do you still need this makeCurrent()?
Stephen White
Comment 20
2011-07-27 12:33:49 PDT
(In reply to
comment #19
)
> (From update of
attachment 102169
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=102169&action=review
> > Looks good > > > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:119 > > context->platformContext()->makeGrContextCurrent(); > > do you still need this makeCurrent()?
In theory, no, since we always use the same context under the hood. But it seems a little fragile to rely on that, so I think this is safer.
Stephen White
Comment 21
2011-07-27 14:51:22 PDT
Committed
r91870
: <
http://trac.webkit.org/changeset/91870
>
James Robinson
Comment 22
2011-07-29 17:02:51 PDT
Comment on
attachment 102169
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=102169&action=review
> Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:118 > + m_context->platformContext()->makeGrContextCurrent(); > + SkDevice* srcDevice = m_context->platformContext()->canvas()->getDevice(); > + SkBitmap bitmap = srcDevice->accessBitmap(false); > + SkAutoLockPixels bitmapLock(bitmap);
I'm pretty sure that something in here is causing us to do a readback for every canvas->canvas draw now :/
Mike Reed
Comment 23
2011-08-01 06:45:38 PDT
The lockpixels seems unnecessary. We should only see that in a stackframe if we're directly accessing the pixels in the same frame. Are we sure we need this here? Calling BitmapImageSingleFrameSkia::create(bitmap, forceCopy) will perform a readback if forceCopy is set to true. I will work with Brian to see if we can change bitmap::copyTo() to not force a readback.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug