Commit Graph

10836 Commits

Author SHA1 Message Date
Mike Reed
e5d9bbfa5b Add alt path dumper that outputs for SkPath::Make()
Change-Id: I85f285c32229d0999d187777436c3875e9884fef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341724
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-08 18:26:12 +00:00
Michael Ludwig
f639a24c50 Consolidate quick reject / paint bounds logic into helper function
Bug: skia:10987
Change-Id: I149bbe33b79848e010c35c94482131fd301f7837
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339992
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-12-08 01:41:50 +00:00
Brian Salomon
b5f880a3f6 Take origin when creating/updating backend texture using pixmaps.
Bug: skia:11042

Change-Id: I511c7556f97f19d7f162031c245019d2da33c129
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341005
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2020-12-07 20:31:10 +00:00
Mike Reed
198e6ea3f9 add new entry-points for drawImage[rect] with samplingoptions
Change-Id: Icc2c2e4affbf4c4dba1983b069351f33487af81b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339116
Reviewed-by: Florin Malita <fmalita@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-07 19:39:30 +00:00
Mike Reed
edb22ec498 work on better SkPath::dump
ForceClose is a pain, and already removed from some
(hopefully all at some point) of our iterators

Follow-on plan: use raw iter, and output code compatible with
SkPath::Make()

Change-Id: Icda4ad2e605eb2fb9842dd35b5e0d4a0939e62eb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341237
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-06 19:47:31 +00:00
Michael Ludwig
f326e4faef Remove SkCanvas::LayerIter used in SkCanvasStateUtils
The LayerIter existed to iterate over the top-most device and any
unclipped layers connected to it. With unclipped layers gone,
SkCanvasStateUtils can just access the top-most device using other
APIs.

Bug: skia:10986
Change-Id: I260ec37fcc8e39d1ec2972a3297521d714649cb5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339991
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
2020-12-05 17:21:53 +00:00
Michael Ludwig
e0dee01043 Remove support for deprecated kDontClipToLayer_SaveLayerFlag
This removes the conditional behavior based on #defines, and the private
flag definitions. It removes GMs and updates tests that tested the
feature. Follow-up CLs will go through and simplify the internals of
SkCanvas to take advantage of this support removal.

Bug: skia:10986
Change-Id: Id42c9e7d134dd06507fabf6577e7872942ef9077
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339988
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-12-05 00:00:13 +00:00
Florin Malita
38921cafe1 Reland "[skottie] Add image sampling and transform options"
This reverts commit b81842aa28.

Reason for revert: reland with fixes

Original change's description:
> Revert "[skottie] Add image sampling and transform options"
>
> This reverts commit 2f24405250.
>
> Reason for revert: broke Win/shared 
>
> Original change's description:
> > [skottie] Add image sampling and transform options
> >
> > Expand the SkImageAsset API to support controlling sampling options and
> > pass an additional transform.
> >
> > Bug: skia:10944, skia:10942
> > Change-Id: I7bad0b2ab58ed40fe4b425de0eb6970a4c7d7117
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340097
> > Commit-Queue: Florin Malita <fmalita@chromium.org>
> > Commit-Queue: Florin Malita <fmalita@google.com>
> > Reviewed-by: Mike Reed <reed@google.com>
>
> TBR=fmalita@chromium.org,fmalita@google.com,reed@google.com,aparchur@google.com
>
> Change-Id: I59d4161356ffdc20588f1bd3beb33c54e44807a2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:10944
> Bug: skia:10942
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340619
> Reviewed-by: Florin Malita <fmalita@google.com>
> Commit-Queue: Florin Malita <fmalita@google.com>

TBR=fmalita@chromium.org,fmalita@google.com,reed@google.com,aparchur@google.com

# Not skipping CQ checks because this is a reland.

Bug: skia:10944
Bug: skia:10942
Change-Id: I91892f4db6366ceb07d1a49a7bc54da17cea5399
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340657
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@google.com>
2020-12-03 19:21:57 +00:00
Mike Reed
1a4140e598 deprecate getTotalMatrix
Change-Id: Iec7d67f4ec3fdf4d5280f3de3d6146a69a60c646
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339995
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-03 17:37:35 +00:00
Florin Malita
b81842aa28 Revert "[skottie] Add image sampling and transform options"
This reverts commit 2f24405250.

Reason for revert: broke Win/shared 

Original change's description:
> [skottie] Add image sampling and transform options
>
> Expand the SkImageAsset API to support controlling sampling options and
> pass an additional transform.
>
> Bug: skia:10944, skia:10942
> Change-Id: I7bad0b2ab58ed40fe4b425de0eb6970a4c7d7117
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340097
> Commit-Queue: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Florin Malita <fmalita@google.com>
> Reviewed-by: Mike Reed <reed@google.com>

TBR=fmalita@chromium.org,fmalita@google.com,reed@google.com,aparchur@google.com

Change-Id: I59d4161356ffdc20588f1bd3beb33c54e44807a2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10944
Bug: skia:10942
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340619
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2020-12-03 17:11:00 +00:00
Florin Malita
2f24405250 [skottie] Add image sampling and transform options
Expand the SkImageAsset API to support controlling sampling options and
pass an additional transform.

Bug: skia:10944, skia:10942
Change-Id: I7bad0b2ab58ed40fe4b425de0eb6970a4c7d7117
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340097
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-12-03 16:17:24 +00:00
Mike Reed
2d8bd15588 get 4x4 initialMatrix in pictureplayback
Bug: skia:11031
Change-Id: Ib502870a43b295ad6932ee95a839128d54963019
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339984
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-03 15:29:18 +00:00
Leon Scroggins III
469d67e7d9 Expose more info in SkCodec::FrameInfo
Bug: b/160984428

Add more fields to SkCodec::FrameInfo, which describes the properties of
an individual frame in an animated image. This allows a client that
wishes to seek to determine frame dependencies so that they can decode
an arbitrary frame, which in turn will allow SkCodec to remove
SkCodec::FrameInfo::fRequiredFrame. Currently, SkCodec seeks through the
stream to determine frame dependencies, but this is unnecessary work
(and storage) for a client that does not want to seek.

These fields also support the proposed APIs in go/animated-ndk.

Move SkCodecAnimation::Blend from SkCodecAnimationPriv (and delete that
file) into SkCodecAnimation.h. Rename its values to be more clear.

Merge common code for populating SkCodec::FrameInfo.

Add a test for a GIF with offsets outside the range of the image. Note
that libwebp rejects such an image.

Update libgifcodec.

Change-Id: Ie27e0531e7d62eaae153eccb3105bf2121b5aac4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339857
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Nigel Tao <nigeltao@google.com>
2020-12-02 22:37:20 +00:00
Mike Klein
bb1933e0d6 simplify SkSamplingOptions field names
SkSamplingOptions has no methods, so there's no need
to use an fPrefix to distinguish its fields from locals.
They'll always be accessed by foo.filter, bar->mipmap, etc.

Change-Id: Ia27ebea26d03eba60036616508731c4d2020462c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340356
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-12-02 22:30:00 +00:00
Mike Klein
dcc8960bc2 make SkSamplingOptions fields const
This lets us trust the invariants that the constructors set up,
like if fUseCubic, then fMipmap == SkMipmapMode::kNone.

Gotta be slightly sneaky and implement operator= ourselves
with placement new.

Change-Id: I043cd56cbf9f1e2fa64ab585268b2799df65c31f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340179
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-12-02 22:15:58 +00:00
Brian Salomon
07bc9a27f5 GPU clear values: just 4 floats
We previously represented these as SkPMColor4f. However, upcoming
changes will add limited support for clearing/drawing to unpremul
dst. Just store the clear values as four floats without assigned
interpretation.

Also, noticed a bug by code inspection: we weren't accounting for
write view swizzle in GrRTC. Fixed and added gm to test.

