Commit Graph

6 Commits

Author SHA1 Message Date
Michael Ludwig
f38b711222 Reland "Refactor geometry union capabilities out of GrStyledShape"
This reverts commit af312c9d40.

Reason for revert: improved performance, updated empty point cap behavior
to make chrome happy.

Because of the performance regression in the original CL, this is a bit
more to it than just updating cap behavior. Summary of changes for perf:
1. In asPath(), only call reset() if the type isn't a path or arc.
   Otherwise it was just a wasted realloc of an empty path ref.
2. Rewrote the GrShape::simplify() to not progress through every shape
   type in order, it just jumps to the appropriate type.
3. Have simplify() return whether or not the shape started out closed,
   so we don't have to call GrShape::closed(), which is costly when the
   shape is a path.
4. Expose the GrShape's type enum so GrStyledShape's key writing can use
   switches instead of a giant block of ifs (where path happened to be
   last)

The regressions showed up most heavily on desk_mapsvg and desk_chalkboard
SKPs on the Android skpbench marks. On my system, I was able to
reproduce a similar %-regression from ToT and the original CL on the
chalkboard (but not mapsvg).

Master ranged between 5.1 and 5.3ms, original CL ranged from 5.6-5.8
and after the changes listed above, I got it down to 5.3-5.5. It's not
ideal but I haven't been able to figure out anything more substantial
that it could be. At this point it may just be code layout and/or the
fact that it's now split into two types.


Original change's description:
> Revert "Refactor geometry union capabilities out of GrStyledShape"
>
> This reverts commit 2becdde074.
>
> Reason for revert: likely breaking cc unit test due to empty shape cap change.
>
> Original change's description:
> > Refactor geometry union capabilities out of GrStyledShape
> >
> > The geometry union part of GrStyledShape is now held in GrShape. For the
> > most part, GrShape is entirely style agnostic and focuses on storing
> > the various types of geometry, and destructing them gracefully. It also
> > provides a public API that unifies functionality across all shape types,
> > such as contains() and bounds().
> >
> > GrStyledShape now just owns a GrShape and a GrStyle, and handles the
> > additional simplification logic that relies on knowing the effects of
> > the style on the draw. This is where GrShape makes some allowances for
> > style. Its simplify() function accepts flags that enable/disable various
> > simplification optimizations. Currently these are designed around
> > what is needed to respect path effects and stroking behaviors in
> > GrStyledShape. The main other user of GrShape (the new clip stack) will
> > always provide all flags since it treats every shape as if it were
> > simply filled.
> >
> > Several other related refactorings were taken at the same time:
> > 1. The implementations for asNestedRects, asRRect, etc. were moved out
> >    of the header and into the cpp file for GrStyledShape.
> > 2. GrRenderTargetContext relies on GrStyledShape for its stroke rect
> >    fallbacks.
> > 3. GrShape can hold points, lines, and rects explicitly. This let me
> >    simplify the stroke reasoning.
> >
> > Change-Id: I9fe75613fee51c30b4049b2b5a422daf80a1a86e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284803
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Reviewed-by: Chris Dalton <csmartdalton@google.com>
>
> TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com
>
> Change-Id: I2af5782e072e0ccb4a87f903bb88cbe335b9613f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286039
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

Change-Id: I8c614573582084f2e9ee0d73f93812e0a7c13983
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286396
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-04-30 19:36:43 +00:00
Michael Ludwig
af312c9d40 Revert "Refactor geometry union capabilities out of GrStyledShape"
This reverts commit 2becdde074.

Reason for revert: likely breaking cc unit test due to empty shape cap change.

