Commit Graph

629 Commits

Author SHA1 Message Date
Robert Phillips
b87b39b7a2 Make GM::onGpuSetup take a GrDirectContext
This should, hopefully, clarify the role of onGpuSetup vis a vis onDraw.

The remaining tools are updated in:
https://skia-review.googlesource.com/c/skia/+/300220/ (Update remaining tools to GrDirectContext)

Change-Id: I19d6eec4d16cb9ebad8924763a18225cc871f0f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300172
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-07-01 19:25:55 +00:00
John Stiles
d2f870c911 Fix modifier key handling in OS X to allow command-keys to work.
A variety of modifier key handling issues are addressed in this CL:
- Added a skui::Key for the Super key (this is ImGui's name for command)
- Added OS X event handling for `flagsChanged` (sent when modifier keys
  are pressed)
- OS X manually tracks modifier key state and sends key-up and key-down
  events to the ImGuiLayer as necessary
- OS X does not send key-up events when hotkeys are pressed, so these
  are manually synthesized and sent to ImGui (otherwise hotkeys are
  repeated forever)
- Replaced hardcoded Virtual Key valus in OS X code with named constants
- Our custom bitmask type was lacking the ability to XOR

This CL does NOT enable the OS X clipboard; this uses the ImGui internal
clipboard.

Change-Id: I76b55215858bfb6441dbef18ad638426fa8bc073
Bug: skia:10338
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300182
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-07-01 16:07:03 +00:00
John Stiles
ab9578e9c6 Update ImGui to latest stable version (1.77).
Also added various sk_app headers to BUILD.gn for ease of access.

Change-Id: I99646c8f3906e00ca95f8e583319cb9b873c66ff
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300037
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-07-01 02:29:22 +00:00
Robert Phillips
e922953cab Adjust how GM::gpuSetup is handled in the tools
Change-Id: I7a49ff49030b4c8aba1f0798a3742641030fe44f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298710
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-06-26 15:37:30 +00:00
Robert Phillips
d26d25ed67 Make gpuSetup draw a error message on failure
Since gpuSetup can preempt draw's execution it needs to draw the error message too.

This is pulled out of the gpuSetup refactoring.

Change-Id: Iafe06d924fc1b694c59aa3100e9fbe95c4773222
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/299140
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-06-26 13:50:35 +00:00
John Stiles
38b7d2f223 Add support for magenta highlights on shader mouseover in Metal.
Change-Id: Ia449e2cfd8b1153e7ab1cd7ad1916550aecf55ef
Bug: skia:10428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298744
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-06-24 16:55:53 +00:00
John Stiles
03b92cd667 Fix crash in Viewer when attempting to view shaders in Metal.
Change-Id: Ia19063f13e74d7dc2f1ead1fad20ad6828a3648d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298742
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-06-24 15:34:53 +00:00
Robert Phillips
c23b732da6 Update viewer to call the gpuSetup GM entry point
Change-Id: Ic2562d985e144f25dcbb5cf40fafc86a33fb76c2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298505
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Trevor Barton <trevor.barton@sydstu.catholic.edu.au>
Reviewed-by: Kobi Robinson <kobi.robinson@sydstu.catholic.edu.au>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-06-24 13:43:59 +00:00
Florin Malita
579e63af00 [skrive] Reset the node system
Tacking another hierarchy on top of SkSG doesn't work well.

Let's start fresh.

TBR=
Change-Id: Ieb379b57e1a77df3c62048d3be7e81e1429f9b23
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297807
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2020-06-19 20:00:55 +00:00
Brian Osman
f847f3106c In SkSLSlide, directly use Viewer's shader error handler
With the CPU backend, there is no GrContext on the canvas, so we were
sending errors to the default handler (SkDebugf + assert), so editing
shaders was impossible. Now they fail gracefully (and produce a popup
window with the message).

Change-Id: I29bad24f201be59ba1cec45f446a433c01cf86dc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297461
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-06-18 19:24:02 +00:00
Brian Osman
c85f1fa20f Support viewing/changing backend shaders in Viewer
Previously, all backends allowed the SkSL to be edited, and GL allowed
GLSL to be edited. Now any backend's source can be seen, and they can
all be edited (other than SPIR-V). Tested with HLSL and SPIRV. I don't
have a Mac available, but MSL should work, too.

Change-Id: Ia2a11bb5922dd49a5f25840e48384e0246a28b69
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/296856
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2020-06-16 21:03:53 +00:00
Brian Osman
9e4e4c7e97 Reland "Switch persistent cache to use SkReadBuffer/SkWriteBuffer"
These are much safer than SkReader32/SkWriter32 (they do validation and
ensure we never read past the end of the buffer).

Where we used to just assert that the contents of the cache were valid,
we now validate everything, and fail gracefully by discarding the cache
contents if it's corrupted or invalid.

Reland includes a new skipByteArray API. The previous technique for
reading into an std::string relied on data(), which doesn't return a
writeable pointer until the C++17 standard library.

Bug: skia:9402
Change-Id: I3b88efbf8ca590c8ad4f8164f7c07eee12696ec6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295441
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-06-10 14:55:37 +00:00
Mike Reed
90e82904b5 Revert "Switch persistent cache to use SkReadBuffer/SkWriteBuffer"
This reverts commit 5fa11d4040.

Reason for revert: breaking some compiles..

https://chromium-swarm.appspot.com/task?id=4cb41acadb936310

Original change's description:
> Switch persistent cache to use SkReadBuffer/SkWriteBuffer
> 
> These are much safer than SkReader32/SkWriter32 (they do validation and
> ensure we never read past the end of the buffer).
> 
> Where we used to just assert that the contents of the cache were valid,
> we now validate everything, and fail gracefully by discarding the cache
> contents if it's corrupted or invalid.
> 
> Bug: skia:9402
> Change-Id: Ib893681f97f9413c28744f11075dc2e392364db6
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294998
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

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

Change-Id: Iabea26cde82043e3f3a23cde81503ea3abdd8398
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9402
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295394
Reviewed-by: Mike Reed <reed@google.com>
2020-06-10 00:19:45 +00:00
Brian Osman
5fa11d4040 Switch persistent cache to use SkReadBuffer/SkWriteBuffer
These are much safer than SkReader32/SkWriter32 (they do validation and
ensure we never read past the end of the buffer).

Where we used to just assert that the contents of the cache were valid,
we now validate everything, and fail gracefully by discarding the cache
contents if it's corrupted or invalid.

Bug: skia:9402
Change-Id: Ib893681f97f9413c28744f11075dc2e392364db6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294998
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-06-09 22:34:03 +00:00
Florin Malita
45cd20004c [skrive] Initial artboard plumbing
"Artboards" are top-level Rive containers (similar to AE compositions),
holding the scene graphics and related animations.

Artboard properties:

  - name
  - width/height (size)
  - translation (position)
  - origin (anchor point for transforms?)
  - (background) color
  - clip contents flag

Plumb artboard parsing + background rendering, and hook into viewer.

TBR=
Change-Id: Ib188245ce41a76197cf9e0937689adf8243826d6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295244
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2020-06-09 19:58:38 +00:00
Chris Dalton
3e7d511de3 Add svg parsing to CanvasKit viewer.html
Also enables ccpr and makes flags parsing more robust.

Change-Id: Ia98467403de87423a63167681b2ee635b0fa593a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292690
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-05-28 20:39:43 +00:00
Chris Dalton
f3242c44cf Add an skp loader to CanvasKit viewer
The new loader works by checking for a "slide" flag, and if it ends in
".skp", then we treat the slide name as a URL and try to pull it in with
an HTTP request and parse it as an SkPicture.

It is the user's responsibility to copy or link skps into their
canvaskit server directory.

Change-Id: Iaafa84300d36d2d5a0bb29c47761ec67076c0f50
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292204
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2020-05-28 17:29:28 +00:00
Mike Reed
4348097fd4 tell gms when they are being run in viewer
Motivated here: https://skia-review.googlesource.com/c/skia/+/291696

Change-Id: I7388c20fafc27684d55c1493a96fc3b5ccd88bea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292314
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-05-27 21:26:58 +00:00
Mike Reed
1f60733fb3 Revert "Revert "move onto new factories for SkMatrix""
This reverts commit c80ee456ad.

fix: update flutter's gn file to add guard

Change-Id: Iac5171c8475d9a862d06255dab1c6f38f10de2f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291361
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-05-21 16:58:39 +00:00
Mike Reed
c80ee456ad Revert "move onto new factories for SkMatrix"
This reverts commit 046c2b7d90.

Reason for revert: need to update/guard flutter

Original change's description:
> move onto new factories for SkMatrix
> 
> Just rename, no functional changes expected.
> 
> Change-Id: Id77ab1cf6b1cab35087a7c56000750912cf47383
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290831
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>

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

Change-Id: Ic74f177128913374b8c60b4df88f04cf72fbacb3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291359
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-05-21 16:05:20 +00:00
Mike Reed
046c2b7d90 move onto new factories for SkMatrix
Just rename, no functional changes expected.

Change-Id: Id77ab1cf6b1cab35087a7c56000750912cf47383
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290831
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2020-05-21 15:04:09 +00:00
Florin Malita
67ff541ac1 [skottie] Add support for embedded fonts (glyph paths)
Parse embedded fonts into SkCustomTypefaces, and pass down the text
animation pipeline.  Things seem to mostly work for Latin examples.

Most existing Lottie files come with embedded fonts (the option is
enabled by default), so to minimize disruption only use the new
feature as a fallback for typefaces which cannot be resolved otherwise.

Also introduce a builder flag to prioritize embedded fonts over native
(kPreferEmbeddedFonts), and plumb in existing tools for testing.

Change-Id: Ia2a659f76e354fea6081b0f2e0dce1d8bdf63c52
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291180
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2020-05-21 01:27:34 +00:00
Brian Osman
28590d54f5 Add 'shader' as an alias for 'fragmentProcessor'
Change-Id: I2d95c63de18125e6258709b48b03abd7904b7537
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278596
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-05-15 13:52:15 +00:00
Greg Daniel
0a2464f51f Update internal skia uses to use flushAndSubmit and submit calls.
Bug: skia:10118
Change-Id: Ieb7c0eece56d3d9df56ecb52e00e76c01f038de8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289888
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2020-05-14 20:26:44 +00:00
Jim Van Verth
682a2f4de6 Add Direct3D swapchain support
Change-Id: I4d4025fb842eb937785509bc7947f85f28a98ab8
Bug: skia:9935
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288551
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2020-05-14 14:23:02 +00:00
Adlai Holler
684838f1f5 Mark SkStringPrintf as SK_PRINTF_LIKE
Change-Id: I3d2ee8dca1d2e962794ce8c3c391779bff357f0c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288762
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
2020-05-12 15:22:14 +00:00
Florin Malita
fbddfbb9f3 [skottie] Introduce an external layer API
Add support for external precomp Skottie layers.  This allows embedders
to seamlessly mix custom/Lottie content.

General flow:

  * embedders register a PrecompInterceptor callback with
    the animation builder
  * at build time, Skottie invokes the callback for each pre-composed
    layer
    - the returned ExternalLayer implementation is used instead of the
      Lottie layer payload
    - (a nullptr value signals Skottie to use the usual Lottie payload)
  * at render time, ExternalLayer::render() is called to defer content
    rendering to the embedder

Also implement a sample PrecompInterceptor which attempts to substitute
precmp layers matching a given pattern with external Lottie animations:

   precomp_name: "__foo.json"  -> Animation("foo.json")

This new mechanism is a generalization of (and supersedes) the old
NestedAnimation hack - so we can remove that.

Change-Id: Id80fe11881c62b8717c2476117c7c03ad5300eef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288130
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
2020-05-06 20:31:14 +00:00
John Stiles
5daaa7f0f9 Limit the Viewer MSAA options to the context's max sample count.
Selecting an MSAA option that the context does not support can cause
issues, so prevent those options from being displayed.

This fix was suggested by jvanverth@ during his review of
https://skia-review.googlesource.com/c/skia/+/287976

Bug: skia:10134
Change-Id: If8c35786da83e6ace336328281d7005cc75cf301
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288096
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-05-06 19:54:44 +00:00
John Stiles
31964fd155 Qualify local constant strings with static, and remove unused strings.
Change-Id: Icd317eb1b260e9640473e8a201a204a6e49bc002
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287916
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-05-06 17:36:44 +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
e42af16143 add --stats to start with the stats overlay on
Change-Id: Ibc0a47258009a24bf7d9b378c9e21729b13d0216
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286027
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2020-04-29 13:22:22 +00:00
Mike Klein
1e0884d07a add --dylib to viewer
This JIT mode helps debugging and profiling by shelling out to an
external assembler then loading its results back in via dlopen(),
so you can see coherent function profiles and not just every
instruction as its own line in the profile.

It's very slow, so viewer will stutter for a second or two before
drawing goes smooth again.  We can paper over this by using the
interpreter while these compiles are in progress, but I haven't hooked
that up yet.

Change-Id: I23e74d65a1a3a6d89649733296db8217be306438
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285864
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-04-28 20:42:49 +00:00
Brian Osman
95c26efc90 Pure SkSL RNG for particles
Change-Id: I2cb6255a553852a292427d6dc9ef8c5ed7f8286d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252926
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-04-10 17:20:07 +00:00
Tyler Denniston
31dc48138c Sort viewer slides by filename when traversing a directory.
Main motivation for this was convenience when rendering directories of
external files (e.g. --svgs) as readdir() does not guarantee any
ordering.

Change-Id: I78dced834e5a3edde4a5e8e0e65ad946c7d3a3fa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282617
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
2020-04-09 16:15:06 +00:00
Florin Malita
d532bdbc86 [svg] Adjust container size on Viewer window resize
It's nice to be able to resize the SVG container on the fly.

Change-Id: I6624e6151aaff7e2a7f6eb07e84aee88c4a2e408
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282418
Auto-Submit: Florin Malita <fmalita@chromium.org>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
2020-04-09 12:16:34 +00:00
Robert Phillips
e19babf996 Remove GrAtlasManager.h from all other .h files
Having GrAtlasManager.h in GrContextPriv.h was needlessly propagating dependence on that header.

Change-Id: Idf5836f1e217ecd2da91f751b488a63a884c02ce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281739
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-04-07 12:43:46 +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
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
Florin Malita
bb7d95f0f0 [skottie] Cleanup: relocate Animator base class out of SkSG
Decouple animator semantics from the scene graph.

No functional changes, just shuffling code around.

TBR=
Change-Id: I9a4592c424d2f8eb45b1b5f3e1f4b885cfaff9f6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279421
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2020-03-26 20:50:10 +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
Mike Reed
862818b291 add --skvm and '!' to viewer to toggle using skvm blitters
Change-Id: I71b81e89a871d9bd96534f1fb8b88fe25045685c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278417
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-03-21 19:31:11 +00:00
Brian Salomon
f4ba4ec796 Revert "Revert "Revert "Revert "Don't build GL on Metal, Vulkan, Dawn, Direct3D bots""""
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>
2020-03-20 17:11:58 +00:00
Brian Salomon
1171d314ef Revert "Revert "Revert "Don't build GL on Metal, Vulkan, Dawn, Direct3D bots"""
This reverts commit fb27c9a25f.

Revert "Remove MoltenVK support"

Reason: TSAN Vulkan bots hanging.

This reverts commit 6cafe73da9.

Change-Id: I8ec9db35c112f3c8da8636dab2065e6f18de7d0b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277936
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-03-19 13:10:59 +00:00
Brian Salomon
fb27c9a25f Revert "Revert "Don't build GL on Metal, Vulkan, Dawn, Direct3D bots""
This reverts commit 00ba5ef4a6.

Bug: skia:10051

Change-Id: I13fd5494b7e7e64159e6330f168ab8c16a2db149
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277609
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2020-03-18 18:12:11 +00:00
Brian Salomon
00ba5ef4a6 Revert "Don't build GL on Metal, Vulkan, Dawn, Direct3D bots"
This reverts commit f6784a8c84.

Reason for revert: breakage of builds

Original change's description:
> Don't build GL on Metal, Vulkan, Dawn, Direct3D bots
> 
> Misc fixes to omit GL-dependent targets and fix assumptions that
> SK_SUPPORT_GPU implies SK_GL.
> 
> Bug: skia:10051
> Change-Id: Ida88ac3f1bf4d9e23f66d0700c2bce18b938ed6f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277456
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>

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

Change-Id: I4e02f675fd8820ed3c8efee192c64e570a23c3e5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10051
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277601
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-03-18 14:42:28 +00:00
Brian Salomon
f6784a8c84 Don't build GL on Metal, Vulkan, Dawn, Direct3D bots
Misc fixes to omit GL-dependent targets and fix assumptions that
SK_SUPPORT_GPU implies SK_GL.

Bug: skia:10051
Change-Id: Ida88ac3f1bf4d9e23f66d0700c2bce18b938ed6f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277456
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2020-03-18 14:26:28 +00:00
Brian Osman
1facd5e8d1 Make persistent cache serialization safer
Add a version tag at the start, reject any cache blobs without it

Bug: chromium:1062018
Change-Id: I18bb668e6b836e1247640e9286a69a3e745babfd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277376
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-03-17 13:52:47 +00:00
Mike Reed
5929535315 add draw-via-serialize mode to viewer
'$' lets you see what the serialized version looks like. Helps diagnose
failures in dm/fm

Change-Id: I0c3acdeb6e7f170f5caeba1c0516b449eb7402ea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/276756
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2020-03-12 18:36:27 +00:00
Brian Osman
2e19af063b Revert "Move interpreter disassemble to out-of-line member of ByteCode"
This reverts commit 1b0124fec6.

Reason for revert: Check generated files bot is unhappy.

Original change's description:
> Move interpreter disassemble to out-of-line member of ByteCode
> 
> Now it returns a string (rather than just calling printf).
> 
> Adds GUI view of particle effect byte code (for fun), and fixes the
> unit tests that called ByteCodeFunction::disassemble, which wasn't
> doing anything.
> 
> Change-Id: Ide3fd933cf14832feae7ff9e0fdc1ae8f24a28d4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273878
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

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

Change-Id: I478a93769a3e1a72a339853d6d41865dba8bbe66
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275800
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-03-07 17:44:05 +00:00
Brian Osman
1b0124fec6 Move interpreter disassemble to out-of-line member of ByteCode
Now it returns a string (rather than just calling printf).

Adds GUI view of particle effect byte code (for fun), and fixes the
unit tests that called ByteCodeFunction::disassemble, which wasn't
doing anything.

Change-Id: Ide3fd933cf14832feae7ff9e0fdc1ae8f24a28d4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273878
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-03-06 22:16:11 +00:00
Brian Osman
bd4f872d69 Handle runtime effect shader errors better
- Expose shader error handler on GrBaseContextPriv
- Use that to report errors that happen during (late) SkSL conversion
- Remove various asserts. We expect these functions not to fail, but
  they absolutely can for any kind of error that gets past the first
  compile in SkRuntimeEffect::Make. We'll still make a GLSLFP, but it
  won't inject any code, so the resulting shader will *also* fail to
  compile. Injecting our own errors first gives the user a better idea
  what's actually broken.
- SkSLSlide also reports errors via the error handler now, too.

Change-Id: I4b871cdaa5e3217b042ebf000bb7474afaeab04c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275679
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-03-06 21:32:31 +00:00
Florin Malita
f0d5ea1ae7 Clip-only tiling in Viewer
Use clipping for tile isolation, instead of separate surface.

Change-Id: I8ae09ef25962fe877d54b1154ab9b5bf9a5f5a1c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271859
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2020-02-19 14:54:39 +00:00
Brian Osman
7353dc5490 Change SkSL main() from (float x, float y) to (float2 p)
Change-Id: Id046199edd63535ef07e1dfa65fbc7c0f8cefd00
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269371
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-07 20:19:13 +00:00
Brian Osman
788b91678f Remove SkTMin and SkTMax
Use std::min and std::max everywhere.

SkTPin still exists. We can't use std::clamp yet, and even when
we can, it has undefined behavior with NaN. SkTPin is written
to ensure that we return a value in the [lo, hi] range.

Change-Id: I506852a36e024ae405358d5078a872e2c77fa71e
Docs-Preview: https://skia.org/?cl=269357
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269357
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-02-07 18:40:09 +00:00
Brian Osman
87e3bef6f8 Reland "Switch runtime SkSL to always sample at explicit coords"
This reverts commit d4bf54eac6.

Change-Id: I65bfea4d880de29394e25d44d781fd18508fe337
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266942
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-07 14:39:29 +00:00
Brian Osman
aba642c6ac Remove SkScalarClampMax and SkScalarPin
Change-Id: Ic96a0ea2cd1bfd59ee3f236543e1d6dd102544ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269142
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-02-06 18:29:51 +00:00
Brian Salomon
d4bf54eac6 Revert "Switch runtime SkSL to always sample at explicit coords"
This reverts commit b1e9971eb7.

Reason for revert: crbug_905548 GM drawing incorrect
before: https://gold.skia.org/img/images/32964364a8ac12af5a68bf95c24fb90c.png
after : https://gold.skia.org/img/images/0918b58c93c770c20cf475c37a70b528.png

Original change's description:
> Switch runtime SkSL to always sample at explicit coords
> 
> Change-Id: I4647d0f4a098acf399e1add1d87ca0752d0fdf90
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266381
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

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

Change-Id: I0fb892148a424d5928878a49e3ccd5bfb9485b23
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266840
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-01-27 17:50:56 +00:00
Brian Osman
b1e9971eb7 Switch runtime SkSL to always sample at explicit coords
Change-Id: I4647d0f4a098acf399e1add1d87ca0752d0fdf90
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266381
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-01-27 15:31:05 +00:00
Brian Osman
f72deddb89 Expose the Input variable and Child name collections in SkRuntimeEffect
Add framework for unit tests that draw (CPU and GPU) with a runtime
shader, as well as couple example tests.

Change-Id: I43b3b39e86634ec55521a2689a4c55c21939dce5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262809
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-01-08 19:23:13 +00:00
Chris Dalton
b832ce61ee Add a path renderer that uses GPU tessellation
Implements a simple first pass for a path renderer that uses the
classic Red Book "stencil then cover" method, and linearizes curves
with GPU tessellation shaders.

The new path renderer is disabled by default, and can only be enabled
in the viewer UI or by passing the "--pr gtess" flag.

Change-Id: Ic9354952e93c8b108577961760b4f0daa82d35aa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261715
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-01-07 20:00:22 +00:00
Chris Dalton
c887733740 Add a commandline flag to force offscreen rendering in viewer
Change-Id: I0d6dd3625a8571c09af7557b1727812bba2a9ee4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262355
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-01-06 17:28:23 +00:00
Brian Osman
ee426f223f Move SkRuntimeEffect.h to include/effects
Change-Id: I0b11d4210c6e663cfb4854fc33e1396fd79fe9a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261780
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-01-02 17:37:46 +00:00
Chris Dalton
37ae4b06e2 Rename GpuPathRenderers::kAll to kDefault
There was never a need to distinguish between "all" and "default".
We can just use kDefalut everywhere. And as we add new path renderers,
we can exclude them from kDefault until they are ready to ship.

Change-Id: I378aa1e195d40daef6a2c54f9c8e829208780ebe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261714
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-12-31 01:01:17 +00:00
Brian Osman
107c66669d Make it safe to include SkRuntimeEffect.h from client code
Bundling the pipeline stage arguments also simplifies the code in
several spots.

Change-Id: I85e81b436a39378f753cc9404b6eeb27fe055525
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261778
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-12-30 21:06:56 +00:00
Chris Dalton
5258623d82 Move --internalSamples to common flags
Change-Id: I3120ca817f5fe3dc5969b6b875473f38c2fb8ea2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261667
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-12-27 22:00:10 +00:00
Brian Osman
93de162dc2 Add SkRuntimeEffect::makeShader
This makes the effect *be* the factory, so we can get rid of
SkRuntimeShaderFactory (and later, SkColorFilterFactory).

Change-Id: I2cd95f1380a0ec1e65fe5a18b1226c042598a8bd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261439
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-12-27 21:50:20 +00:00
Brian Osman
088913a63b Start adding unit tests of SkRuntimeEffect
- Change SkRuntimeEffect::Make so *it* can fail, and returns
  [Effect, ErrorText].
- Initial tests just test for expected failure conditions.
  Next steps are to add tests for effects that should work,
  and to validate results on CPU and GPU.

Change-Id: Ibac8c3046104577434034263e9e4a4b177e89129
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261095
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-12-20 14:15:06 +00:00
Brian Osman
173e153552 Runtime SkSL: API sketch for child shaders/effects
Only works on GPU backend for now, and still only supports
single-argument sample (at original coords).

Change-Id: I4c36ebd0c370ca65126786802c5ea268c3f32edd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260899
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-12-19 14:40:17 +00:00
Brian Osman
d927bd246d Runtime SkSL: Reflect inputs in SkRuntimeEffect
Adds a new structure to describe the inputs, including type,
shape, name, etc. This removes any references to the type
variables in the compiler's context, and centralizes the
logic for parsing those type variables.

Also normalizes the rules for what types are supported.
(This was inconsistent among the various functions before).

Now:
  - bool and int must be 'in'
  - float may be 'in' or 'uniform'
  - float[2-4] and matrices must be 'uniform'

Includes a new Slide that allows for interactive editing
of a runtime shader.

Change-Id: Ic2af68a80c8bb645ba96417c430da24de0a9c2d8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260497
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-12-18 17:37:55 +00:00
Chris Dalton
1215cda5a2 Add a kWireframe flag to GrPipeline
Adds the flag to GrPipeline, as well as a 'w' keystroke in viewer for
toggling the alternate global wireframe mode.

Change-Id: I385c31320a5fa2cec79b527a91fa876b19cdff89
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260747
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-12-18 15:55:54 +00:00
Chris Dalton
77912983a3 Include line numbers in Viewer's shader error windows
Change-Id: I83bea6e9c94431afba858b0e7b60456e8f9a2176
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260356
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-12-16 19:08:11 +00:00
Mike Klein
f46d5ca492 use std::make_unique
Change-Id: I7c672ff6b8eb95ec8c1123a5bfdb202e1644f494
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259281
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-12-12 22:32:45 +00:00
Florin Malita
1bb3a6dae5 [skottie] Add SkottieSlide frame rate UI option
Also store fTimeBase as a double/ns, since uint/ms doesn't have enough
precision when setting progress manually.

Change-Id: Ic01a55cea5897dd8b43d2d54f4a98e08e7406af8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259172
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-12-11 22:40:42 +00:00
Florin Malita
15ee970d79 [skottie] Add frame time histogram to SkottieSlide UI
Ignoring GPU flush for now...

Change-Id: Ie28718ee528ac3f708c0237472845b3cca47f97d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259160
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-12-10 19:57:58 +00:00
Florin Malita
c4f6e024ca [skottie] Initial SkottieSlide UI
- reveal on hover over lower region
 - live progress bar

Planning to add more features.

Change-Id: I776d5b525070c8894ae2ca3a9d9d7c407399b9e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259158
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-12-10 19:08:34 +00:00
Florin Malita
870374825b [skottie] Explicit seek(0) in tools
With recent deferred image loading changes, Skottie relies on clients
to always/explicitly seek() before drawing a frame.

Some of the existing tools are still attempt to draw before the first
seek() fires (the animation callback is not guaranteed to occur before
the first draw).  For these, add an explicit seek(0) after loading the
animation, to ensure valid state.

TBR=
Change-Id: Ie453559af2d96560602b5e6508c25169dffb484d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258805
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-12-09 16:35:02 +00:00
Brian Osman
ffbfd1bc78 Particles: Remove play-position thing, simplify mouse tracking
Change-Id: I36ce78ee1de8096d9aa164444e8af31b3831a3ab
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258217
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-12-05 20:07:13 +00:00
Brian Osman
9dac0d8216 Particles: Better integration for ResourceProvider
This untangles some of the dirty state tracking and dynamic rebuilding
support (that's only needed for the GUI editor), so the core code is
more streamlined. It also paves the way for feeding the RP to bindings.

Change-Id: I208ec59622154fdb2845c3ae8f7efb070d1abfc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257476
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-12-03 14:12:50 +00:00
Brian Osman
d12f2786e2 Use ResourceProvider in particles
Currently just for image drawable, but going to use this for
references to other kinds of data in bindings, too.

Change-Id: Ic6673530013337bbaadd2d3f1c040626ec24ffb8
Bug: skia:9513
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256776
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2019-11-27 16:45:23 +00:00
Brian Osman
849f4d6571 Copy SkottieUtils' classes into skresources
For now, we'll have two copies. Once clients are using the skresources
versions exclusively, we can remove the originals from skottie.

Change-Id: I3152f526b0505b8374bdd9b4513a80bddc702ccc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256416
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2019-11-26 14:25:44 +00:00
Jim Van Verth
7b55818248 Add flag to Viewer to trigger continuous redraw.
Change-Id: I71059001567b39afc486a2f099efdffde42b0d1b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254681
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-11-15 13:46:50 +00:00
Florin Malita
cfbc4d496d [skottie] Add DataURI image support in utils/tools
BodyMovin can export inline (dataURI) images.

Change-Id: I821a2e225359f8ac37d4d2c9479d4ff5d78f924e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249516
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-10-21 18:02:39 +00:00
Brian Osman
5b43113e75 Interpreter: Reflect all uniform variables in ByteCode
Gives enough information to locate variables by name (using the same
scheme as glGetUniformLocation), and provide hints about type and size.

Bug: skia:9513
Change-Id: I9444f1042471967a79c9f05167dcdb78eca41bad
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244502
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-10-16 15:35:48 +00:00
Brian Osman
df18296f98 Add accessors to get/set SkParticleEffect fields
Simplify burst handling. Scripts should just add to burst (if
they want to handle programmatic bursting, as well).

Update most effects to handle dynamic updates to position better,
and add a sample effect meant to be used with mouse tracking.

Change-Id: Ia302e1d04e62e2b07974807c44067786cc10a8ad
Bug: skia:9513
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248798
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-10-15 14:54:50 +00:00
Brian Osman
647c7a97d3 Particles: New confetti effect, minor tweaks elsewhere
Confetti mimics the look of a standard skottie asset

Change-Id: Iffeedeb24182c4ac2d3ec390614bc1861b821376
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/246518
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-10-07 14:06:56 +00:00
Brian Osman
4524e84a74 When precompiling SkSL, avoid the need to re-link
Adds metadata to the SkSL blobs about attributes (and other resources)
so that we can do all necessary work during precompile.

Change-Id: I1846c6c96946d5a43a48112d062853717a6571a0
Bug: skia:9402
Bug: b/140174804
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/243739
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-09-24 20:32:32 +00:00
Brian Salomon
8391bac5c6 Add F16Norm mode to viewer
Change-Id: If7b84731bce9ba8f1034c974fc7852ee304b499d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242478
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2019-09-18 17:04:56 +00:00
Brian Osman
d46cb9729b Particle effect scripting update
This change adds another layer of complexity and control to
the particle system. There are now two code chunks: the old
code that's run per-particle, and new code that's run for
the effect itself. This allows for effect lifetime to be set
by the script (eg, randomly), as well as the emission rate.
Rate can vary over time (see pulse.json), and particles can
be emitted in bursts by setting the effect's burst field
(see fireworks.json).

Additionally, the effect has its own frame of reference and
color, which becomes the default state for newly emitted
particles. This allows synchronizing state across particles
in various interesting ways (see color in fireworks.json).

Change-Id: Iec2f7a3427ce1d6411ed7ef5b3023cbef2e8a134
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/240498
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-09-16 17:48:04 +00:00
Jim Van Verth
d0cf5da20d Hook up pinch-zoom and swipe gestures.
Sets UIPinchGestureRecognizer and UISwipeGestureRecognizers and
passes the result down to the sk_app::Window. To simplify detection,
swipes take precedence over pans, and pans require a single touch.
This is less flexible for the app, but in most cases I think is
what we want.

Bug: skia:8737
Change-Id: Ib031b6ad465d3a353da29d7e0b48a666d4ff8b9a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/239776
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-09-10 13:34:47 +00:00
Brian Osman
ed58e004e0 Add support for pre-compiling cached SkSL shaders
The client can do a test run of their application with
a persistent cache set to SkSL mode. They store the key
and data blobs that are produced.

Ship those blobs with the application. At startup, call
GrContext::precompileShader for each key/data pair. This
compiles the shaders, and stores the GL program ID, plus
a small amount of metadata in our runtime program cache.

Caveats:
* Currently only implemented for the GL backend. Other
  backends will require more metadata to do any useful
  amount of work. Metal may need a more drastic workflow
  change, involving offline compilation of the shaders.
* Currently only implemented for cached SkSL (not GLSL
  or program binaries). Supporting other formats again
  requires more metadata, and the cached shaders become
  increasingly specialized to GPU and driver versions.
* Reusing the cached SkSL on different hardware is not
  supported. Many driver workarounds are implemented in
  the SkSL -> GLSL transformation, but some are higher
  level. Limiting device variance by artificially hiding
  extensions may help, but there are no guarantees.

* The 'gltestprecompile' DM config exercises this code
  similarly to 'gltestpersistentcache', ensuring that
  results are visually identical when precompiling, and
  that no cache misses occur after precompiling.

Change-Id: Id314c5d5f5a58fe503a0505a613bd4a540cc3589
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/239438
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-09-06 19:45:09 +00:00
Brian Osman
a66081d943 Move SkSL caching out of GR_TEST_UTILS, trim persistent cache options
Combines the two boolean options into a single tri-state enum. Old GLSL
option is still present (temporarily) until Chrome is switched over.

Also add a type tag for cached program binaries, so we can safely
detect cache entries of the wrong type.

Change-Id: I0ddeefa9180b27bc2c46e2e7b77e6c9cdf4a730a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238856
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-09-03 20:18:48 +00:00
Jim Van Verth
e58d532bc3 Get Metal running on iOS viewer.
Adds MetalWindowContext_ios and hooks it up to Window_ios.
Also includes some minor clean up in other iOS code.

Bug: skia:8737
Change-Id: I2e8a0c755310fbc4ed534f975815c60f8eca130b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238438
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-09-03 14:07:39 +00:00
Brian Osman
2aa85df8e7 Particle cleanup: split SkParticleBinding out of SkParticleEffect
Also simplify type registration.

Change-Id: Ia47febb2ae2cd5821476c3dd33a688b688aa6d6d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238359
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-08-30 15:32:38 +00:00
Hal Canary
b1f411ac05 tools/skui: put all enums in a common namespace
Change-Id: Icd331e8946d80652750b8b6ea0db65f5f676ac3e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238058
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2019-08-29 15:39:32 +00:00
Ben Wagner
54aa8846e9 Add test for baseline snapping.
Change-Id: I895218ba087d2f04ee92bc6eaaaad780723a9202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/237803
Auto-Submit: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-08-28 16:35:55 +00:00
Ben Wagner
c17de1d2b7 Add a way to disable baseline snapping.
Skia has traditionally snapped horizontal and vertical baslines to
pixels as a kind of baseline hinting. This is a feature which cannot
reliably be implemented from the outside and tends to make static text
better looking by ensuring the baselines are consistent. However, with
animation like scrolling or flying and resizing text the animation
suffers. Allow the user to disable the baseline snapping.

Change-Id: I6ee1c12a07242d10c08ae4b75c73e4e28c860790
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/237124
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-08-27 19:54:29 +00:00
Ben Wagner
406ff500a4 Clean up some gm factory use.
Mostly use unique_ptr more consistently.

Change-Id: I6e11b272a7904eb662dea59b03fbc309a4cfc25d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233984
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2019-08-13 15:57:37 +00:00
Hal Canary
edda5653e1 gm: GMFactory returns a unique_ptr<>
Change-Id: If8a4d3cfdeaef58dd9924af430cfed834519b096
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/232496
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2019-08-12 19:02:40 +00:00
Hal Canary
bcfed55a8c experimental/editor: mouse drag select, modifierkeys cleanup.
Change-Id: I8c8de54ad6309424bdf18987ccf3eac6bdd41c19
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233080
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-08-08 02:33:44 +00:00
Stephen White
a800ec96f7 Dawn: implement sk_app window contexts for all backends.
Implement Window contexts for D3D12, Metal and Vulkan, as well as
a base class for all of them (DawnWindowContext).
Implement WSI, swap chains and external textures for all backends.
Add Dawn support to Viewer app.

Change-Id: I9368eae8d43594821aa1edd9fd559c8a9ba30066
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/228060
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2019-08-02 19:51:02 +00:00
Brian Osman
fe49163cd1 Major rewrite of the particle system based on the SkSL interpreter
This removes all of the fixed-function particle affector classes.
Instead, each particle effect just has two SkSL snippets, one for
spawn logic, and one for update logic. Each one gets an inout copy
of the particle struct. Ultimately, this makes the effects much
simpler and smaller, while also being far more flexible (you can
do whatever you want with any values you want). Finally, because
the interpreter is vectorized and a particular effect's scripts
are usually tuned to the specific behaviors desired, it's faster
on basically every effect I compared.

I re-created all of the old effects in the new system. Many just
use pure SkSL (no curves or anything). Some of the old curve and
path/text stuff was very handy, though - so those are now exposed
as external values in the interpreter. Basically, an effect can
have any number of named "bindings" that are a callable thing.
This can be a path, text (shortcut for making fancy paths), curve,
or color curve. The path ones return a float4 with position and
normal, the curves return one or four floats.

... and this transposes all of the particle data storage into
SoA form, so that it can use the much faster interpreter entry
point.

Change-Id: Iebe711c45994c4201041b12d171af976bc5e758e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/222057
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2019-07-25 19:59:03 +00:00
Florin Malita
5f240186ec [skottie] Ref-counted animators
Change-Id: I022c655c3f72551ccf6d35ba013fba6461e89a5c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229389
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-07-23 22:40:14 +00:00
Mike Reed
f702ed495e add 'r'epeat option sans the HUD (to not complicate the profile)
Change-Id: Ia95f2b2b86c83b1715dc46b07baa2fc547abdee3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229081
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
2019-07-23 00:20:07 +00:00
Florin Malita
00d4f535c9 [skottie] Expose SG inval controller on seek()
- shift the revalidation phase from Scene::render() to Scene::animate()
 - pass an optional inval controller to Scene::animate() and Animation::seek()
 - hoist the showInval logic out of SkSG, into clients

This allows clients to track dirty regions and detect cases where no updates are needed.

Bug: skia:9267
Change-Id: I3d35bf58b6eee9bfeb6e127ba58e2b96713b772d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229001
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
2019-07-22 16:33:15 +00:00
Chris Dalton
c3318f09cd ccpr: Add an MSAA atlas mode
Adds the option to use a multisampled (or mixed sampled) atlas, and
uses the sample mask and stencil buffer instead of coverage counts.

Bug: skia:
Change-Id: I9fb76d17895ae25208124f6c27e37977ac31b5eb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/227428
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-07-19 20:52:17 +00:00
Hal Canary
ff2e8fe65f sk_app, Sample: Unify InputState enum.
replace() {
      if git grep -q "$1")";
      then sed -i -e "s#${1}#${2}#g" $(git grep -l "$1");
      fi
    }
    replace 'k\([A-Za-z]*\)_InputState' 'InputState::k\1'
    replace '\(\(sk_app::\|\)Window\|Sample\|\)::InputState' 'InputState'

Change-Id: I4cc18814fb1fbdd1f240aabba05aae79c54a4841
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/227642
Commit-Queue: Hal Canary <halcanary@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-07-16 14:51:03 +00:00
Hal Canary
fcf6359ce8 Sample not RefCnted; ClickHandling moved out of viewer
Change-Id: I23456144b267192928a1253692daf846329f2ab5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/227067
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2019-07-15 17:59:15 +00:00
Hal Canary
41248071ac tools: separate TimeUtils from AnimTimer
gm, slides, and samples no longer need to know about the implementation
details of AnimTimer.

This
    virtual bool onAnimate(const AnimTimer&);
becomes this:
    virtual bool onAnimate(double /*nanoseconds*/);
which is much easier to reason about.

AnimTimer itself is now part of viewer.

Change-Id: Ib70bf7a0798b1991f25204ae84f70463cdbeb358
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/226838
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2019-07-12 15:05:01 +00:00
Hal Canary
3a85ed12bf ModifierKey unifies sk_app::Window::ModifierKey & Sample::Click::ModifierKey
Change-Id: Idb5dfe57a7f6e3d6078ab1e68d542b084114cfbe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225735
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-07-09 16:16:41 +00:00
Hal Canary
c74a55057b GM: s/handleKey/onChar/
Change-Id: I917de2705807f61e6a6c3f76d52e290e8194d204
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225936
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-07-08 22:28:50 +00:00
Hal Canary
6cc65e1fda Samples: simplify Sample::Event
Change-Id: I1daaa9dcf56812bfd29dab64ee04dae63c2660e1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225545
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-07-08 19:09:42 +00:00
Hal Canary
8a027312cd Samples: add name() virtual
Change-Id: I9b6e39bc7e35346bb73dfe014de1c8daa5a92f2a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225428
Auto-Submit: Hal Canary <halcanary@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-07-03 17:41:16 +00:00
Chris Dalton
a1638a527e Rename "preferredInternalSampleCount" to "internalMultisampleCount"
Bug: skia:
Change-Id: If6e0287b3d631f4f3856875d94c84d1ddea44f22
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223279
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-06-24 19:40:12 +00:00
Chris Dalton
1e6c5b8dee Add a "preferredInternalSampleCount" cap
This new cap tells Ganesh how many samples to use when performing
internal draws with MSAA or mixed samples. The default is always 4x,
but the client can change that with
GrContextOptions::fPreferredInternalMSAASampleCount.

Also adds a command line flag to viewer to control
fPreferredInternalMSAASampleCount.

Bug: skia:
Change-Id: Iba369273e802aa1bee796b576b3c18af347b0494
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221156
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-06-17 23:47:59 +00:00
Brian Osman
072e6fc374 Remove version string from Viewer's "highlight" SkSL shader
Change-Id: Id61b7b9d9bc7611727a27be0172fcabc2ef4345a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/220522
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2019-06-12 16:03:36 +00:00
Brian Osman
c6568afa0b Remove Nima from DEPS, experiments, Viewer, etc.
Change-Id: Ide69d3c9f0f02e886bd0d52723d425a548edd2e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214187
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-05-16 17:02:11 +00:00
Brian Osman
32d2490c43 Use better widget for multiline strings in particle GUI
Change-Id: I3ffc7736d96cd95c171b8f421ccd79d0055a983d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212725
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-05-08 19:32:57 +00:00
Ben Wagner
5785e4a165 Use SkFontHinting instead of macros.
Change-Id: Ie7f231295c27010f53f09e9879aa7df74ab2d09b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212507
Auto-Submit: Ben Wagner <bungeman@google.com>
Reviewed-by: Hal Canary <halcanary@skia.org>
Commit-Queue: Ben Wagner <bungeman@google.com>
2019-05-08 12:16:37 +00:00
Brian Osman
5bee390667 Viewer: Fixes for shader editing in ANGLE
- Include default precision in viewer's highlight shader when needed
- Flush cache when switching backends. Fixes issues between (eg) GL
  and ANGLE where shader caps are different.

Change-Id: I80bc9fb56fdab49fdbe2e858db7398a5471048c6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212194
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2019-05-07 14:29:15 +00:00
Brian Osman
5e7fbfd9b0 Add ShaderErrorHandler to GrContextOptions
Allows clients to customize behavior when shaders fail to compile.
Added nicer shader error handling to viewer.

Change-Id: If82b48e40d64fd786f37e88c564fd623b53c7f9d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/211361
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-05-06 16:29:13 +00:00
Brian Osman
fd7657cba2 Add SkSL editing to Viewer in Vulkan backend
Change-Id: Ic328dc9f16a1f1aa27306321f5a53b587c14fa21
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/210221
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-04-25 16:57:59 +00:00
Brian Osman
a085a41b9d Normalize storage of shader strings in the cache
Adds a tag that can be used to verify the expected type
of shaders. My follow-up CL that adds SkSL editing to
Vulkan relies heavily on this.

Change-Id: Ifda420c2dcbaff07cdf1b8157d0ece02b1ab6c78
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/210262
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-04-25 15:27:59 +00:00
Mike Klein
c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00
Brian Osman
cbc33b8e35 Add SkSL viewing/editing to viewer
Still only works with the GL backend. For other backends,
need to add similar logic to the shader caching, and some
extra checks in Viewer to force the SkSL flag on.

But in GL, this lets you toggle the checkbox and see the
SkSL / GLSL at will (and edit in either form).

Change-Id: I6d392113aa9cbcbd6e64589b849de70d0ac3beeb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209165
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-04-22 13:57:02 +00:00
Brian Osman
0b8bb88cbb GLSL editing in Viewer
When in GL backend, adds a "Shaders" section to the debug menu.
"Load" scrapes all of the vertex and fragment shaders being used,
then displays them. They can be edited, and "Save" pushes the
results.

Note: It is trivial to trigger an assert by saving a shader that
doesn't compile. I'd like to make the program builder more robust
in a follow-up CL, to fall back to the "real" SkSL, not draw, or
something along those lines.

Change-Id: I841fe2ee76a3c2eae58b64ef587fcbe25b95cc7e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206905
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-04-12 16:23:54 +00:00
Ben Wagner
f55fa0d0cf Make SkPaintFilterCanvas paints no longer COW.
The two existing external users of SkPaintFilterCanvas always end up
making a copy of the paint when the canvas is in use. As a result, the
extra overhead of doing COW is being wasted. In general, it seems easier
for users to optimize by simply not using the filter canvas when it
won't be making any changes. Also, no users are using the 'Type'.

After users are updated to this new API, the old onFilter can be
removed.

Change-Id: Iee1ce3cd22bce8c00664de078375b105abd7c866
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/149806
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2019-04-11 22:42:13 +00:00
Chris Dalton
a8fbeba6cb Add a cap to allow coverage counting or not
We don't want to just disable the "ccpr" path renderer anymore (or
whatever it should be called), because we are adding an MSAA
implementation. This new cap will eventually tell ccpr whether it can
use coverage counting, or if it should just use the MSAA impl.