Bug: skia:11019
Change-Id: I1bce1f6c97a156c0377ebad1b166eb641362b67a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340098
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-12-02 22:04:08 +00:00
Mike Reed
387826f6f6 Remove unused SkRWBuffer
Bug: skia:10980
Change-Id: Ibbb62edcbf5a8c1bc341416aef225cae3cf1a256
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336960
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Thiabaud Engelbrecht <thiabaud@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-12-02 15:29:06 +00:00
Ethan Nicholas
bb9fbe057a Allow SkASSERTF to take zero varargs parameters
Previously, calling SkASSERTF(test, "message") would result in an error
due to a dangling comma in its expansion. Adding '##' instructs the
preprocessor to strip the dangling comma if there are no varargs.

Change-Id: Id5dd27e770cf6cd9dec9cd62808d1821f37c9c65
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339398
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-12-01 17:18:52 +00:00
Ben Wagner
831a5a10f4 Fix DWrite axis design parameters.
DWrite makes up a bunch of axes that don't exist, so non-variable axes
are ignored. However, the actual index of the non-variable axes was not
being updated. Update it.

Bug: skia:10928
Change-Id: Iedce5d0dd58f447821b403c38f033d214b457e9f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338602
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2020-12-01 15:00:33 +00:00
Mike Reed
6affa2c2e3 move SkMipmapBuilder to private
Change-Id: I77f57b175984a5e373fae951a270a883e7e4c5d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339216
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-11-30 20:13:15 +00:00
Robert Phillips
c4fbc8d6cf Stop overflow of windows rects in GrClipStack
Bug: skia:10989
Change-Id: I512ccbd3d95178756ae436f7c67ed53d46105ae7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339165
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-11-30 18:12:24 +00:00
Robert Phillips
ca92424e21 Remove SkBaseDevice::flush (take 2)
Another small step in removing SkCanvas::flush

Change-Id: I6f3bec367e582754b8463b7bfe6a2542436ca829
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335647
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-11-30 14:13:03 +00:00
Mike Reed
420a9ba7b5 Switch to m44 for the rest of canvas virtuals
Guard flag has been added to clients

Change-Id: Ib61a48781f5dbd52279c8f4257ba3e22fb2704e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338596
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-11-25 21:50:37 +00:00
Michael Ludwig
a2c40206c6 Preserve dithering for SkImageFilters::Shader
Migrating chromium code to use SkImageFilters::Shader over
SkPaintImageFilter requires dithering to be preserved for its gradient
fills.

I debated always forcing it to true, but dithering was never turned on
for the turbulence filter and it's not necessary for const color shaders
Given that, I opted to just make it a parameter to the filter factory,
which seems okay since we're unlikely to embed dithering into SkShader
itself, it's a shading-related parameter of SkPaint, and if we migrate
to always dithering, then we can remove it.

Bug: skia:9310
Change-Id: I86f14969e2446f3a84e71e687cb263bcd44cf9d9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338156
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-25 19:41:37 +00:00
Michael Ludwig
51b74afb84 Reland "Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice"
This reverts commit 8636e13c2d.

Reason for revert: recording canvases with really big float bounds could
produce a non-empty integer rect bounds that became empty after mapping
it to (0,0,w,h) for the device. This meant resetForNextPictures logic of
updating QR bounds directly from the input bounds allowed state to become
inconsistent with computeDevClipBounds().

PS1->PS4 shows the 1-liner to just compute bounds from the device. This
means that, for now, we preserve the behavior of setting the QR bounds to
be actually empty. skbug.com/10997 is added to fix the underlying issue
with recorders and excessively large float bounds. If that change landed
first, I'd be able to reland this w/o any modifications, but have decided
that it's better to have all locations that modify fQuickRejectBounds use
the exact same expression.

Original change's description:
> Revert "Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice"
>
> This reverts commit 11a394759a.
>
> Reason for revert: assert during google3 tests.
>
> Original change's description:
> > Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice
> >
> > Change-Id: I56670b4a4159e21eaa1a58a9a3ee439298d5aa8e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335863
> > Reviewed-by: Mike Reed <reed@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com
>
> Change-Id: I7c3a8797460113d9a8ef18d82bbbd64aba2f439c
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338316
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com

# Not skipping CQ checks because this is a reland.

Change-Id: I1b33e128b4fb4e06b8c7a6ee9b9dcc67202674d8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338322
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-11-25 17:29:47 +00:00
Michael Ludwig
8636e13c2d Revert "Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice"
This reverts commit 11a394759a.

Reason for revert: assert during google3 tests.

Original change's description:
> Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice
>
> Change-Id: I56670b4a4159e21eaa1a58a9a3ee439298d5aa8e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335863
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com

Change-Id: I7c3a8797460113d9a8ef18d82bbbd64aba2f439c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338316
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-24 20:13:57 +00:00
Mike Reed
246fcc3895 rely on clients to guard old api
Change-Id: Iaac2e7da034b7fc20d23d44c814485a068f26f1c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337943
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-11-24 17:33:36 +00:00
Michael Ludwig
11a394759a Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice
Change-Id: I56670b4a4159e21eaa1a58a9a3ee439298d5aa8e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335863
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-24 17:00:25 +00:00
Chris Dalton
4c1fb1c27a Return the contour's final point from SkPath::RangeIter in kClose
This point is located at fPoints[-1]. We might as well provide it
since it's free, and the stroke iterators for indirect tessellation
will be able to use it.

Bug: skia:10419
Change-Id: If0161a18a9a5a0f3b118a99d7c090d79d424f9db
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337637
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-11-24 03:24:43 +00:00
Mike Reed
ce0c876ce2 hide legacy scalePixels and makeShader
Change-Id: Idae1e44aa0417adb943fd20112fb4f1fa81167f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337719
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-11-24 00:41:33 +00:00
Mike Klein
cd74dea856 macro hygiene in SkVx.h
These macros are not meant to leak out of the file.

Change-Id: I7e24f65a3053785410c7fac760fd3af46c5c1f1c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337739
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2020-11-23 22:49:33 +00:00
Michael Ludwig
f9334e918f Reland "Simplify layer bounds syncing and no-device error handling in SkCanvas::internalSaveLayer"
This reverts commit 6c1191d749.

Reason for revert:
 - the lowest-level issue is fixed in https://skia-review.googlesource.com/c/skia/+/337076
   which prevents bad replaceClips from going beyond the device bounds
 - but this also updates the original CL so that we don't call
   replaceClip in these problematic situations. The old behavior of
   effectively downgrading a saveLayer to a save when the new device
   fails to allocate is better behavior.
 - now the bounds tracking is still consolidated as before, but only
   applied when the kNoLayer_Strategy is used, or the layer should be
   empty (in which case replaceClip() is passed an empty rect and
   everything works out).

 - when the layer fails to allocate, we add a clipRegion to restrict
   nested draw calls to what would have been the layers bounds, while
   still respecting the old clip (that normally would have been applied
   on the layer restore, but won't because there's no layer). This is
   somewhat pedantic, and is probably a rare case in the wild, but it
   makes some of our SkCanvas tests easier to deal with.
 - This is because, if you just make an SkCanvas(width, height) directly
   you get an SkNoPixelsDevice but also use the kFullLayer_Strategy.
   SkNoPixelsDevice always fails to create a layer (since it's meant to
   be used with subclasses of SkCanvas that return kNoLayer_Strategy,
   like SkNoDrawCanvas).
 - applying the failed layer bounds as a clip keeps the canvas' reported
   bounds as accurate as possible in this case.
     - in the future, it may be worth updating how SkCanvas can be
       constructed to avoid this, and overhauling the unit tests but
       I didn't want to further delay these changes.

 - it's important that replaceClip() is still used for the kNoLayer case
   because it allows image-filtered layers to expand the clip bounds
   until the restore. This keeps any virtual canvas or recording canvas
   completely in-sync with the base canvas or eventual real canvas that
   is backed by a device that actually draws.

