Commit Graph

1283 Commits

Author SHA1 Message Date
Adlai Holler
33dbd65611 Pass file and line number when asserting single owner
Working on debugging some multithreading and when a bot fails single owner, currently we get the unhelpful message "GrSingleOwner.h:33" with no backtrace. With this at least we get the real function.

Bug: skia:10305
Change-Id: I201ae96839bf9c043d009abc44a6ba784a9b9742
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293246
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-06-01 17:10:40 +00:00
Adlai Holler
43b1579dac Make abandonment state of context thread-safe
The plan going forward is to centralize all thread-safe data in GrContextThreadSafeProxy, make it not derive from GrContext_Base, and have all the GrContext-derived classes share a pointer to a context group's shared GrContextThreadSafeProxy. And probably rename the proxy class after retracting it from public API (GrContextFamily?)

Bug: skia:10295
Change-Id: I9807ad0926f9b2d69a8694db974a3bcac9fd66b0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292853
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
2020-06-01 14:47:07 +00:00
Greg Daniel
6c6caf420a Add GrBackendMutableState object to handle shared texture state.
This is will be the main struct used to synchronize changes of certain
texture/image between clients and Skia. With this change we
implement support for the Vulkan shared state as POC.

Bug: skia:10254
Change-Id: I10543357635c347838b193874e4da4496a0dcf06
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292311
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-05-29 16:53:08 +00:00
Michael Ludwig
81d4172d86 Reland "Simplify GrRTC::clean APIs"
This reverts commit 4730f29993.

Reason for revert: Fix WIP

Original change's description:
> Revert "Simplify GrRTC::clean APIs"
> 
> This reverts commit 6cbd7c2e57.
> 
> Reason for revert: mac/generated files failures
> 
> Original change's description:
> > Simplify GrRTC::clean APIs
> > 
> > The CanClearFullscreen enum type is removed. Most usages of clear() had
> > kYes because a null scissor rect was provided, or had kNo because the
> > scissor was really critical to the behavior. A few places did provide a
> > scissor and kYes (e.g. for initializing the target).
> > 
> > To simplify this, the public GrRTC has two variants of clear(). One with
> > only a color (for fullscreen clears), and one with a rect for partial
> > clears. The private API also adds a clearAtLeast() function that replaces
> > the several cases where we'd have a scissor but could expand to fullscreen.
> > 
> > I find the current control flow in internalClear() to be hard to
> > follow (albeit I was the one to make it that way...), but later CLs
> > will improve it.
> > 
> > Bug: skia:10205
> > Change-Id: I87cf8d688c58fbe58ee854fbc4ffe22482d969c6
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290256
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> 
> TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com
> 
> Change-Id: I7131df6f5323f4f9c120cbcfd9bc57e627e2eb65
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:10205
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291842
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

# Not skipping CQ checks because this is a reland.

Bug: skia:10205
Change-Id: Id5db153d7c2500279cca8478818b66f67a53e143
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291844
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-05-27 14:26:16 +00:00
John Stiles
e84ed12bbd Improve doc comments for SkTArray.
Change-Id: Ife5abd41cdc594abd20518081f8ed12565db4a47
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291937
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
2020-05-26 21:10:31 +00:00
Mike Reed
c8653569d9 Avoid malloc calls for these two temp arrays on the stack.
TODO: fRunsInVisualOrder is a long-lived array, but appears to..
- never resize after the constructor
- very often be size==1
Can we preallocate storage for it in the TextLine itself? (e.g. StSTArray or other trick)

Change-Id: I817b46a24e01ddf999bdd81a607aaf35b3c0674b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291776
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-05-26 16:37:49 +00:00
Michael Ludwig
4730f29993 Revert "Simplify GrRTC::clean APIs"
This reverts commit 6cbd7c2e57.

Reason for revert: mac/generated files failures