Bug: skia:
Change-Id: Ie6e5ca1a637ca4408bc6bb844153afa9da26f58e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/204883
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-04-03 19:39:24 +00:00
Florin Malita
fb4bce8322 [sksg] Refactor gradient implementation
Currently, gradients are PaintNode subclasses - which limits their
applicability to leaf DAG nodes.

In order to support generalized gradient/shader effects:

  * introduce a new Shader base class
  * refactor gradients as Shader subclasses
  * introduce ShaderPaint (to support current Gradient-as-paint use)
  * introduce ShaderEffect (to support future Gradient-as-effect use)

Tangentially:

  * rename SkSGPaintNode.h -> SkSGPaint.h
  * consolidate sksg::Color into SkSGPaint.h

Change-Id: I94ba949f4504c09cfde4a4f030d927411fdd66a2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/205263
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-04-01 18:43:43 +00:00
Greg Daniel
d0794cccd0 Add support for vsync on android viewer.
Bug: skia:
Change-Id: Idcb3e3b0a67c2da65c99c597686cb55961142a38
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/204263
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2019-03-27 20:57:01 +00:00
Greg Daniel
bb792aae8c Add option to disable vsync on viewer unix.
This also fixes an issue where vulkan would crash any time we change a
display param on unix.

Bug: skia:
Change-Id: Ic6c3843e04bc77c2e9c5301ee38fcc58a409495d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203380
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2019-03-25 18:24:29 +00:00
Mike Klein
c6142d855c de-common the rest of the flags
Turns out lots of tools had two copies of many of these flags.