Original change's description:
> Revert "Simplify layer bounds syncing and no-device error handling in SkCanvas::internalSaveLayer"
>
> This reverts commit b27ba538ec.
>
> Reason for revert: causes invalid memory accesses due to replaceClip use, and replaceClip() is probably not the right operation to use
> to emulate a layer when no layer was the strategy or failed to allocate.
>
> Original change's description:
> > Simplify layer bounds syncing and no-device error handling in SkCanvas::internalSaveLayer
> >
> > This corrects some subtle bugs that can occur with recording canvas or
> > if a device fails to be created for a new layer, where the stashed
> > matrix would not be restored properly. Since no new DeviceCM would get
> > added in those cases, the canvas' total matrix wouldn't get fixed in the
> > paired onRestore() and it would remain dirty for the remainder of the
> > canvas's lifetime.
> >
> > After this change, the underlying SkDevice's bounds are also kept in
> > sync with the intent of the saveLayer when kNoLayer_Strategy is used.
> > Previously, the bounds would be applied to the canvas' conservative clip
> > and quick reject bounds, but the device would remain un-updated. As we
> > move towards SkNoPixelsDevice taking over the conservative clip bounds,
> > this ensures bounds remain up to date within a saveLayer/restore pair
> > even if no layer was allocated.
> >
> > Change-Id: I5ca389bdd624ea7278106da863a96e9d8f90e2d1
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335861
> > Reviewed-by: Mike Reed <reed@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com
>
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:1151195, chromium:1151270, chromium:1151294, chromium:1151320, chromium:1151322
> Change-Id: I9db07916ffc450cc6ecc9188d72bb7c35770a974
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337117
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com

# Not skipping CQ checks because this is a reland.

Change-Id: Idcab9084c7f19d8f31b11231fd9b52292fc397a3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337157
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-23 19:49:03 +00:00
Mike Reed
ee9c4c71f6 remove legacy SkFilterOptions
Prerequisite:
https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/native/+/13103845

Change-Id: Ic89937b2fffa2e81b5e38ac7082134bc0a90c4de
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337399
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-11-23 17:42:21 +00:00
Mike Reed
a03f8bf837 other ways to organize samplingoptions?
do not land

Change-Id: I5fa7b2a0d1eb7e893d9b333f850a2f515d7ce065
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336956
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-11-21 02:00:26 +00:00
Robert Phillips
10089c6a42 Revert "Remove legacy SkImage::MakeFromYUVATextures."
This reverts commit df29db4c41.

Reason for revert: blocking the G3 roll

Original change's description:
> Remove legacy SkImage::MakeFromYUVATextures.
>
> Bug: skia:10632
> Change-Id: Iad8989e0ae5aa6921e8e2e27ba375221f2af0262
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336959
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Auto-Submit: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

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

Change-Id: Id77c1679a96ad9c1be93e6e29449cc4785a3983b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10632
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337183
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-11-20 21:51:40 +00:00
Michael Ludwig
6c1191d749 Revert "Simplify layer bounds syncing and no-device error handling in SkCanvas::internalSaveLayer"
This reverts commit b27ba538ec.

Reason for revert: causes invalid memory accesses due to replaceClip use, and replaceClip() is probably not the right operation to use
to emulate a layer when no layer was the strategy or failed to allocate.

Original change's description:
> Simplify layer bounds syncing and no-device error handling in SkCanvas::internalSaveLayer
>
> This corrects some subtle bugs that can occur with recording canvas or
> if a device fails to be created for a new layer, where the stashed
> matrix would not be restored properly. Since no new DeviceCM would get
> added in those cases, the canvas' total matrix wouldn't get fixed in the
> paired onRestore() and it would remain dirty for the remainder of the
> canvas's lifetime.
>
> After this change, the underlying SkDevice's bounds are also kept in
> sync with the intent of the saveLayer when kNoLayer_Strategy is used.
> Previously, the bounds would be applied to the canvas' conservative clip
> and quick reject bounds, but the device would remain un-updated. As we
> move towards SkNoPixelsDevice taking over the conservative clip bounds,
> this ensures bounds remain up to date within a saveLayer/restore pair
> even if no layer was allocated.
>
> Change-Id: I5ca389bdd624ea7278106da863a96e9d8f90e2d1
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335861
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1151195, chromium:1151270, chromium:1151294, chromium:1151320, chromium:1151322
Change-Id: I9db07916ffc450cc6ecc9188d72bb7c35770a974
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337117
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-20 17:10:58 +00:00
Brian Salomon
df29db4c41 Remove legacy SkImage::MakeFromYUVATextures.
Bug: skia:10632
Change-Id: Iad8989e0ae5aa6921e8e2e27ba375221f2af0262
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336959
Commit-Queue: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-11-20 16:48:16 +00:00
Michael Ludwig
b27ba538ec Simplify layer bounds syncing and no-device error handling in SkCanvas::internalSaveLayer
This corrects some subtle bugs that can occur with recording canvas or
if a device fails to be created for a new layer, where the stashed
matrix would not be restored properly. Since no new DeviceCM would get
added in those cases, the canvas' total matrix wouldn't get fixed in the
paired onRestore() and it would remain dirty for the remainder of the
canvas's lifetime.

After this change, the underlying SkDevice's bounds are also kept in
sync with the intent of the saveLayer when kNoLayer_Strategy is used.
Previously, the bounds would be applied to the canvas' conservative clip
and quick reject bounds, but the device would remain un-updated. As we
move towards SkNoPixelsDevice taking over the conservative clip bounds,
this ensures bounds remain up to date within a saveLayer/restore pair
even if no layer was allocated.

Change-Id: I5ca389bdd624ea7278106da863a96e9d8f90e2d1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335861
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-19 21:24:40 +00:00
Jim Van Verth
9e64047a04 Add MTLBinaryArchive support to iOS Metal build
Change-Id: I7a4f58e4fc1fc18c42de372dd480e0681000e2f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333758
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Chinmay Garde <chinmaygarde@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
2020-11-19 20:00:30 +00:00
Michael Ludwig
466e7e88d3 Hide SkCanvas::AutoValidateClip in cpp file
Bug: skia:9283
Change-Id: I1f808ec9d004f228b17a139dff7a2f44676baf50
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335856
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-11-18 20:56:15 +00:00
Michael Ludwig
5013d957f3 Rename fDeviceClipBounds to fQuickRejectBounds
This better differentiates it from device clip bounds, and the fact that
the stored bounds have been outset by 1 to account for AA, and are only
used for quick reject purposes.

Bug: skia:9283
Change-Id: I47420f23b74e47626596f978c78f01d7d97ae808
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335828
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-11-18 20:37:55 +00:00
Brian Salomon
94584f4574 Remove unused macros from GrGLConfig.h, GrGLConfig_chrome.h, and scripts
Change-Id: I5a9e7d490fd71f326ac37a72eb942fc64f557733
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335666
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-11-18 20:23:35 +00:00
Herb Derby
90f211f46b calculate glyph offset using (0,0) mapping
This code has rotted a bit. The glyph off set is now calculated
by mapping (0,0) through the current matrix, and the initial
matrix, and taking the vector difference. Residual is no longer
needed and all the plumbing can be removed.

Change-Id: I20b56afc6749fd26fe283a7ff22f38951da0e6f5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335823
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2020-11-18 17:18:45 +00:00
Brian Salomon
fcc4e85f3c Remove SkYUVAInfo::PlanarConfig
Bug: skia:10632
Change-Id: I72b4379c82fd7dc4c7169387014f8fffbb86e23f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334161
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2020-11-18 14:26:14 +00:00
Brian Salomon
98e17bf01a Remove deprecated DDL promise texture image factories.
Bug: skia:10632
Change-Id: I218281256ea5ab4a5a5a7ea7bf209350082f8dc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335038
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-11-17 17:28:23 +00:00
Ben Wagner
c634fc4a66 Remove FCLocker::Suspend.
It's a bad idea, difficult to reason about, and may be causing
deadlocks.

Change-Id: Id9749661f4f3f942ee983e9c1fdab2bd7f287edb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335242
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2020-11-17 17:11:03 +00:00
Leon Scroggins
da3d8c2471 Reland "SkAnimatedImage: Use fSampleSize"
This is a reland of 4fdf9f9ce5

No change from the original, which was just reverted to be able to
cleanly revert its parent, which has now been relanded with a fix.

