Commit Graph

551 Commits

Author SHA1 Message Date
John Stiles
7571f9e490 Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'.
Mechanically updated via Xcode "Replace Regular Expression":

  typedef (.*) INHERITED;
    -->
  using INHERITED = $1;

The ClangTidy approach generated an even larger CL which would have
required a significant amount of hand-tweaking to be usable.

Change-Id: I671dc9d9efdf6d60151325c8d4d13fad7e10a15b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314999
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-03 03:41:26 +00:00
Adlai Holler
bcfc554fde Add GrDirectContext arg to SkImage::readPixels
Note: The polarity of the staging flag is inverted from usual because
a G3 dependency with no SkUserConfig.h relies on the legacy API.

Once this lands, we will migrate them and others, then remove the
staging API. The inverted staging flag is kind of nice, actually - I may
use that pattern in the future. It means less total CLs and it's just as
easy to flip the bit on or off during debugging.

Bug: skia:104662
Change-Id: I48cba1eeae3e2e6f79918c6d243e0666e68ec71b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310656
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
2020-08-27 19:26:29 +00:00
Brian Osman
767f444feb SkRuntimeEffect SkSL has a new signature for main()
There is no more 'inout half4 color'. Effects return their output color.
If an effect wants the input color, it must use the (already existing)
approach of sampling a nullptr input shader.

The change is guarded for Chromium (so we can update their runtime color
filters in skia_renderer.cc).

For the GPU backend, FPs can now override usesExplicitReturn to indicate
that their emitCode will generate a return statement. If that's true,
then writeProcessorFunction doesn't inject the automatic return of the
output color, and emitFragProc will *always* wrap that FP in a helper
function, even as a top-level FP. GrSkSLFP opts in to this behavior, so
that the user-supplied return becomes the actual return in the FP's
emitCode.

Adapting the skvm code to this wasn't too bad: It looks fragile (what
happens if there are multiple returns?), but that's not really possible
today, without varying control flow.

Bug: skia:10613

Change-Id: I205b81fd87dd32bab30b6d6d5fc78853485da036
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310756
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-08-25 13:36:28 +00:00
Brian Osman
eb3fb90675 Tweak viewer's shader panel
Base the box size on the shader length (within reason).

Change-Id: If847cb4de0cea3cb2267f284fd5bbb653f25e185
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311455
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-08-18 17:44:35 +00:00
John Stiles
a008b0fa8b Enable ClangTidy check readability-redundant-smartptr-get.
To my surprise, this even works with homegrown smart pointers (such as
SkTLazy).

https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-smartptr-get.html

Find and remove redundant calls to smart pointer’s .get() method.

Examples:

  ptr.get()->Foo()  ==>  ptr->Foo()
  *ptr.get()  ==>  *ptr
  *ptr->get()  ==>  **ptr
  if (ptr.get() == nullptr) ... => if (ptr == nullptr) ...

Change-Id: I8ff541e0229656b4d8e875c8053a7e6138302547
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310976
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-08-16 15:56:48 +00:00
Florin Malita
c9c4e2e9ef Componentize SkAudioPlayer
Relocate under modules/audioplayer and package as a standalone
component.

Change-Id: If9dc72bb0abe170049a514c9931186703a3c138a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310058
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-08-14 13:46:06 +00:00
Florin Malita
cc01311cfc [skottie] Add audio track support to viewer
Based on SkAudioPlayer, Mac-only for now.

Change-Id: Ic4b0e2814aa341586634cbd270d7afd90e32716b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310056
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-08-13 17:04:12 +00:00
Brian Osman
a4b9169fb6 Remove 'in' variables from SkRuntimeEffect
Runtime effects previously allowed two kinds of global input variables:
'in' variables could be bool, int, or float. 'uniform' could be float,
vector, or matrix. Uniform variables worked like you'd expect, but 'in'
variables were baked into the program statically. There was a large
amount of machinery to make this work, and it meant that 'in' variables
needed to have values before we could make decisions about program
caching, and before we could catch some errors. It was also essentially
syntactic sugar over the client just inserting the value into their SkSL
as a string. Finally: No one was using the feature.