Some GN and .cpp file refactoring to make sure when flags are
present in a binary, they do something in that binary.

I think this finally finishes the flag refrag.

Change-Id: I01488e37ab73a5c4361786863ddb137a7f1095b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203420
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-25 17:39:58 +00:00
Ben Wagner
110c703b5d Move fontmgr_bounds label setting to checkbox.
The fontmgr_bounds gm has an option to show the name of the font and the
glyph ids of the glyphs with extreme bounds. This was previously done
with a command line flag label_fontmgr_bounds. However, this information
is generally only useful in the viewer application, so change this to a
control.

This also adds bool field handling in viewer.

Change-Id: Idbdbb08e9516ec49a96f9baa320acd6fe44e95ca
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203175
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2019-03-23 14:37:59 +00:00
Mike Klein
19cc0f647c create a wrapper to manage --nativeFonts and --gdi
Put it in ToolUtils to avoid cyclic dependencies.

Change-Id: Ie0ad7eb5d1ba58be5ad8c668afdb7c74facd71dc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203181
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-22 21:06:29 +00:00
Mike Klein
4932a5efa8 Fold CommonFlagsGpu into CommonFlags
This scopes a bunch of flags more tightly
to SetCtxOptionsFromCommonFlags().

Change-Id: I6090a016880c085fb5405a45081c0af984a1cd5b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203094
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-22 18:01:13 +00:00
Mike Klein
e5acd7547b delete DAA
Change-Id: I1fd8cba067c0063c6621641e8196e69fd5e31cec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203080
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-22 15:44:03 +00:00
Ben Wagner
cc8eb86c37 Make zoom in viewer exponential.
The previous linear zoom fits into about -2 to 2 in the new system. By
keeping the old linear values (instead of making the slider exponential)
the up and down keys can still be used to get away from and back to no
zoom. The new zoom allows for a much larger range of zoom, allowing more
issues to be seen.