Original change's description:
> SkAnimatedImage: Use fSampleSize
>
> Bug: b/163595585
>
> This will allow using less memory when decoding an animated GIF by
> sampling at decode time. This is tested by the animated_image GMs.
>
> Change-Id: I748b2180827623e4ca1fc0fd4d6dd02733b3b5f2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333226
> Commit-Queue: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Derek Sollenberger <djsollen@google.com>

Bug: b/163595585
Change-Id: I3249bd04b64750a50a4c5c787db3e80ac4d85e67
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335279
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-11-17 14:07:03 +00:00
Robert Phillips
b7c1310834 Revert "Remove SkBaseDevice::flush"
This reverts commit 971b19d0c6.

Reason for revert: See if this CL was causing the Perf-Win10-Clang-ShuttleA-GPU-GTX660-x86_64-Release-All issue

Original change's description:
> Remove SkBaseDevice::flush
>
> Another small step in removing SkCanvas::flush
>
> Change-Id: I6f17edcd1996e1009dad7cc96a97be3b0c4664f4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334417
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Adlai Holler <adlai@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,adlai@google.com

Change-Id: I0b9116f8ce4eed3a0d49ccf1cc55d8d89675617e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335216
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-11-16 18:46:19 +00:00
Leon Scroggins
1340dbde91 Reland "SkAndroidCodec: Support decoding all frames"
This is a reland of fc4fdc5b25

Original change's description:
> SkAndroidCodec: Support decoding all frames
>
> Bug: b/160984428
> Bug: b/163595585
>
> Add support to SkAndroidCodec for decoding all frames with an
> fSampleSize, so that an entire animation can be decoded to a smaller
> size.
>
> dm/:
> - Test scaled + animated decodes
>
> SkAndroidCodec:
> - Make AndroidOptions inherit from SkCodec::Options. This allows
>   SkAndroidCodec to use fFrameIndex. (It also combines the two versions
>   of fSubset, which is now const for both.)
> - Respect fFrameIndex, and call SkCodec::handleFrameIndex to decode
>   the required frame.
> - Disallow decoding with kRespect + fFrameIndex > 0 if there is a
>   non-default orientation. As currently written (except without
>   disabling this combination), SkPixmapPriv::Orient would draw the new
>   portion of the frame on top of uninitialized pixels, instead of the
>   prior frame. This could be fixed by
>   - If SkAndroidCodec needs to decode the required frame, it could do so
>     without applying the orientation, then decode fFrameIndex, and then
>     apply the orientation.
>   - If the client provided the required frame, SkAndroidCodec would need
>     to un-apply the orientation to get the proper starting state, then
>     decode and apply.
>   I think it is simpler to force the client to handle the orientation
>   externally.
>
> SkCodec:
> - Allow SkAndroidCodec to call its private method handleFrameIndex. This
>   method handles decoding a required frame, if necessary. When called by
>   SkAndroidCodec, it now uses the SkAndroidCodec to check for/decode the
>   required frame, so that it will scale properly.
> - Call rewindIfNeeded inside handleFrameIndex. handleFrameIndex calls a
>   virtual method which may set some state (e.g. in SkJpegCodec). Without
>   this change, that state would be reset by rewindIfNeeded.
> - Simplify handling a kRestoreBGColor frame. Whether provided or not,
>   take the same path to calling zero_rect.
> - Updates to zero_rect:
>   - Intersect after scaling, which will also check for empty.
>   - Round out instead of in - this ensures we don't under-erase
>   - Use kFill_ScaleToFit, which better matches the intent.
>
> Change-Id: Ibe1951980a0dca8f5b7b1f20192432d395681683
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333225
> Commit-Queue: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Derek Sollenberger <djsollen@google.com>

Bug: b/160984428
Bug: b/163595585
Change-Id: I7c1e79e0f92c75b4840eef65c8fc2b8497189e81
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334842
Auto-Submit: Leon Scroggins <scroggo@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
2020-11-16 16:55:48 +00:00
Robert Phillips
971b19d0c6 Remove SkBaseDevice::flush
Another small step in removing SkCanvas::flush

Change-Id: I6f17edcd1996e1009dad7cc96a97be3b0c4664f4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334417
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-11-16 15:26:06 +00:00
Brian Salomon
9f94f31cc0 Add convenience method SkYUVAInfo::makeSubsampling.
Will be used Chrome to convert subsampled info to k444.

Bug: skia:10632
Change-Id: Ife9bdf3a28aeb6db1de063539a8b1664bdcbdb5e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334958
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
2020-11-16 14:28:34 +00:00
Michael Ludwig
4757a60871 Accept SkFilterQuality in SkImageFilters::Shader
This is needed to help ease the migration from SkImageFilters::Paint,
until image shaders always force you to embed sampling options.

Change-Id: Id8dc8c3196a7935073677a5fbb8d35c3bd22f9ba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333757
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-13 22:46:20 +00:00
Mike Reed
cae335d5b1 Add temporary Make for SkSamplingOptions
To help stage clients away from SkFilterQuality

Change-Id: Icf9d192880caa16a82f9774cc99c97e096f8e678
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334162
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-11-13 20:12:53 +00:00
Brian Salomon
a29ed26cfc Remove unused copy-to-external YUV SkImage factories.
Also inline some helper functions into newer factory method
that are no longer shared.

Bug: skia:10632
Change-Id: I466c59f668d882802087acad1ec1f229505a3377
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334596
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-11-13 19:24:15 +00:00
Leon Scroggins III
267a8589d3 Revert "SkAndroidCodec: Support decoding all frames"
This reverts commit fc4fdc5b25.

Reason for revert: Google3 and ASAN failures

Change-Id: I890cd76109c0375391637f879550837d01e650f9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334840
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-11-13 16:20:39 +00:00
Leon Scroggins
efd628a1a9 Revert "SkAnimatedImage: Use fSampleSize"
This reverts commit 4fdf9f9ce5.

Reason for revert: Google3 and ASAN failures caused by the prior
change, which this depends on.

Original change's description:
> SkAnimatedImage: Use fSampleSize
>
> Bug: b/163595585
>
> This will allow using less memory when decoding an animated GIF by
> sampling at decode time. This is tested by the animated_image GMs.
>
> Change-Id: I748b2180827623e4ca1fc0fd4d6dd02733b3b5f2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333226
> Commit-Queue: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Derek Sollenberger <djsollen@google.com>

TBR=djsollen@google.com,scroggo@google.com

Change-Id: I0d30ada4eba2302ce0c5f85b1174d0618ae0f589
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b/163595585
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334839
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2020-11-13 15:28:00 +00:00
Leon Scroggins
4fdf9f9ce5 SkAnimatedImage: Use fSampleSize
Bug: b/163595585

This will allow using less memory when decoding an animated GIF by
sampling at decode time. This is tested by the animated_image GMs.

Change-Id: I748b2180827623e4ca1fc0fd4d6dd02733b3b5f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333226
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
2020-11-12 22:30:51 +00:00
Leon Scroggins
fc4fdc5b25 SkAndroidCodec: Support decoding all frames
Bug: b/160984428
Bug: b/163595585

Add support to SkAndroidCodec for decoding all frames with an
fSampleSize, so that an entire animation can be decoded to a smaller
size.

dm/:
- Test scaled + animated decodes

SkAndroidCodec:
- Make AndroidOptions inherit from SkCodec::Options. This allows
  SkAndroidCodec to use fFrameIndex. (It also combines the two versions
  of fSubset, which is now const for both.)
- Respect fFrameIndex, and call SkCodec::handleFrameIndex to decode
  the required frame.
- Disallow decoding with kRespect + fFrameIndex > 0 if there is a
  non-default orientation. As currently written (except without
  disabling this combination), SkPixmapPriv::Orient would draw the new
  portion of the frame on top of uninitialized pixels, instead of the
  prior frame. This could be fixed by
  - If SkAndroidCodec needs to decode the required frame, it could do so
    without applying the orientation, then decode fFrameIndex, and then
    apply the orientation.
  - If the client provided the required frame, SkAndroidCodec would need
    to un-apply the orientation to get the proper starting state, then
    decode and apply.
  I think it is simpler to force the client to handle the orientation
  externally.

