bit_clear is at least useful as a special case for select(),
which helps with code readability.
Add is_NaN() and use these all together in sweep gradient.
Change-Id: I57a54f8956f85e0db0662b33f8446b8dc7342d8d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281685
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
- new this-> convention: never use it when calling common public
Builder methods like splat(), bit_and(), etc like you'd see in
normal user code, but always use it when calling private methods
like this->push(), this->isImm(), this->allImm().
- use c++17 if-statements to scope this->allImm() variables tighter.
- check for x.id == y.id cases where applicable, including a tweak
to min() and max() to make them able to hit the special case.
- add special cases for I32 +,-,*, and remove an old unimportant
unit test that assumed we didn't fold these.
- add special cases for select(), and use select() in a few more
places where it's clearer and now just as efficient.
Change-Id: Idaac9250ac5a95a48d33eeba1cc4380c8c91629d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281678
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Change-Id: Ie877e995642fe6be48b7e242aa955e87ecc14fb0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281385
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
bit_clear() is just another bit_and(),
and bytes() is a way of expression pshufb
that we never really use (yet).
Can always add them back later, but there's
some extra complexity to think about for each
that I'd like to not think about now:
- common sub-expression elimination between bit_and and bit_clear
- large constant management JIT'ing bytes
Change-Id: I3a54afa963231fec1d5de949acc647e3430ed0d8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281557
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Bug: skia:10078
Change-Id: I3ce0d97f8ada55403cc3f88bb16659085449ea29
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281207
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
It's clearer to see the flow of data this way and to read each pass'
implementation without all the pointer indirection, and move semantics
should let this be just as efficient.
Change-Id: I1ac211fbe54bec37de6d126eec0c211573c2a568
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281218
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This finishes up the main refactoring.
Still some follow-ups I want to try.
I got tired of typing usage.users(id) so I converted that to operator[],
which I think is clear for now. If we add more methods that don't refer
to the users, we can undo?
Change-Id: I0ac563cfb1899f7a3f8b2cb6d50ca1646dd05071
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281216
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
The color type used to influence the GrPixelConfig and the swizzles
used with the proxy and its GrTextures. So we had to create a new proxy
if the same API texture was used to fulfill a promise image of a
different color type. That has all been removed or lifted out of proxies
and into views. So now it is fine to reuse the same proxy/GrTexture with
a different color type.
Also remove unit test that checked required a new GrTexture be made if
a different color type was used.
Bug: skia:10078
Change-Id: Ib74c419b5d54d382ea95720af7026640e35013f0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281056
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Seems nicer to keep encapsulated in a program->program pass
so nothing upstream of it has to think about liveness.
I will be circling back around to profiling the cost of these
tempoaries, copies, etc. I just want to start writing them as
if cost were no object first.
Change-Id: I1d1187b521fbe963e720e0d8de90316a549f7797
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281182
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
We already checked the SkSafeRange earlier (after its last use). Here we
need to be checking the SkSafeMath object. Oops.
The counts are directly copied from the constructor to the vertices'
fields - the user already knows what they are (and the tests are
verifying a tautology).
Bug: skia:9984
Change-Id: I33c62e02825718e497834b0dfa40d0d56e46a197
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280963
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Adds structure to the per-vertex (now custom) data.
Attributes currently just have a type, but the next
step is to augment that with semantic flags to handle
transformation logic in the vertex shader.
Added unit tests and GMs that exercise attributes of
varying float counts, as well as normalized bytes.
Bug: skia:9984
Change-Id: I02402d40b66a6e15b39f71125004efb98bc06295
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280338
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This is purely to make debugging easier, as the shaders now make more sense
to read.
Change-Id: Ie8e9b9d36112fda3ff997d088955de5a0e2c787a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281017
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Instead of copying fIndex and marching it forward,
we can tick down our existing uses counts backward,
saving one temporary std::vector.
Our implementation does guarantee the Instructions
returned by users() are sorted, so let's lean into
that... that means we can find the death time of any
instruction simply by looking at users().back()
(if there are any, of course).
Everything else is names and formatting, the biggest
being renaming Uses -> Usage. There's enough mention
of "users" and "uses" contrasting with each other that
I think it makes sense for the type to have the nice
middle-ground neutral name Usage, reflecting the arrow
and not which way we're thinking about it pointing.
Change-Id: I32ea9af6eb6430a162bee6da4810a599e8ed0dfd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281003
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
It is also used for writes to surfaces other than fragment shader
output. e.g. clears.
Change-Id: Id1eb79be6d1a8aed936456bffa59dee32661cec8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280344
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Change-Id: Ic6c0de262e13c3c3ea9e7777ccdd04f22ff6ae0a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280345
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Liveness tracks all the live instructions in the instruction stream.
Uses maps this value to instructions that use it.
Uses is overkill for the current schedule, but will be needed for
spilling.
Change-Id: Id20b7b7a90901e156d323bb612c5908f91405967
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277744
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Rather than two separate (partially overlapping) ways of accessing the
private portions of SkVertices, use a single privileged helper class
(similar to GrContextPriv).
Change-Id: I76b14b63088658ed8726719cce126577e5a52078
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280601
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This reverts commit 8176508cc6.
Replaces incorrect check for Read pixels support with Write check.
Change-Id: Idc80aaaa41ba35014339df450bb8b583fb6dab51
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280399
Auto-Submit: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Allow push_back to take an rvalue to move into the allocator, which has
the nice side effect of making the test for it a bit better.
Change-Id: I7e313cf75c1ad65fbf765b10c4717672063b5570
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280412
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Change-Id: I60a3569b47b599b710c0f3a9522241748f15360d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280409
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
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>
Instead separately check texturability and uploadability using existing
queries.
Also remove unused renderable param from onGetDefaultBackendFormat()
Change-Id: I8751e6d62263ddabd713c850beb788620a78bf10
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279996
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
GCC 9 warns about this pessimizing-move. It isn't clear why clang isn't
as well.
GCC 9 has a working redundant-move diagnostic. Clang has an old (C++11
style) redundant-move diagnostic which only warns when moving a
parameter. The GCC warning conflicts with Clang's
return-std-move-in-c++11, which we want to keep until we can drop
support for older compilers. So just disable redundant-move warnings
until we can remove return-std-move-in-c++11.
This change allows us to compile without warnings on gcc 9.3.0.
Change-Id: If21fcfb2944ce49e27fc84d40805752895ae68cf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279958
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
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>
This effectively reverts https://codereview.chromium.org/972153010/
Note that we have no such hard limit on SkShaders, and it's never
been a problem. Complex SkPaint objects can generate too many FPs
for us to handle, but those are rare, and better managed by just
reporting the shader compile error (which we do).
Change-Id: Iee5dc3d65ec130f2ce0a29e55fbe3c25b00dc828
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279836
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
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>
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>
Previously, the GrAllocator header defined three types: GrAllocator,
GrTAllocator, and GrSTAllocator. GrAllocator was generic, and would
manage the blocks of memory (fixed size to hold N * sizeof(item)). It
stored an SkTArray of pointers to each block. GrTAllocator wrapped
the GrAllocator to add template support for a specific T. GrSTAllocator
extended GrTAllocator to include a template arg for inline storage.
In this CL, GrAllocator is no longer defined, and its memory functionality
is replaced with the use of GrBlockAllocator. For the most part, the
implementation of GrTAllocator on top of GrBlockAllocator remains the
same, although there is explicit array to the block pointers so indexing
is slightly different. GrSTAllocator is also removed entirely, so that
GrTAllocator's template includes initial storage size.
The iteration over the allocated items
is updated to wrap GrBlockAllocator's block iterator, and then iterate
by index within each block. Documentation on GrAllocator already recommended
using the iterator instead of random access, and these changes further
reinforce it. It turns out that many of the use cases of GrAllocator
were written to use random access, so many of the files outside of
GrAllocator.h have just been updated to use the new for-range iteration
instead of a random access for loop.
Change-Id: I28b0bc277c323fd7035d4a8442ae67f058b2b64c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272058
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Properly tagging links in PDFs just required a small change: at the time
an annotation is drawn, we need to keep track of the bounding rect, the
url and/or named destination, and now additionally the node ID. Instead
of keeping track of separate maps of rects/urls and rects/dests, this
patch combines them into a vector of SkPDFLinks.
Then, at the time the annotation is written to the file, an object
reference to that annotation can be saved and passed to the document
structure tree, where it can be included as an additional child of
the node with that node ID.
That allows for properly tagging the link and optionally giving it alt
text (like for an image link).
Bug: chromium:1039816
Change-Id: I97e47d3c70949020c3e0a69b8c9fc743748f3a7b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277426
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: Ben Wagner <bungeman@google.com>
... in support of programs for colorspacexforms
Change-Id: I72ace09f10511ef8994038a4af3feab8bc1a299e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278466
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This reverts commit bc0fe058f8.
Reason for revert: red
Original change's description:
> Make TessellationTestOp and GrPipelineDynamicStateTestOp surface their programInfos at record time
>
> These aren't high priority but it would be nice to have all the ops go through the same system.
>
> Bug: skia:9455
> Change-Id: Idbd8b0829faf12703c82f5a016f5b0e7c3efb762
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277757
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
TBR=egdaniel@google.com,robertphillips@google.com
Change-Id: I579ad16f144d17afaec9ee1b9000eaaa5c04228c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9455
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278508
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
These aren't high priority but it would be nice to have all the ops go through the same system.
Bug: skia:9455
Change-Id: Idbd8b0829faf12703c82f5a016f5b0e7c3efb762
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277757
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Updated to use sentinel GL context even when GL backend is not built.
This reverts commit 1171d314ef.
Change-Id: Ia94bbe4865ddd4e898446c13886877c539f0eb0b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277976
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This makes onPrePrepare match onPrepare & onExecute. Most of the new method bodies will-have-to/should be filled in anyway.
Change-Id: Ifc897feaeb2d8fe6eec3ac3a8e91f99393ad6758
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277542
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Also strengthens/adds some guarantees about this function:
* Always returns the same image if the original is texture-backed and
compatible with GrMipMapped (WRT HW MIP support)
* If a new texture backed image is returned it is always an uncached
texture that is not shared with another image or owned by an image
generator.
Adds a GrImageTexGenPolicy that allows control through image/bitmap
GrTextureProducers of whether a new texture must be made and whether
that texture should be budgeted or not.
Increases unit test coverage of this API.
Bug: skia:8669
Change-Id: Ifc0681856114a08fc8cfc57ca83d22efb1c1f166
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274938
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Every op that updates dynamic state between draws has now been
migrated to explicit binding.
Change-Id: Ibd13c9c0ffb16a205c073dfb4fd21d93f496dc52
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277493
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
We are removing dynamic state from the ProgramInfo, so the Ops will
need to invoke visits on their own primProc proxies.
Change-Id: I7ab227ab71208b7c7bcb7a9deb56b9abd556d6aa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277236
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Everyone is responsible to set up their own scissor and textures now.
Change-Id: Ic3547f00c0e7908409631951de4b7237b9bce23b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277177
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This moves the byte block linked list structure outside of GrMemoryPool
into a new type, GrBlockAllocator. This new type is solely responsible
for managing the byte blocks, tracking where the next allocation
occurs, and creating/destroying the byte blocks. It also tries to
encapsulate all of/most alignment related math, while making it
convenient for clients to add per-allocation padding/metadata.
It has added functionality compared to the original block linked list
that was embedded in GrMemoryPool:
- Supports resetting the entire allocator
- Supports resizing the last allocation
- Is able to rewind an entire stack of allocations, instead of just the
last allocation.
- Supports multiple block growth policies instead of just a fixed size.
- Supports templated alignment, and variable alignment within a single
GrBlockAllocator
- Query the amount of available memory
- Performs as much math as possible in 32-bit ints with static asserts
that ensure overflow won't happen.
Some of this flexibility was added so that the GrBlockAllocator can be
used to implement an arena allocator similar to SkArenaAlloc, or to
replace the use of SkTArray in GrQuadBuffer. It is also likely possible
that GrAllocator can be written on top of GrBlockAllocator. I will try
to perform these consolidations in later CLs.
Change-Id: Ia6c8709642369b66b88eb1bc46264fb2aa9b62ab
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262216
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
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>
In the old code, the cache was checked and perged on every reattach
of a strike. That was left out of the multi-threaded code. Add the
check and purge back in to maintain cache size.
* Removed minimum cache size from setCacheSizeLimit.
Bug: skia:10046
Change-Id: I2438c83f04b6da8133c161a29604c3c3d7f58cd8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277066
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>