Change-Id: I9ba8cf2c3c8d610a21a8c8598e0f5150eeb04ad8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202940
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2019-03-21 21:30:49 +00:00
Greg Daniel
655002b8b0 In viewer measure and show full frame times.
This updates viewer to show the full frametime including getting new buffers
and presenting buffers to the screen. This is more useful information than
simply the sum the flush and paint.

In a follow up CL we'll enable disabling vsync so we can truly measure how
long it takes us to draw.

Bug: skia:
Change-Id: Ibdbf16b37b44309fca6e771272ce38fd31a0e95c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202708
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2019-03-21 19:30:06 +00:00
Mike Klein
19fb3971bc de-common some flags
Move flags used only in one place to that place,
and remove a couple unused flags.

Change-Id: I0504d9583d464377e84ab28ce378d6da1e99ac3e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202802
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-21 18:55:34 +00:00
Ben Wagner
15a8d57175 Add font scale and skew in x to viewer.
Also change the names of some fields to remove the now redundant 'Text'
specification to make things fit on lines.

Change-Id: I4503eebaea406e82a1332dade0b6aea7dddf281f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202709
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2019-03-21 18:22:28 +00:00
Mike Klein
5b3f343d25 DEFINE_int32 + DEFINE_uint32 -> DEFINE_int
There's really no big benefit to distinguishing these.