SkCodec:
- Allow SkAndroidCodec to call its private method handleFrameIndex. This
  method handles decoding a required frame, if necessary. When called by
  SkAndroidCodec, it now uses the SkAndroidCodec to check for/decode the
  required frame, so that it will scale properly.
- Call rewindIfNeeded inside handleFrameIndex. handleFrameIndex calls a
  virtual method which may set some state (e.g. in SkJpegCodec). Without
  this change, that state would be reset by rewindIfNeeded.
- Simplify handling a kRestoreBGColor frame. Whether provided or not,
  take the same path to calling zero_rect.
- Updates to zero_rect:
  - Intersect after scaling, which will also check for empty.
  - Round out instead of in - this ensures we don't under-erase
  - Use kFill_ScaleToFit, which better matches the intent.

Change-Id: Ibe1951980a0dca8f5b7b1f20192432d395681683
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333225
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
2020-11-12 21:31:41 +00:00
Jim Van Verth
351c9b53d6 Switch to using GrMtlBackendContext for GrDirectContext creation.
Makes the Metal backend more consistent with the other backends,
and allows new init parameters to be added without significantly
changing API.

Added updated sk_cf_obj because I needed some of its functionality.

Bug: skia:10804
Change-Id: I6f1dd1c03ddc4c4b702ea75eff14bc0f98ab5ad2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334426
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-11-12 21:03:51 +00:00
Leon Scroggins
7d1153fc4c Handle EXIF orientation in SkAnimatedImage
Bug: skia:10914
Bug: b/163595585

In a WebP image, it is possible to combine animation with an EXIF
orientation. While SkAndroidCodec attempts to handle orientation itself
by decoding into temporary memory and then drawing through a matrix,
this doesn't work directly when compositing a P-frame into a prior
frame. SkAnimatedImage already uses an SkMatrix to handle cropping and
scaling, so update that matrix to include the orientation.

Make SkAnimatedImage a friend of SkAndroidCodec. This allows the former
to have the same ExifOrientationBehavior specified by the latter, and to
recreate the latter so it does not try to handle the orientation itself.

Clip SkAnimatedImage to its bounds. Android's AnimatedImageDrawable
performs its own clip, but this makes a crop rect work for other
clients.

Update getCurrentFrame to take cropping, scaling, and orientation into
account. This method is used by CanvasKit, which does not use cropping
or scaling, but will now properly orient an animation with an EXIF
orientation.

Add a GM that exercises the various combinations of ways SkAnimatedImage
can be used:
- via newPictureSnapshot (as in Android) versus getCurrentFrame
- scaling down to a dimension that can be output from the
  SkAndroidCodec, versus up, which SkAnimatedImage scales
- with a crop rect
- with a post processor

Change-Id: If1854e9aea23fc4afddf75d39132b38e3fbc6071
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333223
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
2020-11-12 19:47:59 +00:00
Heather Miller
c6e3881888 Update Skia milestone to 89
Change-Id: I9de827fe1902a9a91898fcf70d82153a821500ee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334418
Reviewed-by: Heather Miller <hcm@google.com>
Commit-Queue: Heather Miller <hcm@google.com>
2020-11-12 16:50:19 +00:00
Leon Scroggins
bc098ef6d4 Handle EXIF orientation in SkAnimCodecPlayer
Bug: skia:10914

SkAnimCodecPlayer:
- Properly handle orientation, whether the image is still or not
- Mark const methods as const
- Fix seek() so that if you seek to the duration of frame 0, it will
  show frame 1
- Fix the SkImageInfo so if the first frame is opaque, but following
  frames are not, those frames can still be decoded

resources:
- Rename "webp-animated.webp" to "stoplight.webp", which better
  describes the animation
  - Update test files accordingly
- Add "stoplight_h.webp", which is the same animation with an EXIF
  that converts it to a horizontal stoplight

AnimCodecPlayer test:
- Test the new image files
- Verify SkAnimCodecPlayer::dimensions behaves as expected
- Remove extra debugging line
- Provide better error messages

AnimCodecPlayerExifGM:
- Add a new GM that shows all frames of the new animation with an EXIF
  orientation
- Add a new GM that shows all frames of an animation with an opaque
  first frame followed by frames with alpha

Change-Id: I43cf91c16d52aa1901eef8e13e1e644eea6058b3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332753
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-11-12 14:43:47 +00:00
Brian Salomon
e4387382c2 Split SkYUVAInfo::PlanarConfig into PlaneConfig and Subsampling enums
Sometimes it's helpful to think about subsampling separately from
how the channels are spread across planes.

Bug: skia:10632
Change-Id: Ib03f71195f9706ef6def418b1f2125c29e0cf738
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334102
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-11-11 22:42:36 +00:00
Leon Scroggins
70eba23828 Remove SkAnimatedImage::dimensions
The only caller is CanvasKit, and SkAnimatedImage already has getBounds
(from SkDrawable) which does the same thing, except it returns
SkScalars. It also takes scaling and cropping into account, which
CanvasKit does not use, and in a future commit, it will consider
orientation. Switch CanvasKit to use getBounds.

Change-Id: Ia956f91d241641aec450f3aba99583e95a3ff386
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333222
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-11-11 21:48:15 +00:00
Leon Scroggins
398fbed736 Remove unused SkAnimatedImage factory
This version was used before we added the version with an SkImageInfo
parameter to handle the SkColorSpace. That version supports all use
cases supported by this old one.

Change-Id: I966cfc83ac34d4951283eaf9e81febb032f461cf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333221
Commit-Queue: Leon Scroggins <scroggo@google.com>
Auto-Submit: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
2020-11-11 21:29:05 +00:00
Ben Wagner
dfe8cbcf8f Update SkFont::measureText documentation.
The documentation implied that the paint would affect the advance
widths, but this has never been done. Instead document which parts of
the paint affect the bounds.

Change-Id: I48376f08e8a6a47b7ea949c53523b47bb66b4aa4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334052
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2020-11-11 17:15:35 +00:00
John Stiles
f7c9ccfb1f Avoid over-allocation in SkTArray assignment and reserve_back.
Previously, `checkRealloc` would always size up the requested buffer to
allow for 50% extra growth. In some cases (e.g. repeated push_back),
this is a clear win for performance. In other cases (e.g. assigning one
array to another, reserve_back), this extra padding is typically
unwanted and goes against most caller's expectations.

Change-Id: I2d2b5cf81268026822dc5ea08396771bbf06b25a
Bug: skia:10930
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333797
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-11-11 17:09:15 +00:00
Brian Salomon
bd3792de72 Add SkYUVAInfo-based promise texture image factory
Bug: skia:10632
Change-Id: I6a31f2d712f704850ba5246208dc8a4a6e6916eb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333519
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-11-11 14:38:55 +00:00
Michael Ludwig
1fe2b80dc7 Revert "Reland "Draw image filters directly under non-axis-aligned transforms""
This reverts commit 7712db9c24.

Reason for revert: blink unittests and maybe vulkan+skiarenderer masks appear broken. The blink unittests had actually failed with original CL, but was missed because of focus on Android. Not sure what's going on yet.