Original change's description:
> Refactor geometry union capabilities out of GrStyledShape
> 
> The geometry union part of GrStyledShape is now held in GrShape. For the
> most part, GrShape is entirely style agnostic and focuses on storing
> the various types of geometry, and destructing them gracefully. It also
> provides a public API that unifies functionality across all shape types,
> such as contains() and bounds().
> 
> GrStyledShape now just owns a GrShape and a GrStyle, and handles the
> additional simplification logic that relies on knowing the effects of
> the style on the draw. This is where GrShape makes some allowances for
> style. Its simplify() function accepts flags that enable/disable various
> simplification optimizations. Currently these are designed around
> what is needed to respect path effects and stroking behaviors in
> GrStyledShape. The main other user of GrShape (the new clip stack) will
> always provide all flags since it treats every shape as if it were
> simply filled.
> 
> Several other related refactorings were taken at the same time:
> 1. The implementations for asNestedRects, asRRect, etc. were moved out
>    of the header and into the cpp file for GrStyledShape.
> 2. GrRenderTargetContext relies on GrStyledShape for its stroke rect
>    fallbacks.
> 3. GrShape can hold points, lines, and rects explicitly. This let me
>    simplify the stroke reasoning.
> 
> Change-Id: I9fe75613fee51c30b4049b2b5a422daf80a1a86e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284803
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Chris Dalton <csmartdalton@google.com>

TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com

Change-Id: I2af5782e072e0ccb4a87f903bb88cbe335b9613f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286039
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-04-29 13:32:34 +00:00
Michael Ludwig
2becdde074 Refactor geometry union capabilities out of GrStyledShape
The geometry union part of GrStyledShape is now held in GrShape. For the
most part, GrShape is entirely style agnostic and focuses on storing
the various types of geometry, and destructing them gracefully. It also
provides a public API that unifies functionality across all shape types,
such as contains() and bounds().

GrStyledShape now just owns a GrShape and a GrStyle, and handles the
additional simplification logic that relies on knowing the effects of
the style on the draw. This is where GrShape makes some allowances for
style. Its simplify() function accepts flags that enable/disable various
simplification optimizations. Currently these are designed around
what is needed to respect path effects and stroking behaviors in
GrStyledShape. The main other user of GrShape (the new clip stack) will
always provide all flags since it treats every shape as if it were
simply filled.

Several other related refactorings were taken at the same time:
1. The implementations for asNestedRects, asRRect, etc. were moved out
   of the header and into the cpp file for GrStyledShape.
2. GrRenderTargetContext relies on GrStyledShape for its stroke rect
   fallbacks.
3. GrShape can hold points, lines, and rects explicitly. This let me
   simplify the stroke reasoning.

Change-Id: I9fe75613fee51c30b4049b2b5a422daf80a1a86e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284803
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2020-04-28 19:17:08 +00:00
Michael Ludwig
2686d69bf0 Reland "Rename GrShape to GrStyledShape"
This reverts commit 73b86c1ade.

Reason for revert: wasn't the problem, relanding

Original change's description:
> Revert "Rename GrShape to GrStyledShape"
> 
> This reverts commit f3f08af010.
> 
> Reason for revert: maybe this is breaking the ios perf bot; it is the first CL that caused the bot to fail, but I can't really say why this would break them.
> 
> Original change's description:
> > Rename GrShape to GrStyledShape
> > 
> > Change-Id: Ic457e634b4b95356f5615cff3fce1ca7d7677c26
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284036
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> 
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> 
> # Not skipping CQ checks because original CL landed > 1 day ago.
> 
> Change-Id: I2e5adbfc820811fbbde9cb57af28f86a7ba40bd9
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284231
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com

Change-Id: Ifdd52f8bacb5d66a7bf58efd328675c4c443ac8a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284376
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-04-17 20:24:53 +00:00
Michael Ludwig
73b86c1ade Revert "Rename GrShape to GrStyledShape"
This reverts commit f3f08af010.

Reason for revert: maybe this is breaking the ios perf bot; it is the first CL that caused the bot to fail, but I can't really say why this would break them.

Original change's description:
> Rename GrShape to GrStyledShape
> 
> Change-Id: Ic457e634b4b95356f5615cff3fce1ca7d7677c26
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284036
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I2e5adbfc820811fbbde9cb57af28f86a7ba40bd9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284231
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-04-17 19:38:34 +00:00
Michael Ludwig
f3f08af010 Rename GrShape to GrStyledShape
Change-Id: Ic457e634b4b95356f5615cff3fce1ca7d7677c26
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284036
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-04-16 18:05:51 +00:00