Original change's description:
> Simplify GrRTC::clean APIs
> 
> The CanClearFullscreen enum type is removed. Most usages of clear() had
> kYes because a null scissor rect was provided, or had kNo because the
> scissor was really critical to the behavior. A few places did provide a
> scissor and kYes (e.g. for initializing the target).
> 
> To simplify this, the public GrRTC has two variants of clear(). One with
> only a color (for fullscreen clears), and one with a rect for partial
> clears. The private API also adds a clearAtLeast() function that replaces
> the several cases where we'd have a scissor but could expand to fullscreen.
> 
> I find the current control flow in internalClear() to be hard to
> follow (albeit I was the one to make it that way...), but later CLs
> will improve it.
> 
> Bug: skia:10205
> Change-Id: I87cf8d688c58fbe58ee854fbc4ffe22482d969c6
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290256
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

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

Change-Id: I7131df6f5323f4f9c120cbcfd9bc57e627e2eb65
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10205
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291842
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-05-26 14:37:23 +00:00
Michael Ludwig
6cbd7c2e57 Simplify GrRTC::clean APIs
The CanClearFullscreen enum type is removed. Most usages of clear() had
kYes because a null scissor rect was provided, or had kNo because the
scissor was really critical to the behavior. A few places did provide a
scissor and kYes (e.g. for initializing the target).

To simplify this, the public GrRTC has two variants of clear(). One with
only a color (for fullscreen clears), and one with a rect for partial
clears. The private API also adds a clearAtLeast() function that replaces
the several cases where we'd have a scissor but could expand to fullscreen.

I find the current control flow in internalClear() to be hard to
follow (albeit I was the one to make it that way...), but later CLs
will improve it.

Bug: skia:10205
Change-Id: I87cf8d688c58fbe58ee854fbc4ffe22482d969c6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290256
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-05-26 13:16:12 +00:00
Ben Wagner
4651b99f32 Reland "Cache hb_face."
Creating an hb_face can be quite expensive, cache them.

This implementation is similar to the super simple caching strategy used
by libtxt. It uses a simple global LRU cache from SkFontID to hb_hbface
of size 100.

Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289442
Change-Id: I971620f7aaaf2d7b6902da8681e29d6d458429ed
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290761
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-05-19 17:42:14 +00:00
Ben Wagner
39decdbe35 Fix TODO in SkTArray move constructor.
If moving from an SkTArray which owns its own memory, just steal it
instead of always making a copy.

Change-Id: Ic969437a39d23d878d752bbdee38aa5dd2472e21
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290125
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2020-05-18 15:17:17 +00:00
Robert Phillips
f10b2a58a3 Loosen up uniqueKey asserts between GrTextureProxy and GrTexture in DDLs (alt. version)
When recording a DDL it is possible for a uniquely keyed resource to lose its uniqueKey in the direct context (and its proxyProvider) while the DDL's proxyProvider still has a proxy with a uniqueKey.

Bug: 1056730
Change-Id: I565b08a8eb280aea19fc3052c758e059392a4c12
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289890
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-05-15 15:49:25 +00:00
Robert Phillips
273f107a2d Dump out path-mask generation and caching stats
These stats would've helped block https://skia-review.googlesource.com/c/skia/+/286902 (Add path bounds to SW path mask key) from landing.

Change-Id: I684f39de53fb2678c7a679e4e4aafdbb39a154ca
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287499
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-05-05 18:21:49 +00:00
Florin Malita
3facc9c886 [skottie] Non-legacy brightness effect
Includes POW intrinsic plumbing.

Change-Id: Ida961718e28822c8559f17f97003f67082dd44cc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287156
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-05-04 14:04:24 +00:00
Mike Reed
8520e76f05 migrate spiral demo from canvaskit
- add atan, fract, dividef, subtractf

Also wants mix(), but I'm still learning how to handle 2 args
functions (e.g. how to support atan(y,x) as well)

Change-Id: Ib9f233cd1c4266110cfea68a7d444f834f875f1f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286276
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-04-30 16:52:22 +00:00
Robert Phillips
9a30ee09b0 Add BGR_10A2 support to Ganesh (take 2)
This is no different from the first try but a Chrome-side bug fix has landed:

https://chromium-review.googlesource.com/c/chromium/src/+/2173388 (Map RGBA/BGRA_1010102 to their correct SkColorType equivalents)

TBR=bsalomon@google.com
Bug: 1068416
Change-Id: Ic6ee758b0f0537d83262b0d708f9b7b15a4cb1c7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286036
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-04-30 15:25:20 +00:00
Mike Klein
dc976a96ea update skstd
- Lots of skstd::foo is now std::foo since C++14.
- Get rid of SK_WHEN(cond,T); std::enable_if_t<cond,T> is pithy enough.
- Move SkBitmaskEnum.h contents into sknonstd.