Original change's description:
> Reland "Draw image filters directly under non-axis-aligned transforms"
>
> This reverts commit 6cafdc069b.
>
> Reason for revert: Fixes unit test failure in Android
>
> In the original version, this internalSaveLayer() returned early if the
> strategy was kNoLayer. This diverged from the old code that updated the
> canvas' clip bounds and then returned before making the layer. A comment
> had suggested this was maybe okay to switch to this early out, but it
> turns out that's not the case.
>
> In Android's unit tests, it queries the clip bounds on a recording canvas
> which always uses a no-layer strategy. However, we do need to set the
> clip bounds of these types of canvas' (or virtual wrappers of a real
> canvas) so that they stay consistent with a real canvas.
>
> The unit tests had two failures, first the bounds and second a color
> mismatch after reading back. However, the bounds test was an ASSERT_EQ
> inside an SkDrawable function. ASSERT_EQ aborts the current function, so
> it never ran the drawRect that sets the color to green. The later
> readback is outside the drawable function, so that test still happened
> and failed. The only real issue to fix is the clip bounds tracking; once
> that unit test succeeds, the color readback will work properly.
>
> Original change's description:
> > Revert "Draw image filters directly under non-axis-aligned transforms"
> >
> > This reverts commit f8f23b2030.
> >
> > Reason for revert: b/172617382 is creating issues for Android's Webview
> >
> > Original change's description:
> > > Draw image filters directly under non-axis-aligned transforms
> > >
> > > This removes hacking the canvas CTM and wrapping the paint's image
> > > filter in a special MatrixTransform that computed a post-transform
> > > instead of its documented pre-transform effect. Performance-wise, the
> > > computed layer sizes should be about the same, but we avoid one less
> > > render target switch because we apply the transformation while drawing
> > > to the dst device, vs. transforming into another temporary layer and
> > > then drawing that to the dst device.
> > >
> > > Several important changes in behavior here:
> > > 1. The DeviceCM record no longer has a stashed matrix to restore and
> > >    holds its restoration paint directly.
> > > 2. Devices for image filter inputs can now have device-to-global
> > >    transforms that are not integer translates.
> > > 3. The MatrixTransform hack punted when there was perspective because it
> > >    could produce excessively large temporary images, but the new version
> > >    appears to work around that. We now impose a maximum layer size to
> > >    protect against that and automatically scale the layer to prevent it.
> > >    Perspective image filters otherwise now draw correctly.
> > > 6. Updated layer sizing code to use the new image filter APIs
> > > 7. Updated backdrop filter and restore filters to go through the same
> > >    code paths, although restore filters skip the intermediate image
> > >    transform.
> > >     - layer bounds and transforms now go through the updated skif API
> > >       and is hopefully more straight forward to understand.
> > > 8. Now we can optimize root color filter nodes of a filter DAG, even if
> > >    the entire DAG can't be represented as a color filter. The last node
> > >    is pulled off and composed with the restoration paint instead.
> > >
> > > Bug: skia:9074,skia:9283
> > > Change-Id: I1fa1d50135b9d6d453b02f89aa3cc3b54deab678
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328376
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
> >
> > Change-Id: I098d0e4b8ee067b436400eb9fea047e629544eec
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:9074
> > Bug: skia:9283
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332737
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Derek Sollenberger <djsollen@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: skia:9074
> Bug: skia:9283
> Change-Id: Ifd5fed708d05a64ddccbd096fbf29896a44ef9f5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333123
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com

Change-Id: I7758641e0279ab5af44794d70cd381bc0a69f956
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9074
Bug: skia:9283
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333756
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-10 21:26:17 +00:00
Michael Ludwig
7712db9c24 Reland "Draw image filters directly under non-axis-aligned transforms"
This reverts commit 6cafdc069b.

Reason for revert: Fixes unit test failure in Android

In the original version, this internalSaveLayer() returned early if the
strategy was kNoLayer. This diverged from the old code that updated the
canvas' clip bounds and then returned before making the layer. A comment
had suggested this was maybe okay to switch to this early out, but it
turns out that's not the case.

In Android's unit tests, it queries the clip bounds on a recording canvas
which always uses a no-layer strategy. However, we do need to set the
clip bounds of these types of canvas' (or virtual wrappers of a real
canvas) so that they stay consistent with a real canvas.

The unit tests had two failures, first the bounds and second a color
mismatch after reading back. However, the bounds test was an ASSERT_EQ
inside an SkDrawable function. ASSERT_EQ aborts the current function, so
it never ran the drawRect that sets the color to green. The later
readback is outside the drawable function, so that test still happened
and failed. The only real issue to fix is the clip bounds tracking; once
that unit test succeeds, the color readback will work properly.

Original change's description:
> Revert "Draw image filters directly under non-axis-aligned transforms"
>
> This reverts commit f8f23b2030.
>
> Reason for revert: b/172617382 is creating issues for Android's Webview
>
> Original change's description:
> > Draw image filters directly under non-axis-aligned transforms
> >
> > This removes hacking the canvas CTM and wrapping the paint's image
> > filter in a special MatrixTransform that computed a post-transform
> > instead of its documented pre-transform effect. Performance-wise, the
> > computed layer sizes should be about the same, but we avoid one less
> > render target switch because we apply the transformation while drawing
> > to the dst device, vs. transforming into another temporary layer and
> > then drawing that to the dst device.
> >
> > Several important changes in behavior here:
> > 1. The DeviceCM record no longer has a stashed matrix to restore and
> >    holds its restoration paint directly.
> > 2. Devices for image filter inputs can now have device-to-global
> >    transforms that are not integer translates.
> > 3. The MatrixTransform hack punted when there was perspective because it
> >    could produce excessively large temporary images, but the new version
> >    appears to work around that. We now impose a maximum layer size to
> >    protect against that and automatically scale the layer to prevent it.
> >    Perspective image filters otherwise now draw correctly.
> > 6. Updated layer sizing code to use the new image filter APIs
> > 7. Updated backdrop filter and restore filters to go through the same
> >    code paths, although restore filters skip the intermediate image
> >    transform.
> >     - layer bounds and transforms now go through the updated skif API
> >       and is hopefully more straight forward to understand.
> > 8. Now we can optimize root color filter nodes of a filter DAG, even if
> >    the entire DAG can't be represented as a color filter. The last node
> >    is pulled off and composed with the restoration paint instead.
> >
> > Bug: skia:9074,skia:9283
> > Change-Id: I1fa1d50135b9d6d453b02f89aa3cc3b54deab678
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328376
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
>
> Change-Id: I098d0e4b8ee067b436400eb9fea047e629544eec
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:9074
> Bug: skia:9283
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332737
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com

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

Bug: skia:9074
Bug: skia:9283
Change-Id: Ifd5fed708d05a64ddccbd096fbf29896a44ef9f5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333123
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-10 19:04:39 +00:00
Robert Phillips
0c0884991d Update DDL testing harness to support drawing DDL w/ integer offsets
This isn't hooked up anywhere but breaks up the omnibus CL.

Change-Id: I15c200e57450e7cc8ee95a3f7969926d0eb8487f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333129
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-11-10 14:34:46 +00:00
Brian Salomon
f143274cda Simplify promise image callbacks.
Remove done and release distinction. Chrome is not using either as
it tracks texture access using other synchronization mechanisms
(semaphores, flush finish procs). Now there is just fulfill and release
where release is called when the texture can be deleted. Also,
release proc can be null.

Simplify texture idle mechanism as the "flushed" state was only used to
implement the old idea of a release proc. The "finished" idle state is
still used to implement the new release proc. Though, it could also be
removed if GrTexture were to be removed for textures returned by fulfill.

Not directly tied to this bug, but a new YUVA factory will be required
and it's good to clean things up first to avoid adding another
instance of the current complexity.

Bug: skia:10632

Change-Id: I4fe3c0af3f5a591506b1b3c736fd3284a38465a6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331836
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-11-10 02:47:56 +00:00
Mike Klein
c6acdab422 refactor Sk[S]TArray methods
Lots of this stuff can be delegated to each other,
cutting the protected SkTArray constructors to two.

Change-Id: Ie35b7a5ceb0ffef5a9548afccc546e076bd668cc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333256
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-11-09 22:28:48 +00:00
Mike Klein
339f0ee2a6 align SkAlignedSTStorage<N,T> to T
This decreases alignment for things like float
and increases alignment for things like __m128.

The other users of SkAlignedSStorage looked simple enough to port to
aligned char[].  I haven't changed either of their alignments---still
the old max(void*,double)---but we can now if we want.

All that together lets us delete SkAlignedSStorage.

Change-Id: I6b5957a26f42ad859de383054573fb58d5cd0576
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333196
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-11-09 19:51:55 +00:00
Mike Klein
46f11c2aab init SkSTArray storage before passing to SkTArray
Using private inheritance is similar to having a class member,
except it's initialized before the next base class, SkTArray.
This lets us pass it to SkTArray's constructors.