To simplify the mental model, and make the API much more predictable,
this CL removes 'in' variables entirely. We no longer need to
"specialize" runtime effect programs, which means we can catch more
errors up front (those not detected until optimization). All of the API
that referred to "inputs" (the previous term that unified 'in' and
'uniform') now just refers to "uniforms".

Bug: skia:10593
Change-Id: I971f620d868b259e652b3114f0b497c2620f4b0c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309050
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-08-10 22:00:44 +00:00
John Stiles
a6841be235 Enable ClangTidy check llvm-namespace-comment.
This fixes a large number of SkSL namespaces which were labeled as if
they were anonymous, and also a handful of other mislabeled namespaces.
Missing namespace-end comments have been added throughout.
A number of diffs are just indentation-related (adjusting 1- or 3-
space indents to 2-space).

Change-Id: I6c62052a0d3aea4ae12ca07e0c2a8587b2fce4ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308503
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-08-06 19:07:52 +00:00
Mike Klein
813e8cc762 add a global may-we-JIT flag
The most interesting part of the CL is that we recheck gSkVMAllowJIT in
Program::eval() even though we've already checked it in the constructor.
This allows Viewer to toggle the JIT on and off without having to worry
about program caching. This is not something that you'd expect to come
up in practice if a program just sets gSkVMAllowJIT at the start of
main(); for real clients I think we can avoid all this with a simple
SkGraphics::allowJIT() that only lets clients opt-in, never back out.

I toyed with making '!' rotate through a tristate in Viewer, until I
realized that these really are independent bits: GMs like threshold_rt
that use both ordinary effects and SkVM-only effects demonstrate
different behavior and performance in all four modes.  So '!' continues
to toggle SkVMBlitter, and now '@' toggles the JIT.

I've left the test program default settings unchanged, with the JIT
enabled unless --nojit is passed.  Where we previously simplified the
command line by conflating --dylib with --skvm, we now conflate --dylib
with --jit.

Change-Id: If86bf524c657298c0846bcd33c706e3c3f91e788
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308184
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-08-05 16:35:45 +00:00
John Stiles
bd3ffa43d2 Fix range-based for loops which copy the loop variable unnecessarily.
This will allow us to enable the ClangTidy check
performance-for-range-copy.

Change-Id: I11f152ffe458f5f353da8715ffd2fd47cf4e71a7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306946
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-07-31 01:02:21 +00:00
Florin Malita
96d6c6f04d [skottie] Re-enable inval tracking in viewer
This was disabled accidentally at some point.

TBR=

Change-Id: I7d537e519aca983ce2f9b5428820ba87f8113789
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306539
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2020-07-29 15:21:06 +00:00
John Stiles
afb7870f75 Update Slide::getName to return a const reference.
The Viewer slide list stores the values from repeated calls to
Slide::getName().c_str() in a large list for filtering purposes.
However, the temporary SkString was being destroyed before the list was
complete. This luckily happened to work because SkString's refcounting
behavior kept the internal buffer alive past the lifetime of the
temporary SkString object, but it's not intended to work.

Returning a const-ref to the internal SkString is more efficient, and
gives us long-lived SkStrings to work with.

Change-Id: I958148ba46332f9ec576ac60d0a9b916284c4761
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306256
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-07-28 17:37:01 +00:00
Brian Salomon
d007281c9a Fix clang 12 Wsuggest-override and Wsuggest-destructor-override
Change-Id: Ic44e24057b95bb014504f02a736fb4341afc8971
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304856
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-07-22 01:11:36 +00:00
John Stiles
886a904595 Update SkTQSort to use half-open ranges.
C++ algorithms have largely standardized on a [begin, end) half-open
range, as seen in standard library containers. SkTQSort now adheres to
this model, and takes vec.begin() and vec.end() as its inputs.