Change-Id: Ie5dc459405b1ff55e5b3ac57e70df7edd7cf38c0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286315
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-04-30 15:05:43 +00:00
Mike Klein
c2160258f3 add skvx::{sin,cos,tan}
This lets us get rid of VECTOR_UNARY_FN_VEC.

I don't know exactly what was wrong with VECTOR_UNARY_FN_VEC,
but `color.rgb = color.rgb + a*(sin(6.28*color.rgb)*0.159)` looks
ok to me now when run through the interpreter.

Change-Id: I700398cd55eca1b8e1b3b46858415ecae5585a32
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286065
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-04-29 15:39:12 +00:00
Robert Phillips
a50ce3c983 Revert "Add BGR_10A2 support to Ganesh"
This reverts commit 44fc53b7f5.

Reason for revert: Test to see if this is causing the linux-rel MediaColorTest.Yuv420pHighBitDepth failure on the Chrome roll

Original change's description:
> Add BGR_10A2 support to Ganesh
> 
> Bug: 1068416
> Change-Id: I40aa84b7f3f770ba550b7bea44c10173ae9a7ddf
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285356
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>

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

Change-Id: I0ad0197ebd8de9b8761f84ba808c9f90891b9238
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1068416
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285958
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-04-28 22:30:46 +00:00
Robert Phillips
44fc53b7f5 Add BGR_10A2 support to Ganesh
Bug: 1068416
Change-Id: I40aa84b7f3f770ba550b7bea44c10173ae9a7ddf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285356
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-04-28 17:07:57 +00:00
Jim Van Verth
96bfeff55c More fixes to get D3D tests running.
* Set up D3D backend texture creation
* Fix GrD3DBackendSurfaceInfo initialization
* Minor fix to get wrapped RTs into the cache

Bug: skia:9935
Change-Id: Ic5319a7d059c4d969894529a326a91de0192f9eb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282679
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2020-04-10 15:19:18 +00:00
Robert Phillips
4d932d170f Move the GrStrikeCache from the recording context to the direct context
This solidifies that the strike cache and, thus, GrStrikes can't be used when recording DDLs.

TBR=bsalomon@google.com
Bug: 1056730
Change-Id: I15ce3ac2c0a9db0f476c03ef855bd14d22551043
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282536
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-04-09 18:47:27 +00:00
Brian Salomon
dc8fcdb735 Add getter for channels to GrBackendFormat
Bug: skia:10078

Change-Id: I0172a87d836a606a55e60b73ba255a41313e9c12
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282266
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-04-08 19:54:27 +00:00
Chris Dalton
03fdf6a9a9 Implement support for indirect draws
Change-Id: Ib1c0570d747bf9f46be3486f37eba3af53ed1e3d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281642
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2020-04-07 19:41:18 +00:00
Greg Daniel
6e35a00916 Have GrContext abandoned call also check if the underlying device is lost.
Change-Id: Iba09b8f39138e99cbd987880b2da07fdec799248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280638
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2020-04-01 18:33:23 +00:00
Jim Van Verth
8e75147214 Allow GrD3DTextureResourceInfo to include declared D3D12 types.
Changes the GrD3DTextureResourceInfo member in GrD3DBackendSurfaceInfo
to be a unique_ptr<> so we can use forward refs.

This will allow us to use a shared_ptr variant to manage the
ID3D12Resource on GrD3DResourceResourceInfo, without polluting
client files with Windows definitions. Clients can use GrD3DTypes.h
to get the full declarations, GrD3DTypesMinimal.h for only the forward
references.

Bug: skia:9935
Change-Id: I075a3fc608bf6767dae202efd8cbf06cdd4a9457
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280602
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-03-31 19:06:09 +00:00
Brian Osman
01e6d17fe8 Stop including SkCanvas.h from GrTypesPriv.h
It was too easy to get into circular include chains. Added static
asserts to ensure we keep our quad AA flags in sync. Also, IWYU.

