Bug 74183 - [Chromium] With the skia port, setting LCD text filtering is causing texture cache invalidations of gpu canvas backing store
Summary: [Chromium] With the skia port, setting LCD text filtering is causing texture ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Windows 7
: P2 Normal
Assignee: Justin Novosad
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-09 07:22 PST by Justin Novosad
Modified: 2012-04-05 11:49 PDT (History)
8 users (show)

See Also:


Attachments
Patch (10.50 KB, patch)
2012-04-05 09:37 PDT, Justin Novosad
no flags Details | Formatted Diff | Diff
Patch (10.50 KB, patch)
2012-04-05 10:50 PDT, Justin Novosad
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Novosad 2011-12-09 07:22:50 PST
Function isCanvasMultiLayered in SkiaFontWin.cpp creates
a layer iterator for the sole purpose of verifying the existence of multiple
layers. The iterator assumes that it is used for drawing, and therefore makes a
call to SkDevice::accessBitmap, which triggers a pixels changed notification, resulting in a GPU texture invalidation in Skia's caching system.  The unnecessary invalidations are preventing the cache form working properly.
Comment 1 Justin Novosad 2011-12-09 07:41:41 PST
The main use case where this causes trouble is with canvas to canvas draws from a software canvas to a GPU accelerated canvas.  The backing store of the source canvas gets cached on the GPU.
Comment 2 Jin Yang 2011-12-13 21:13:16 PST
Bug 73186 is also related to the generation id management.
Comment 3 Justin Novosad 2012-04-05 09:37:01 PDT
Created attachment 135840 [details]
Patch
Comment 4 Justin Novosad 2012-04-05 09:39:54 PDT
(In reply to comment #3)
> Created an attachment (id=135840) [details]
> Patch

In this patch I removed all unnecessary uses of LayerIter that could be replaced with SkCanvas::isDrawingToLayer, not just the one in SkiaFontWin.cpp
Comment 5 Dana Jansens 2012-04-05 09:42:51 PDT
Comment on attachment 135840 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=135840&action=review

> Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp:143
> +    } else if (m_createdTransparencyLayer || m_platformContext->canvas()->isDrawingToLayer()) {

None of these changes are functionally the same, however. The old code checked if there was > 1 layer present. The new code checks if there is > 0 layers present.
Comment 6 Justin Novosad 2012-04-05 10:27:24 PDT
(In reply to comment #5)
> (From update of attachment 135840 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=135840&action=review
> 
> > Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp:143
> > +    } else if (m_createdTransparencyLayer || m_platformContext->canvas()->isDrawingToLayer()) {
> 
> None of these changes are functionally the same, however. The old code checked if there was > 1 layer present. The new code checks if there is > 0 layers present.

Actually, behavior is the same. It is a little confusing, but the fLayerCount in SkCanvas represents the number of saved layers, which does not include the root layer.
Comment 7 Justin Novosad 2012-04-05 10:31:00 PDT
(In reply to comment #6)
 
> Actually, behavior is the same. It is a little confusing, but the fLayerCount in SkCanvas represents the number of saved layers, which does not include the root layer.

There is clearly a readability issue here. I think I will rename fLayerCount to fSavedLayerCount, to make things clearer in SkCanvas.
Comment 8 Dana Jansens 2012-04-05 10:37:00 PDT
Comment on attachment 135840 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=135840&action=review

>>> Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp:143
>>> +    } else if (m_createdTransparencyLayer || m_platformContext->canvas()->isDrawingToLayer()) {
>> 
>> None of these changes are functionally the same, however. The old code checked if there was > 1 layer present. The new code checks if there is > 0 layers present.
> 
> Actually, behavior is the same. It is a little confusing, but the fLayerCount in SkCanvas represents the number of saved layers, which does not include the root layer.

I see, thanks for the clarification. Making that more clear in Skia would be great :)
Comment 9 Stephen White 2012-04-05 10:43:52 PDT
Comment on attachment 135840 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=135840&action=review

> Source/WebKit/chromium/src/WebFontImpl.cpp:116
> +    if (canvasIsOpaque && SkColorGetA(color) == 0xFF && !const_cast<SkCanvas*>(canvas)->isDrawingToLayer()) {

Not your fault, but is this const_cast necessary anymore?  isDrawingToLayer() is const.
Comment 10 Justin Novosad 2012-04-05 10:50:40 PDT
Created attachment 135858 [details]
Patch
Comment 11 Stephen White 2012-04-05 10:54:29 PDT
Comment on attachment 135858 [details]
Patch

Looks good!  r=me
Comment 12 WebKit Review Bot 2012-04-05 11:49:33 PDT
Comment on attachment 135858 [details]
Patch

Clearing flags on attachment: 135858

Committed r113345: <http://trac.webkit.org/changeset/113345>
Comment 13 WebKit Review Bot 2012-04-05 11:49:45 PDT
All reviewed patches have been landed.  Closing bug.