remove allocs for colorfilters

For a modified bench, that installs colorfilterimagefilters and then draws a colored rect:
before:
  13/13  MB	18	1.66µs	1.67µs	1.67µs	1.73µs	1%	█▂▂▃▄▁▂▁▁▃	8888
after:
  13/13  MB	17	874ns	878ns	882ns	920ns	2%	█▁▂▂▁▂▂▁▁▁	8888


Some observations
- we can sometimes build several rasterpipelines in a single draw
    - filterColor4f (can be called more than once)
    - actual_blit
- imagefilter::affectsTransparentBlack
    - calls through to the colorfilter
    - this in-turn invokes filterColor4f, which makes a pipeline
    + if we had elimnated the imagefilter (for a colorfilter) sooner,
      we would not have called affectsTransparentBlack
    + adding a virtual to colorfilter for affectsTransparentBlack might
      also avoid having to call filterColor4f (at least for filters
      that know how to determine this simply)

For now however, increasing the arena's stack-budget seems to brush over
these other inefficiencies.

More observations
- we decide to use pipeline before we fold-away the colorfilter (w/ no shader)
   - the pipeline later notices this, and becomes just a color draw
   - if we had removed the colorfilter earlier, we would have taken a different
     (legacy, slightly faster) blitter (logically using memset).

Change-Id: I1a63414acbf23967c4d4daed9956bdc4d81148c6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214682
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2019-05-20 09:49:29 -04:00 committed by Skia Commit-Bot
parent 9e6a39356e
commit f93d021680

View File

@ -52,7 +52,9 @@ SkColor SkColorFilter::filterColor(SkColor c) const {
SkColor4f SkColorFilter::filterColor4f(const SkColor4f& c, SkColorSpace* colorSpace) const {
SkPMColor4f dst, src = c.premul();
SkSTArenaAlloc<128> alloc;
// determined experimentally, seems to cover compose+colormatrix
constexpr size_t kEnoughForCommonFilters = 512;
SkSTArenaAlloc<kEnoughForCommonFilters> alloc;
SkRasterPipeline pipeline(&alloc);
pipeline.append_constant_color(&alloc, src.vec());