Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Issue 12184010: skia::AnalysisCanvas: implementation for IsCheapInRect(). (Closed)

Created:
7 years, 10 months ago by Tom Hudson
Modified:
7 years, 10 months ago
CC:
chromium-reviews, cc-bugs_chromium.org, Sami
Visibility:
Public.

Description

skia::AnalysisCanvas: implementation for IsCheapInRect(). Minimal implementation for cc::Picture::IsCheapInRect(), without bringing in SkBBoxHierarchy speedup possibilities. As we find effects & relative impacts we can drop them in the overrides in analysis_canvas.cc. Based on the approach Android Browser used to check SkPictures for optimizations (Is this a single color fill? Does it contain text?). This prototype version only counts draw calls. It ignores the clip rect. It does not correctly handle any of the three high costs associated with theverge.com: image decodes (need to expand LazyPixelRef AIP?), glyph cache misses (need to expand Skia API?), and antialiased filled paths (need to recreate some side-effects buried in Skia). I think we can also hide all the SkDevice boilerplate inside analysis_canvas if we write a factory function; that will happen in a follow-on patch. TBR=nduca,junov,tomhudson CC=skyostil BUG=173426

Patch Set 1 #

Total comments: 4

Patch Set 2 : Wrote device boilerplate #

Total comments: 20