Change-Id: I01aefa264aa56420ab5a46a8ecd9e63c021c79ab
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280405
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-03-30 20:43:34 +00:00
Brian Salomon
34ed73b038 Make memcmps in GrResourceKey::op== safe.
Previously the size of one of the keys was passed to memcmp.
It was incorrectly assumed that if the size mismatched in the
first word compared then the rest of the keys would not be
accessed.

Change-Id: I9850949c6b51d0d2fb6de53ed8d4dee5192826d2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280356
Commit-Queue: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-03-30 16:04:12 +00:00
Brian Salomon
2f23ae6b8e Rename SkColorTypeComponentFlags to SkColorChannelFlags.
Precusor step for making this public and adding a method to
GrBackendFormat to query its channels.

Bug: skia:10078
Change-Id: I2d8fa6586721c35961bc328a15eef8e2ebd4406e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279422
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-03-27 21:48:41 +00:00
Greg Daniel
f95a35fb70 Remove some unused 3 byte vertex attrib types.
These attrib types don't have equivalents in d3d12 and they are not used
so just deleting them.

Change-Id: Iff63525d36e0674847e07a13254f321c27aca7bc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279864
Commit-Queue: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-03-27 18:18:32 +00:00
Chris Dalton
0a22b1e656 Rename GrGpuTessellationPathRenderer to GrTessellationPathRenderer
Change-Id: I3598ecab2e56b37a8d08b9da186c27f3cf709bfe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279245
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-03-27 17:37:23 +00:00
Brian Salomon
2cae3b05ea Fix TODO SkImage_GpuBase to check SkColorInfo and not a fake SkImageInfo
Change-Id: I4c495beb1c08fcb42c5ea06c3ba97dce0bdf39cc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279841
Auto-Submit: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-03-27 16:46:21 +00:00
Jim Van Verth
6ec5688413 Rename GrD3DTextureInfo to GrD3DTextureResourceInfo.
Also renames GrD3DSurfaceResource to GrD3DTextureResource. This makes
things consistent with our naming convention in Vulkan, and with the
terminology used in Direct3D.

Bug: skia:9935
Change-Id: I6e6d2066ac70eb8a0d63c1b5731f31851a3017d5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279338
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-03-26 16:26:44 +00:00
Chris Dalton
17dc41870a Rename CPU tessellation to "triangulation"
Ambiguity has come up re: what "tessellation" means in Ganesh. I
believe that, in the context of a graphics library, "tessellation"
should refer to the hardware pipeline feature of submitting patches
and tessellating them on the GPU. This CL therefore renames classes
that triangulate things on the CPU to call it "triangulation".

Change-Id: Ic8515ea6a33000f1b638a852d5122bc9bd6b38f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279236
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-03-26 16:21:39 +00:00
Jim Van Verth
05d091935a Flesh out backend textures and rendertargets to support Direct3D.
Add GrD3DTextureInfo and GrD3DBackendSurfaceInfo, and uses those
to initialize GrBackendTexture and GrBackendRendertarget.

Bug: skia:9935
Change-Id: I4571c1b3aa8115250ff748deb8cf4a95f80f1237
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278036
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2020-03-20 17:12:46 +00:00
Mike Klein
6b48e62ed2 remove unused mutate() apis
Whether we should shrink at the end of mutate() turns out to be moot.

:)

Change-Id: Ic29df5734e3057f165f695b2d03f8e7eb0eeb4dd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277299
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2020-03-16 20:44:36 +00:00
Mike Klein
cff6396875 begin refactoring SkTDynamicHash and SkTMultiMap
The biggest mismatch between these and SkTHash{Map,Set,Table}
is the old ones provide Iter and ConstIter, the new ones foreach().

This CL,

   - adds foreach() methods to the old types,
   - replaces all uses of ConstIter with foreach(),
   - replaces most uses of Iter with foreach(),

I'm leaving one spot using Iter to walk the table and remove its
elements for its own CL... it'll be a little more complicated to get
that right.

From there it should be straightforward to turn SkTDynamicHash
into a thin wrapper over an SkTHashTable.

Bugs: skia:9703
Change-Id: Ia6ba87c35b89585c42b5b9f118f4cbf3abd04f0d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277098
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-03-16 14:06:30 +00:00
Mike Klein
16701eecd5 Shrink SkTHashTables
Since we grow when size >= 3/4 cap, shrink when size <= 1/4 cap?