I think we can make related changes (updating the various SkAlignedFoo,
not using them here, or not using them anywhere) independently.

... storage constructors made explicit at suggestion of GCC's -Wextra.
... now with explicit static_cast<STORAGE*>(this)

Change-Id: I665cf840e111da68f039416c9649ce328cc308d6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333146
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-09 18:13:57 +00:00
Adlai Holler
d7b59c091d Have DDLs honor the reduceOpsTaskSplittingFlag
Especially while I'm fiddling with the implementation, we don't
want the user to be surprised when using DDLs also triggers
this other codepath.

Bug: skia:10877
Change-Id: I660ea08189fff45acd7a45df12e15c45f607758a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332720
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
2020-11-06 20:20:44 +00:00
Herb Derby
e886b8e8b1 move concrete subruns to .cpp
In addition, place all the subruns, and helpers in
an anonymous namespace. Add helper has_some_antialiasing.

Change-Id: Iee7dc24f7e568e2bace03ee00c1c98dbf3050634
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332744
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2020-11-06 19:49:14 +00:00
Mike Reed
15b95d6f6c Move image sampling options into their own header
Experimenting with a single struct for everything, to simplify the
number of API changes/additions needed.

e.g. makeShader(...)

Idea is to use SkSampleOptions to augment drawBitmap calls, so we can
remove SkFilterQuality enum from SkPaint.

Change-Id: I9045ff483f58af29148d7dc21d30b294c4a718a1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332739
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-11-06 17:30:44 +00:00
Greg Daniel
1448eb979d Fix formatting nit.
Change-Id: Id107d50ba23db4491d54d80b1d4c688bd3e80ebc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332741
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Auto-Submit: Greg Daniel <egdaniel@google.com>
2020-11-06 16:46:44 +00:00
Adlai Holler
3078f85ca5 Remove dead no-sorting GrDrawingManager code paths
This simplifies our world a little bit.

Bug: skia:10877
Change-Id: I2fb27cd53e9fda0f279c046f6eaa50fd02774e72
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332604
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-11-06 14:49:50 +00:00
Michael Ludwig
6cafdc069b Revert "Draw image filters directly under non-axis-aligned transforms"
This reverts commit f8f23b2030.

Reason for revert: b/172617382 is creating issues for Android's Webview

Original change's description:
> Draw image filters directly under non-axis-aligned transforms
>
> This removes hacking the canvas CTM and wrapping the paint's image
> filter in a special MatrixTransform that computed a post-transform
> instead of its documented pre-transform effect. Performance-wise, the
> computed layer sizes should be about the same, but we avoid one less
> render target switch because we apply the transformation while drawing
> to the dst device, vs. transforming into another temporary layer and
> then drawing that to the dst device.
>
> Several important changes in behavior here:
> 1. The DeviceCM record no longer has a stashed matrix to restore and
>    holds its restoration paint directly.
> 2. Devices for image filter inputs can now have device-to-global
>    transforms that are not integer translates.
> 3. The MatrixTransform hack punted when there was perspective because it
>    could produce excessively large temporary images, but the new version
>    appears to work around that. We now impose a maximum layer size to
>    protect against that and automatically scale the layer to prevent it.
>    Perspective image filters otherwise now draw correctly.
> 6. Updated layer sizing code to use the new image filter APIs
> 7. Updated backdrop filter and restore filters to go through the same
>    code paths, although restore filters skip the intermediate image
>    transform.
>     - layer bounds and transforms now go through the updated skif API
>       and is hopefully more straight forward to understand.
> 8. Now we can optimize root color filter nodes of a filter DAG, even if
>    the entire DAG can't be represented as a color filter. The last node
>    is pulled off and composed with the restoration paint instead.
>
> Bug: skia:9074,skia:9283
> Change-Id: I1fa1d50135b9d6d453b02f89aa3cc3b54deab678
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328376
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

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

Change-Id: I098d0e4b8ee067b436400eb9fea047e629544eec
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9074
Bug: skia:9283
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332737
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-06 14:06:42 +00:00
Michael Ludwig
f8f23b2030 Draw image filters directly under non-axis-aligned transforms
This removes hacking the canvas CTM and wrapping the paint's image
filter in a special MatrixTransform that computed a post-transform
instead of its documented pre-transform effect. Performance-wise, the
computed layer sizes should be about the same, but we avoid one less
render target switch because we apply the transformation while drawing
to the dst device, vs. transforming into another temporary layer and
then drawing that to the dst device.

Several important changes in behavior here:
1. The DeviceCM record no longer has a stashed matrix to restore and
   holds its restoration paint directly.
2. Devices for image filter inputs can now have device-to-global
   transforms that are not integer translates.
3. The MatrixTransform hack punted when there was perspective because it
   could produce excessively large temporary images, but the new version
   appears to work around that. We now impose a maximum layer size to
   protect against that and automatically scale the layer to prevent it.
   Perspective image filters otherwise now draw correctly.
6. Updated layer sizing code to use the new image filter APIs
7. Updated backdrop filter and restore filters to go through the same
   code paths, although restore filters skip the intermediate image
   transform.
    - layer bounds and transforms now go through the updated skif API
      and is hopefully more straight forward to understand.
8. Now we can optimize root color filter nodes of a filter DAG, even if
   the entire DAG can't be represented as a color filter. The last node
   is pulled off and composed with the restoration paint instead.

Bug: skia:9074,skia:9283
Change-Id: I1fa1d50135b9d6d453b02f89aa3cc3b54deab678
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328376
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-11-05 20:46:15 +00:00
Derek Sollenberger
f843170eb2 Revert "move subrun code to anonymous namespace"
This reverts commit a5eff5d53a.

Reason for revert: b/172455654

Original change's description:
> move subrun code to anonymous namespace
>
> Change-Id: Ic4325a5529ba354c0ce176c4299a9c179f911ff2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332136
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Herb Derby <herb@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

TBR=herb@google.com,robertphillips@google.com,reed@google.com

Change-Id: I5601b086ff3dc0a5de85fb427cc01568c67f18ba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332541
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Auto-Submit: Derek Sollenberger <djsollen@google.com>
2020-11-05 16:03:33 +00:00
Vignesh Venkatasubramanian
eb7f960705 Reland "heif: Add AVIF type and AVIF sniffing"
Fix: Do not use std::optional.

Bug: b/141654151
Change-Id: I6237db0d55b1ea92f7be3588a2b648b9e6014e3f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331878
Reviewed-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-11-05 15:25:52 +00:00
Brian Salomon
694ff17357 Revert "Revert changes to unbreak bots."
This reverts commit 49721c8437.

Reason for revert: fixed double usage of plane release context in
 YUVUtils.

Original change's description:
> Revert changes to unbreak bots.
>
> f01a9d9020
> is the culprit
>
>
> Revert "GrRefCntedCallback has Make function."
>
> This reverts commit b2c42140ea.
>
> Revert "Add SkImage::MakeFromYUVATexturesCopyToExternal"
>
> This reverts commit f01a9d9020.
>
> Bug: skia:10632
> Change-Id: Ief076f168b63ff8ca15b607163a13d5f52a733d2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331798
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

TBR=bsalomon@google.com

Change-Id: I41cdfe0d5b8587f85fae0c804c059c0d6ff92800


Bug: skia:10632
Change-Id: I41cdfe0d5b8587f85fae0c804c059c0d6ff92800
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331876
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-11-05 14:35:23 +00:00
Brian Osman
d7e7659cad Move GrShaderCaps from Program::Settings to Compiler
This ties the caps to the compiler instance, paving the way for
pre-optimizing the shared code. Most of the time, the compiler is
created and owned the GPU instance, so this is fine. For runtime
effects, we now use the shared (device-agnostic) compiler instance
for the first compile, even on GPU. It's configured with caps that
apply no workarounds. We pass the user's SkSL to the backend as
cleanly as possible, and then apply any workarounds once it's part
of the full program.

