Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(233)

Issue 5696086: draw circle paths directly via GPU (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 2 months ago by guanqun
Modified:
12 years ago
Reviewers:
bsalomon, reed1
CC:
skia-review_googlegroups.com
Base URL:
http://skia.googlecode.com/svn/trunk
Visibility:
Public.

Description

This CL tries to implement the feature that detects whether a path is a circle and then renders it in a specific shader. Thus it would save us from drawing 8 quads and then we have the performance boost. With the benchmark below: http://themaninblue.com/experiment/AnimationBenchmark/canvas/ I've seen the FPS goes from 60FPS to 100FPS with the introduction of this CL. This implementation takes a top-down approach, i.e. the client of skia has to call 'addCircle' directly. Then the state of whether it's a circle is kept along in path structure. I tried my best to keep the implementation and simple and change the core parts as little as possible. Therefore in this implementation, I cache several fields in SkPath to track whether it's a circle or not. The complex part comes with the transformation of a path, it has to check whether it's still a circle after transformation. At a glance, I don't like the way I add so much helper functions in SkMatrix and touch almost every function in SkPath. So I've always come up with another bottom-up approach. It guesses whether it's a circle or not. Please take a look at this CL: http://codereview.appspot.com/5698072/ Please help me decide which approach is better so that I'm not going too far away on the wrong path. Also please answer some questions below if it's OK: 1. in which circumstances, can the view matrix of draw state have perspective? Is it possible in canvas 2d? I'm not making another specific circle path renderer because I'm suspecting it could have perspectives and thus this special shader can't be used at all. 2. For now, we use 8 quads to approximate one circle. With this rendering technique, I'm reverting it back to a perfectly sized circle. Therefore, for circles with large diameter, the differences between software rendering and this GPU rendering is obvious, some regions along the circle edges don't match any more. Is it acceptable. 3. In this implementation, I'm using smoothstep() in fragment shader to do the anti-aliasing. From my experiment, it's OK, but I'd like to know what's the policy behind rendering quality? How good should we get? BUG= TEST=improve the performance of http://themaninblue.com/experiment/AnimationBenchmark/canvas/ and http://ie.microsoft.com/testdrive/Performance/Fireworks/Default.html a lot.

Patch Set 1 #

Patch Set 2 : don't add fields in SkPath, instead reconstruct and check if it's a circle. #

Patch Set 3 : rebased to new changes #

Patch Set 4 : WIP. use SkCanvas interface #

Patch Set 5 : new update #

Patch Set 6 : add circle benchmark #

Patch Set 7 : rebased onto latest revision 3627 #

Patch Set 8 : fit into WebKit's calling sequences #

Patch Set 9 : minor optimization #

Total comments: 19

Patch Set 10 : updated #

Patch Set 11 : update #

Patch Set 12 : comment and other small fixes #

Patch Set 13 : relax tolerance for fixed build. #

Patch Set 14 : update isSimilarityTransformation's method #

Patch Set 15 : rebased to rev 3754 #

Total comments: 4

Patch Set 16 : one approach (can't handle stroke) #

Patch Set 17 : second approach #

Patch Set 18 : new update #

Patch Set 19 : simplify shader a bit #

Unified diffs Side-by-side diffs Delta from patch set Stats (+173 lines, -4 lines) Patch
M include/gpu/GrContext.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 chunks +17 lines, -0 lines 0 comments Download
M src/gpu/GrContext.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 chunks +133 lines, -0 lines 0 comments Download
M src/gpu/GrDrawState.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +6 lines, -0 lines 0 comments Download
M src/gpu/gl/GrGLProgram.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +17 lines, -4 lines 0 comments Download

Messages

Total messages: 29
guanqun
Please see Description for more info and help me decide which approach is better. this ...
12 years, 2 months ago (2012-02-27 07:30:28 UTC) #1
bsalomon
On 2012/02/27 07:30:28, guanqun wrote: > Please see Description for more info and help me ...
12 years, 2 months ago (2012-02-27 15:12:34 UTC) #2
bsalomon
>1. in which circumstances, can the view matrix of draw state have perspective? >Is it ...
12 years, 2 months ago (2012-02-27 15:27:54 UTC) #3
guanqun
On 2012/02/27 15:12:34, bsalomon wrote: > On 2012/02/27 07:30:28, guanqun wrote: > > Please see ...
12 years, 2 months ago (2012-02-28 01:47:30 UTC) #4
reed1
On 2012/02/28 01:47:30, guanqun wrote: > On 2012/02/27 15:12:34, bsalomon wrote: > > On 2012/02/27 ...
12 years, 2 months ago (2012-02-28 13:18:49 UTC) #5
guanqun
On 2012/02/28 13:18:49, reed1 wrote: > The benefit would be if we can keep circles/ovals/roundrects ...
12 years, 2 months ago (2012-02-29 07:12:33 UTC) #6
guanqun
Hi all, I've tried to use SkCanvas interface to implement this feature, please take a ...
12 years, 2 months ago (2012-03-12 08:55:26 UTC) #7
reed1
Thank you. We have been thinking about a deeper change in this area for a ...
12 years, 2 months ago (2012-03-12 12:44:48 UTC) #8
guanqun
Thanks for your info, I'll close this issue.
12 years, 2 months ago (2012-03-12 14:36:34 UTC) #9
guanqun
Hi Brian, Here's the issue of my circle drawing patch. The latest patch is modelled ...
12 years, 1 month ago (2012-03-29 06:41:17 UTC) #10
bsalomon
On 2012/03/29 06:41:17, guanqun wrote: > Hi Brian, > > Here's the issue of my ...
12 years, 1 month ago (2012-04-03 14:28:12 UTC) #11
guanqun
Hi Brian, Thanks for your detailed comments, I get the idea of how I should ...
12 years, 1 month ago (2012-04-04 13:43:34 UTC) #12
bsalomon
On 2012/04/04 13:43:34, guanqun wrote: > Hi Brian, > > Thanks for your detailed comments, ...
12 years, 1 month ago (2012-04-04 13:48:54 UTC) #13
guanqun
Hi Brian, I'm done with this feature and FYI there are some differences between your ...
12 years, 1 month ago (2012-04-09 12:39:28 UTC) #14
bsalomon
http://codereview.appspot.com/5696086/diff/17018/include/core/SkMatrix.h File include/core/SkMatrix.h (right): http://codereview.appspot.com/5696086/diff/17018/include/core/SkMatrix.h#newcode91 include/core/SkMatrix.h:91: bool hasNoSkewAndPerspective() const; On 2012/04/09 12:39:28, guanqun wrote: > ...
12 years, 1 month ago (2012-04-09 21:17:58 UTC) #15
reed1
Comments on SkPath.[h,cpp] 1. Can we track ovals instead of circles? 2. I think empty ...
12 years, 1 month ago (2012-04-09 21:28:45 UTC) #16
reed1
Comments on SkMatrix: 1. This method is a bit tricky, since it involves tolerances to ...
12 years, 1 month ago (2012-04-09 21:33:39 UTC) #17
guanqun
2. I think empty is not a circle/oval 3. Lets use SkBool8 instead of bool ...
12 years, 1 month ago (2012-04-10 02:30:14 UTC) #18
guanqun
With some testing, I found the method used right now (track whether it's a circle ...
12 years, 1 month ago (2012-04-10 07:16:27 UTC) #19
reed1
Comments on SkPath. 1. For now, can we decide that if we see a non-scale/translate ...
12 years, 1 month ago (2012-04-10 15:51:54 UTC) #20
bsalomon
On 2012/04/10 15:51:54, reed1 wrote: > Comments on SkPath. > > 1. For now, can ...
12 years, 1 month ago (2012-04-10 23:55:02 UTC) #21
guanqun
On 2012/04/10 23:55:02, bsalomon wrote: > On 2012/04/10 15:51:54, reed1 wrote: > > Comments on ...
12 years, 1 month ago (2012-04-12 06:58:35 UTC) #22
guanqun
I've separated this big CL into several smaller ones, the sequence should be: 1. http://codereview.appspot.com/5999050/ ...
12 years, 1 month ago (2012-04-12 07:38:33 UTC) #23
guanqun
Hi, I've rebased this CL to the latest revision. And please review! Are there any ...
12 years ago (2012-04-24 02:36:19 UTC) #24
bsalomon
The thrust of my comments is that GrContext::drawOval should feel like a real API to ...
12 years ago (2012-04-24 14:19:52 UTC) #25
guanqun
Hi Brian, I've come up two approaches to decouple SkGpuDevice::drawOval() and GrContext::drawOval() and tried to ...
12 years ago (2012-04-25 16:05:56 UTC) #26
bsalomon
On 2012/04/25 16:05:56, guanqun wrote: > Hi Brian, > > I've come up two approaches ...
12 years ago (2012-04-25 17:30:23 UTC) #27
guanqun
Updated patch is available, circles in GM can be rendered properly via GPU. However, as ...
12 years ago (2012-04-26 13:13:23 UTC) #28
bsalomon
12 years ago (2012-04-27 13:06:30 UTC) #29
On 2012/04/26 13:13:23, guanqun wrote:
> Updated patch is available, circles in GM can be rendered properly via GPU.
> 
> However, as you mentioned, this implementation can't handle stroke right now,
we
> need to add this feature later...
> 
> Please review.

LGTM, committed as r3772. I made a few very minor edits (comments and changed
GrAssert(!" to GrCrash(")
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b