Keeping a minimum table size of 4 preserves the invariant that tables
with non-zero capacity always have at least one empty slot, allowing
find() to determine a particular key is not in the table by stumbling
upon that empty slot on the key's hash chain.  That's effectively what
we're asserting at SkTHash.h:84.

Bug: skia:10041
Change-Id: I4247e4ff155fd11561086547525354365bc69f55
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277096
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2020-03-16 13:38:10 +00:00
Mike Klein
5caf7dee25 restore Op::round
While I think trunc(mad(x, scale, 0.5)) is fine for doing our float
to fixed point conversions, round(mul(x, scale)) was kind of better
all around:

   - better rounding than +0.5 and trunc
   - faster when mad() is not an fma
   - often now no need to use the constant 0.5f or have it in a register
   - allows the mul() in to_unorm to use mul_f32_imm

Those last two points are key... this actually frees up 2 registers in
the x86 JIT when using to_unorm().

So I think maybe we can resurrect round and still guarantee our desired
intra-machine stability by committing to using instructions that follow
the current rounding mode, which is what [v]cvtps2dq inextricably uses.

Left some notes on the ARM impl... we're rounding to nearest even there,
which is probably the current mode anyway, but to be more correct we
need a slightly longer impl that rounds float->float then "truncates".
Unsure whether it matters in practice.  Same deal in the unit test that
I added back, now testing negative and 0.5 cases too. The expectations
assume the current mode is nearest even.

I had the idea to resurrect this when I was looking at adding _imm Ops
for fma_f32.  I noticed that the y and z arguments to an fma_f32 were by
far most likely to be constants, and when they are, they're by far likely
to both be constants, e.g. 255.0f & 0.5f from to_unorm(8,...).

llvm disassembly for SkVM_round unit test looks good:

~ $ llc -mcpu=haswell /tmp/skvm-jit-1231521224.bc -o -
	.section	__TEXT,__text,regular,pure_instructions
	.macosx_version_min 10, 15
	.globl	"_skvm-jit-1231521224"  ## -- Begin function skvm-jit-1231521224
	.p2align	4, 0x90
"_skvm-jit-1231521224":                 ## @skvm-jit-1231521224
	.cfi_startproc
	cmpl	$8, %edi
	jl	LBB0_3
	.p2align	4, 0x90
LBB0_2:                                 ## %loopK
                                        ## =>This Inner Loop Header: Depth=1
	vcvtps2dq	(%rsi), %ymm0
	vmovupd	%ymm0, (%rdx)
	addl	$-8, %edi
	addq	$32, %rsi
	addq	$32, %rdx
	cmpl	$8, %edi
	jge	LBB0_2
LBB0_3:                                 ## %hoist1
	xorl	%eax, %eax
	testl	%edi, %edi
	jle	LBB0_6
	.p2align	4, 0x90
LBB0_5:                                 ## %loop1
                                        ## =>This Inner Loop Header: Depth=1
	vcvtss2si	(%rsi,%rax), %ecx
	movl	%ecx, (%rdx,%rax)
	decl	%edi
	addq	$4, %rax
	testl	%edi, %edi
	jg	LBB0_5
LBB0_6:                                 ## %leave
	vzeroupper
	retq
	.cfi_endproc
                                        ## -- End function

Change-Id: Ib59eb3fd8a6805397850d93226c6c6d37cc3ab84
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/276738
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2020-03-12 21:10:34 +00:00
Mike Klein
ec370976c6 move skvm interpreter to SkOpts again
This is the easiest way to guarantee Op::fma_f32
actually fuses, by using platform intrinsics.

While implementing this we noticed that quad-pumping
was actually slower than double-pumping by about 25%,
and single-pumping was between the two.  Switch from
quad to double pumping.

Change-Id: Ib93fd175fb8f6aaf49f769a95edfa9fd6b2674f6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275299
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2020-03-05 17:47:42 +00:00
Brian Salomon
64a3f8fcb7 Revert "Use spin lock in SkIDChangeListener"
This reverts commit a624a534ed.

Reason for revert: Bad perf