Bug: skia:10905
Bug: skia:10868
Change-Id: Ifcf8d7ebda5d43ad8e180f06700a261811da83de
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331493
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-04 19:38:33 +00:00
Greg Daniel
007d97d699 Allow creating SkSurfaceCharacterizations directly for vk secondary CB context.
Bug: chromium:1144921
Change-Id: I9ca905eb9f2542aafbde25e0baa5430640277699
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331877
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-11-04 16:43:42 +00:00
Herb Derby
a5eff5d53a move subrun code to anonymous namespace
Change-Id: Ic4325a5529ba354c0ce176c4299a9c179f911ff2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332136
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2020-11-04 14:59:48 +00:00
Brian Salomon
49721c8437 Revert changes to unbreak bots.
f01a9d9020
is the culprit


Revert "GrRefCntedCallback has Make function."

This reverts commit b2c42140ea.

Revert "Add SkImage::MakeFromYUVATexturesCopyToExternal"

This reverts commit f01a9d9020.

Bug: skia:10632
Change-Id: Ief076f168b63ff8ca15b607163a13d5f52a733d2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331798
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-11-03 18:52:45 +00:00
Brian Salomon
8b5d44b42a Revert "Reland "heif: Add AVIF type and AVIF sniffing""
This reverts commit 28eb592735.

Reason for revert: std::optional use is breaking bots, e.g.:
https://ci.chromium.org/raw/build/logs.chromium.org/skia/4fa8175011a1c411/+/annotations

Original change's description:
> Reland "heif: Add AVIF type and AVIF sniffing"
>
> This is a reland of 3ab5b73649
>
> Fix: Chromium does not use the heif decoder. So hide it behind
> an ifdef.
>
> Original change's description:
> > heif: Add AVIF type and AVIF sniffing
> >
> > AVIF is the image format based on the AV1 video codec. The
> > container for AVIF is very similar to that of HEIF. Add type
> > definitions for AVIF and sniffing code for detecting AVIF images.
> >
> > The underlying android platform's HEIF decoder implementation will
> > also support AVIF decoding.
> >
> > Bug: b/141654151
> > Change-Id: I7e31f4cedf0bffb8920ddf880a26601e48d0e833
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330059
> > Reviewed-by: Leon Scroggins <scroggo@google.com>
> > Reviewed-by: Derek Sollenberger <djsollen@google.com>
> > Reviewed-by: Chong Zhang <chz@google.com>
> > Commit-Queue: Leon Scroggins <scroggo@google.com>
>
> Bug: b/141654151
> Change-Id: Ie6840d6fc97789be619924fc60df8683cd58430f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331496
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> Commit-Queue: Leon Scroggins <scroggo@google.com>

TBR=djsollen@google.com,scroggo@google.com,chz@google.com,vigneshv@google.com

Change-Id: I25df9f65b9d56d81be70a5fa650c3d841bd5a15e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b/141654151
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331800
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-11-03 18:42:49 +00:00
Vignesh Venkatasubramanian
28eb592735 Reland "heif: Add AVIF type and AVIF sniffing"
This is a reland of 3ab5b73649

Fix: Chromium does not use the heif decoder. So hide it behind
an ifdef.

Original change's description:
> heif: Add AVIF type and AVIF sniffing
>
> AVIF is the image format based on the AV1 video codec. The
> container for AVIF is very similar to that of HEIF. Add type
> definitions for AVIF and sniffing code for detecting AVIF images.
>
> The underlying android platform's HEIF decoder implementation will
> also support AVIF decoding.
>
> Bug: b/141654151
> Change-Id: I7e31f4cedf0bffb8920ddf880a26601e48d0e833
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330059
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Reviewed-by: Chong Zhang <chz@google.com>
> Commit-Queue: Leon Scroggins <scroggo@google.com>

Bug: b/141654151
Change-Id: Ie6840d6fc97789be619924fc60df8683cd58430f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331496
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-11-03 17:50:42 +00:00
Brian Salomon
b2c42140ea GrRefCntedCallback has Make function.
Each caller does not need to check for null function.

Also inherit from SkNVRefCnt.

Change-Id: I9a53c3c8e9dec1361db6cfb21b97d178173b23ac
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331490
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-11-03 16:49:12 +00:00
Brian Salomon
f01a9d9020 Add SkImage::MakeFromYUVATexturesCopyToExternal
Updated API for creating a RGBA texture-backed image from RGBA texture
planes with user-provided backing store using GrYUVABackendTextures.

Ultimately we would like to remove all such APIs and have the client
make a SkSurface and draw a YUVA texture image to the surface but
a recent attempt to do that in Chrome caused a not yet understood
perf regression.

Add wacky_yuv_formats variation that tests new api.

Bug: skia:10632
Change-Id: I89411216948682f13281a91a7575d5f345badda7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329956
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-11-03 15:03:21 +00:00
John Stiles
ebb26e30f2 Revert "heif: Add AVIF type and AVIF sniffing"
This reverts commit 3ab5b73649.

Reason for revert: <optional> header is C++17 only

Original change's description:
> heif: Add AVIF type and AVIF sniffing
>
> AVIF is the image format based on the AV1 video codec. The
> container for AVIF is very similar to that of HEIF. Add type
> definitions for AVIF and sniffing code for detecting AVIF images.
>
> The underlying android platform's HEIF decoder implementation will
> also support AVIF decoding.
>
> Bug: b/141654151
> Change-Id: I7e31f4cedf0bffb8920ddf880a26601e48d0e833
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330059
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Reviewed-by: Chong Zhang <chz@google.com>
> Commit-Queue: Leon Scroggins <scroggo@google.com>

TBR=djsollen@google.com,scroggo@google.com,chz@google.com,vigneshv@google.com

Change-Id: I9c9cd00af1a41bffa37725f39afc9bc0e504d616
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b/141654151
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331336
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-11-02 16:08:03 +00:00
Vignesh Venkatasubramanian
3ab5b73649 heif: Add AVIF type and AVIF sniffing
AVIF is the image format based on the AV1 video codec. The
container for AVIF is very similar to that of HEIF. Add type
definitions for AVIF and sniffing code for detecting AVIF images.

The underlying android platform's HEIF decoder implementation will
also support AVIF decoding.

Bug: b/141654151
Change-Id: I7e31f4cedf0bffb8920ddf880a26601e48d0e833
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330059
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Chong Zhang <chz@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-11-02 15:28:21 +00:00
Mike Reed
b21c1f2d44 test lineTo after addRect
Motivated by investigating
https://skia-review.googlesource.com/c/skia/+/330696

This CL does not fix anything, but is meant to better document
the current behavior.

Change-Id: I62b8cbfb39e05404f0f5303f024e1f56fc32b7e5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330937
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
2020-10-31 15:10:48 +00:00
John Stiles
d5e6368fff Add initializer_list support to SkTArray.
Also added unit tests for each of SkTArray's various constructors, and
added `SkTArray::value_type` which allows calling code to refer to the
array's value-type. These unit tests exposed some preexisting strict-
aliasing issues in SkSTArray when compiled on GCC 6+ with optimizations
enabled, which are being investigated separately at skia:10891.

Change-Id: Ia0fb18830cfbbdcb1545fe7f7ac51d8e768a3f94
Bug: skia:10891
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330279
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-10-30 18:35:41 +00:00
Mike Klein
56957d9ccf remove unimplemented sk_data_new_empty()
Bug: skia:9585
Change-Id: I1fefd3598478d2f2c157d3a91750b5b92479b1b2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330278
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-10-29 16:20:06 +00:00
Greg Daniel
771c750169 Track vulkan memory allocations in UMA.
We track the total amount of memory allocated and the percentage of the
allocated memory that is used.

Bug: skia:10871
Change-Id: I4aa120a3545d215cf42430aa6a73e924118f1dbc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329963
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-10-29 15:24:23 +00:00
Robert Phillips
83c38a8fd6 Allow uniqueKey invalidation messages to reach the thread safe cache
With the addition of vertex data to the thread safe cache we also have
to handle the case where a given SkPath becomes inaccessible and
proactively invalidate the matching entry.

Bug: 1108408
Change-Id: Id11ce2aa10517f7c0772a253634d3c0d13e13460
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330261
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-10-29 12:36:13 +00:00