Change-Id: Ib329d32b1fc43e98ba40658cfea37261203ecdb9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202801
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-21 17:20:19 +00:00
Mike Klein
84836b799a moar static flags
Like any normal variable, flags can be made file-scoped static,
and like any normal variable, mostly they should be if they can.

This CL converts most flags to be static, if only so that the
ones that do cross files stand out more clearly, and so that
there's more examples of static flags through the codebase for
people to ape.

Change-Id: Ibb5ddd7aa09fce073d0996ac3ef0487b078b7d79
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202800
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-21 17:07:13 +00:00
Mike Klein
eb678fcc1f de-Sk tools/trace
Kept it on SkDebugfTracer, which seemed to parse as "SkDebugf, Tracer".

Change-Id: I3e43fe101798ca5ffe14324e3c29f2dd41a6bd0f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202317
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-20 18:27:27 +00:00
Mike Klein
cd5104e942 SkAnimTimer -> AnimTimer
Change-Id: I700b7c0461475062ac66712cc29070f150cf777d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202315
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-20 18:26:35 +00:00
Mike Klein
ea3f014e2b sk_tool_utils -> ToolUtils, and git clang-format
sk_tool_utils doesn't really fit the naming convention
the rest of code under tools/ tends to use.

Change-Id: I45326a174101c6eb4b6149e9c742f658f2fd23b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202313
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-20 18:05:42 +00:00
Mike Klein
0cffcbf97b de-Sk tools/font, and git clang-format
Change-Id: I0326eb9cc1e1e38b0fdc417567987a595f9021d2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202310
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-20 17:36:52 +00:00
Mike Klein
88544fbe63 remove Sk prefix from CommandLineFlags
The command line flag package is tool-only, not part of Skia per se,
and does not need an Sk prefix to avoid naming conflicts.