Original change's description:
> Use spin lock in SkIDChangeListener
> 
> This lock should almost never be contested. This simplifies things and
> also avoid mutex locks when one thread has multiple refs on a path,
> image, ...
> 
> Change-Id: I909b490363cb9e81b38ed9edd04272133fb2692b
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274676
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

TBR=bsalomon@google.com,brianosman@google.com

Change-Id: I45ec3241906429e4d0783b68ebe6398079b73d36
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274956
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-03-04 03:40:11 +00:00
Brian Salomon
a624a534ed Use spin lock in SkIDChangeListener
This lock should almost never be contested. This simplifies things and
also avoid mutex locks when one thread has multiple refs on a path,
image, ...

Change-Id: I909b490363cb9e81b38ed9edd04272133fb2692b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274676
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-03-03 16:58:00 +00:00
Brian Salomon
71fe945da3 Prevent unbounded listener growth on SkPixelRefs.
Use SkIDChangeListener and update GrBitmapTextureMaker to add listener
to key to deregister if texture is purged before genID changes.

Add a common listener list implementation and replace existing lists.

Change-Id: Ib0c78241eaf59b59b892d8b004b2bb095140bc6d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274549
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-03-02 22:32:09 +00:00
Brian Salomon
99a813ca29 Avoid unbounded listener growth on SkImage_Lazy when textures are purged
Generalizes the system used on SkPathRef where a GrTexture's key
destructor signals that a listener on the image can be removed via
the unique key custom data.

Removes texturesAreCacheable() from SkImageGenerator. This was used to
prevent unbounded growth in a narrow situation related to
GrBackendTextureImageGenerator.


Change-Id: I3c605da099acfac94751e793331e356a0979d359
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274038
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-03-02 18:38:09 +00:00
Nathaniel Nifong
e71bcc61e8 Add a condition to prevent a thread annotation meant for blaze from showing up to emscripten
Change-Id: Ie84d3fd6ae1625cd0e5b0959a30b94f9142ee30e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273876
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Nathaniel Nifong <nifong@google.com>
2020-02-28 17:57:20 +00:00
Mike Reed
8989363322 rm unneeded header, see include/public
Change-Id: Ica26f683a9fd0ef7a624aa081678b619b70c9af8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273400
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-02-26 04:53:33 +00:00
Julia Lavrova
9b906ce536 Revert "remove private copy of SkM44.h"
This reverts commit f8ef81b35e.

Reason for revert: Build broken

Original change's description:
> remove private copy of SkM44.h
> 
> Change-Id: Ifd47b929bafd40d190722366a0c1e2b856220ab3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272836
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Mike Reed <reed@google.com>

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

Change-Id: I0da4ad43d5eaf5813ec489bc9117d4b8fc2b930e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273330
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-02-25 23:00:54 +00:00
Mike Reed
f8ef81b35e remove private copy of SkM44.h
Change-Id: Ifd47b929bafd40d190722366a0c1e2b856220ab3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272836
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2020-02-25 19:51:17 +00:00
Brian Salomon
9f00494951 Add test that SWPathRenderer GenIDChange listeners get removed.
When a cached path mask texture is destroyed it should remove the
gen ID change listener on from the SkPathRef:
https://skia-review.googlesource.com/c/skia/+/272654

Change-Id: I4d1781e578b29b801b1b5b97ba5119ac321de73c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273004
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-02-25 14:51:51 +00:00
Robert Phillips
251ee1da5b Remove SkDDLTmpRedirect.h
With the Chrome-side CL:

https://chromium-review.googlesource.com/c/chromium/src/+/2067805 (Switch SkDDLTmpRedirect.h reference to SkDeferredDisplayList.h)

having landed, Skia no longer needs this temporary header.

TBR=bsalomon@google.com
Change-Id: I01da4ece2be239407e223105781d4d0d75deabdb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273018
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-02-24 18:26:35 +00:00
Robert Phillips
4d5594dff1 Move SkDeferredDisplayList.h into include\core (take 2)
Clients will need official access to this class for the compilation iterator.

This CL also hides some of the cruft we don't want exposed.

Bug: skia:9455
Change-Id: I696c058f1c409fb459229552fbbdd935ec112358
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272643
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-02-21 21:26:02 +00:00