Patch Set 3 : Respond to reviewer comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+315 lines, -3 lines) Patch
M cc/picture.cc View 1 2 3 chunks +28 lines, -3 lines 0 comments Download
A skia/ext/analysis_canvas.h View 1 2 1 chunk +87 lines, -0 lines 0 comments Download
A skia/ext/analysis_canvas.cc View 1 2 1 chunk +198 lines, -0 lines 0 comments Download
M skia/skia.gyp View 1 2 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
Tom Hudson
7 years, 10 months ago (2013-02-04 10:19:23 UTC) #1
nduca
Even this lgtm [with the tweak below] as a way to start hacking on using ...
7 years, 10 months ago (2013-02-04 10:34:32 UTC) #2
Sami
https://codereview.chromium.org/12184010/diff/1/cc/picture.cc File cc/picture.cc (right): https://codereview.chromium.org/12184010/diff/1/cc/picture.cc#newcode112 cc/picture.cc:112: bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) { Should we make this ...
7 years, 10 months ago (2013-02-04 10:57:54 UTC) #3
Justin Novosad
I am pretty sure this is the correct general approach, we'll just have to add ...
7 years, 10 months ago (2013-02-04 14:28:50 UTC) #4
Justin Novosad
https://codereview.chromium.org/12184010/diff/6001/cc/picture.cc File cc/picture.cc (right): https://codereview.chromium.org/12184010/diff/6001/cc/picture.cc#newcode107 cc/picture.cc:107: emptyBitmap.setConfig(SkBitmap::kARGB_8888_Config, picture_->width(), Config should be SkBitmap::kNo_Config
7 years, 10 months ago (2013-02-04 20:23:55 UTC) #5
Justin Novosad
General comments: I thing AnalysisCanvas should wrap an "analysis device", derived from SkDevice. Most of ...
7 years, 10 months ago (2013-02-04 22:03:31 UTC) #6
Justin Novosad
https://codereview.chromium.org/12184010/diff/6001/skia/ext/analysis_canvas.h File skia/ext/analysis_canvas.h (right): https://codereview.chromium.org/12184010/diff/6001/skia/ext/analysis_canvas.h#newcode26 skia/ext/analysis_canvas.h:26: virtual int save(SkCanvas::SaveFlags = kMatrixClip_SaveFlag); SK_OVERRIDE on all the ...
7 years, 10 months ago (2013-02-04 22:08:04 UTC) #7
Tom Hudson
https://codereview.chromium.org/12184010/diff/6001/cc/picture.cc File cc/picture.cc (right): https://codereview.chromium.org/12184010/diff/6001/cc/picture.cc#newcode107 cc/picture.cc:107: emptyBitmap.setConfig(SkBitmap::kARGB_8888_Config, picture_->width(), On 2013/02/04 20:23:55, junov wrote: > Config ...
7 years, 10 months ago (2013-02-05 10:23:24 UTC) #8
nduca
Chrome has OVERRIDE
7 years, 10 months ago (2013-02-05 10:39:30 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/tomhudson@chromium.org/12184010/12001
7 years, 10 months ago (2013-02-05 10:43:04 UTC) #10
commit-bot: I haz the power
Sorry for I got bad news for ya. Compile failed with a clobber build on ...
7 years, 10 months ago (2013-02-05 10:59:49 UTC) #11
Tom Hudson
On 2013/02/05 10:39:30, nduca wrote: > Chrome has OVERRIDE ...which reveals that one of my ...
7 years, 10 months ago (2013-02-05 11:53:50 UTC) #12
Justin Novosad
On 2013/02/05 11:53:50, Tom Hudson wrote: > ...which reveals that one of my function signatures ...
7 years, 10 months ago (2013-02-05 12:23:58 UTC) #13
Tom Hudson
7 years, 10 months ago (2013-02-05 17:01:59 UTC) #14
It's my intent to close this CL and replace it with
https://codereview.chromium.org/12213018, which is SkDevice-based, but I think
that's not going to apply cleanly (thanks to git branching structures).

PTAL there.

https://codereview.chromium.org/12184010/diff/1/cc/picture.cc
File cc/picture.cc (right):

https://codereview.chromium.org/12184010/diff/1/cc/picture.cc#newcode112
cc/picture.cc:112: bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) {
On 2013/02/04 10:57:54, Sami wrote:
> Should we make this a const method?

Done.

I also had to add contents_scale to the list of args so that the AnalysisCanvas
would line up with the real canvas in Raster().

https://codereview.chromium.org/12184010/diff/1/cc/picture.cc#newcode123
cc/picture.cc:123: if (canvas.getEstimatedCost() <= pictureCostThreshold) {
On 2013/02/04 10:34:33, nduca wrote:
> love this. convert this to bool isCheap() and push the threshold to
analyscanvas
> maybe? That way we dont have to instantiate a cc picture in order to unit test
> it.

Done.

https://codereview.chromium.org/12184010/diff/6001/skia/ext/analysis_canvas.cc
File skia/ext/analysis_canvas.cc (right):

https://codereview.chromium.org/12184010/diff/6001/skia/ext/analysis_canvas.c...
skia/ext/analysis_canvas.cc:32: ++estimatedCost_;
On 2013/02/04 22:03:31, junov wrote:
> In the case of save layer we want to flow-through but without allocating a
> layer.  
> See how SkPictureRecord does this using save + clipRectBounds.

Done.

I'm not sure about the clipRectBounds, though, because if I'm reading
PicturePileImpl correctly we're dealing with a clip that is (rect - bunch of
rects), and so just taking its bounds is way too conservative and overestimates
cost.

https://codereview.chromium.org/12184010/diff/6001/skia/ext/analysis_canvas.c...
skia/ext/analysis_canvas.cc:40: ++estimatedCost_;
On 2013/02/04 22:03:31, junov wrote:
> You want this to flow-through to base class, force doAA to false for speed.

Done.

I'm not sure about forcing AA to false, though, because we need to know if
something is going to be AA to detect expensive mask filters?

https://codereview.chromium.org/12184010/diff/6001/skia/ext/analysis_canvas.c...
skia/ext/analysis_canvas.cc:97: if (doFill && paint.getMaskFilter()) {
On 2013/02/04 22:03:31, junov wrote:
> The Mask filter should result in the same perf penalty regardless of fill
style.
> It basically applies a blur to a rasterized mask that is the size of the bbox.

> I would get rid of this special-case code until we have facts (numbers) to
> support it.

Done.

https://codereview.chromium.org/12184010/diff/6001/skia/ext/analysis_canvas.c...
skia/ext/analysis_canvas.cc:110: ++estimatedCost_;
On 2013/02/04 22:03:31, junov wrote:
> If you gathered stats in an SkDevice-derived class instead (AnalysisDevice?), 
> you would have fewer drawBitmap variants to overload.

Done.

https://codereview.chromium.org/12184010/diff/6001/skia/ext/analysis_canvas.c...
skia/ext/analysis_canvas.cc:133: void AnalysisCanvas::drawText(const void*,
size_t, SkScalar, SkScalar,
On 2013/02/04 22:03:31, junov wrote:
> If you gathered stats in an SkDevice-derived class instead, 
> you would have fewer drawText variants to overload.

Done.

Powered by Google App Engine
This is Rietveld 408576698