add GM for exercising interesting paths in SkVMBlitter
It's not drawing anything earthshattering, but it does act as an easy way to exercise some interesting code paths in SkVMBlitter, here first program caching based on shader program and not shader identity. With today's shader caching patches, this makes 2 calls to skvm::Builder::done(), JITing the program, while if you patched this in at head you'd see 3. I'd like it to get down to 1 by converting paint colors to color shaders. Change-Id: I042f4d44a792b46e5543794c853e4ef0d95b11ec Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252029 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
2368bda0e1
commit
23e856f369
43
gm/skvm.cpp
Normal file
43
gm/skvm.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gm/gm.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkShader.h"
|
||||
|
||||
// This GM exercises interesting cases in SkVMBlitter,
|
||||
// and mostly draws uninteresting simple shapes and colors.
|
||||
// At the moment it's really only interesting if you #define SK_USE_SKVM_BLITTER.
|
||||
|
||||
DEF_SIMPLE_GM(SkVMBlitter, canvas, 100, 100) {
|
||||
SkPaint p;
|
||||
|
||||
// These two draws are supported by SkVMBlitter,
|
||||
// and the green draw will reuse the program cached by the blue draw.
|
||||
//
|
||||
// We don't have any API to detect this, but you can flip on the #if guard
|
||||
// around "calls to done" in SkVMBlitter.cpp and run this GM in isolation.
|
||||
// You should see 2 calls to done, one for the blitter that clears to white,
|
||||
// and one for the program used by both shader draws.
|
||||
//
|
||||
// $ ninja -C out fm && out/fm -b cpu -s SkVMBlitter
|
||||
// ...
|
||||
// 2 calls to done
|
||||
//
|
||||
// Clever readers might realize this could actually be one single blitter:
|
||||
// only the fact that some colors come via shader and the white clear via
|
||||
// the paint makes the two programs cache differently, despite basically
|
||||
// doing the same thing. (TODO: unify these two paths also so they'd hit
|
||||
// the cache.)
|
||||
|
||||
p.setShader(SkShaders::Color(SK_ColorBLUE));
|
||||
canvas->drawRect({0,0,50,50}, p);
|
||||
|
||||
p.setShader(SkShaders::Color(SK_ColorGREEN));
|
||||
canvas->drawRect({50,50,100,100}, p);
|
||||
}
|
Loading…
Reference in New Issue
Block a user