To avoid confusion between inclusive and half-open ranges inside the
implementation, internal helper functions now take "left" and "count"
arguments instead of "left"/"right" or "begin"/"end". This avoids any
ambiguity.

(Although performance was not the main goal, this CL appears to
slightly improve our sorting benchmark on my machine.)

Change-Id: I5e96b6730be96cf23d001ee0915c69764b2c024a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302579
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-07-14 22:13:59 +00:00
Brian Osman
a7685b2343 Runtime effects: Allow null children
Two related things:
1) SkRuntimeEffect will allow null child shaders when calling
   makeshader. This will produce a GrSkSLFP with null FP children.
   Fix some code that assumed that children were non-null.
2) Change the input color passed to any children to be the SkSLFP's
   input color, rather than the default (white). This lets nullptr
   children in runtime effect have the desired behavior (they are the
   paint color or similar, depending on context).

Change-Id: Iabffc50b0a893a56403c5240f32a5da6a88d81f6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301980
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-07-14 21:33:57 +00:00
John Stiles
df07800f95 Include the SkTSort header only where it is used.
Change-Id: If51be35205b40c4a22979a4b49b031126af1dde7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302500
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-07-14 14:19:06 +00:00
John Stiles
6e9ead9166 Revert "Remove custom SkSort algorithms."
This reverts commit 70474c1cb0.

Reason for revert: bot build failure

Original change's description:
> Remove custom SkSort algorithms.
> 
> SortBench shows that SkTQSort and SkTHeapSort are inferior to std::sort.
> The difference is small on randomized inputs, but quite significant for
> semi-ordered inputs (forward/backward/repeated). There doesn't seem to
> to be any compelling advantage to SkTQSort.
> 
> Nanobench results: https://screenshot.googleplex.com/9JOLV1d6Z0u
> 
> (These performance numbers are from an optimized build my local machine;
> it's possible that we might see different results on the test bots.)
> 
> Change-Id: Iaf19563041547eae7de2953be249129108f093b1
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302295
> Commit-Queue: John Stiles <johnstiles@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>

TBR=mtklein@google.com,brianosman@google.com,johnstiles@google.com

Change-Id: I1126dd4cda95716dac225ad32d5b0e5cf3f09421
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302447
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-07-14 00:25:05 +00:00
John Stiles
70474c1cb0 Remove custom SkSort algorithms.
SortBench shows that SkTQSort and SkTHeapSort are inferior to std::sort.
The difference is small on randomized inputs, but quite significant for
semi-ordered inputs (forward/backward/repeated). There doesn't seem to
to be any compelling advantage to SkTQSort.

Nanobench results: https://screenshot.googleplex.com/9JOLV1d6Z0u

(These performance numbers are from an optimized build my local machine;
it's possible that we might see different results on the test bots.)

Change-Id: Iaf19563041547eae7de2953be249129108f093b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302295
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-07-13 23:35:20 +00:00
Brian Osman
31890e2c37 Viewer: Don't steal focus when the shader error window appears
Makes editing shaders (in the SkSL or Particles slides) tolerable.
Previously, every intermediate state (that didn't compile) would force
you to stop and click back in the code window.

Change-Id: Ibc12b8d697a6b5073e24020daa143a4047a5da31
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301984
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
2020-07-13 13:56:52 +00:00
Robert Phillips
ed65339084 Update the sk_app WindowContext to hold a GrDirectContext
This CL is working towards replacing GrContext with the GrDirectContext/
GrRecordingContext pair.

Change-Id: Id4488e1280d76a16c37d58bd8d29fb7f8dde6b1d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301940
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-07-10 18:27:03 +00:00
Adlai Holler
e3ad527e3f Add a convenience to downcast contexts into GrDirectContext
This pattern of needing a safe downcast will continue to grow as we
add more explicit use of GrDirectContext and it's causing long ternary
operations that span multiple lines.

Change-Id: I9e2ebe5156e4245524a52d7c92ed3a8509e53151
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300901
Commit-Queue: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-07-07 18:13:50 +00:00
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