And git clang-format.

Change-Id: Ida8477779e51750ed0475590ed2454841b23d6ea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202307
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-03-20 17:13:22 +00:00
Chris Dalton
f774818f57 Reland "Disable coverage counting by default"
This reverts commit 9ff956e6de.

Reason for revert: Will fix the issues with the change landed.

Original change's description:
> Revert "Disable coverage counting by default"
> 
> This reverts commit 576b2a5596.
> 
> Reason for revert: DDL and MSRTC unhappy
> 
> Original change's description:
> > Disable coverage counting by default
> > 
> > Bug: skia:
> > Change-Id: Iacb4cb3e409c6abdd25319ec0884ef673fb04cec
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201101
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Chris Dalton <csmartdalton@google.com>
> 
> TBR=djsollen@google.com,bsalomon@google.com,csmartdalton@google.com
> 
> Change-Id: Iabdb3116d97c7470044b962ff78cffd47ccee744
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201933
> Reviewed-by: Chris Dalton <csmartdalton@google.com>
> Commit-Queue: Chris Dalton <csmartdalton@google.com>

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

Change-Id: I1d81f7a52e81079bd232e97588fd34729a8f50cd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201938
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-03-18 16:22:47 +00:00
Chris Dalton
9ff956e6de Revert "Disable coverage counting by default"
This reverts commit 576b2a5596.

Reason for revert: DDL and MSRTC unhappy

Original change's description:
> Disable coverage counting by default
> 
> Bug: skia:
> Change-Id: Iacb4cb3e409c6abdd25319ec0884ef673fb04cec
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201101
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Chris Dalton <csmartdalton@google.com>

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

Change-Id: Iabdb3116d97c7470044b962ff78cffd47ccee744
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201933
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-03-18 15:59:47 +00:00
Chris Dalton
576b2a5596 Disable coverage counting by default
Bug: skia:
Change-Id: Iacb4cb3e409c6abdd25319ec0884ef673fb04cec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201101
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2019-03-17 23:54:24 +00:00
Mike Reed
376d8128f0 Use '&' to toggle showing the gm's size in viewer
Bug: skia:
Change-Id: Id294b6a48d60d95b46ce3443edf10513599c43d1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201230
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
2019-03-14 16:11:46 +00:00