Restore offscreen surface example, Add GPU/CPU reporting function.
Change-Id: Ic360cef53aa22983e8b17a3488e97d6f28b27d97 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288894 Reviewed-by: Kevin Lubick <kjlubick@google.com> Commit-Queue: Nathaniel Nifong <nifong@google.com>
This commit is contained in:
parent
baf8921806
commit
ce1648f822
@ -29,13 +29,15 @@
|
||||
<h2> Paragraph </h2>
|
||||
<canvas id=para1 width=600 height=600></canvas>
|
||||
|
||||
|
||||
<h2> CanvasKit can serialize/deserialize .skp files</h2>
|
||||
<canvas id=skp width=500 height=500></canvas>
|
||||
|
||||
<h2> 3D perspective transformations </h2>
|
||||
<canvas id=camera3d width=500 height=500></canvas>
|
||||
|
||||
<h2> Use of offscreen surfaces </h2>
|
||||
<canvas id=surfaces width=500 height=500></canvas>
|
||||
|
||||
<script type="text/javascript" src="/node_modules/canvaskit/bin/canvaskit.js"></script>
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
@ -76,6 +78,8 @@
|
||||
RTShaderAPI1(CanvasKit);
|
||||
|
||||
SkpExample(CanvasKit, skpData);
|
||||
|
||||
SurfaceAPI1(CanvasKit);
|
||||
});
|
||||
|
||||
fetch(cdn + 'lego_loader.json').then((resp) => {
|
||||
@ -242,10 +246,11 @@ const curves = {
|
||||
console.error('Could not make surface');
|
||||
return;
|
||||
}
|
||||
console.log('SurfaceAPI1 top surface type = '+surface.reportBackendType() );
|
||||
const context = CanvasKit.currentContext();
|
||||
const canvas = surface.getCanvas();
|
||||
|
||||
// create a subsurface as a temporary workspace.
|
||||
//create a subsurface as a temporary workspace.
|
||||
const subSurface = surface.makeSurface({
|
||||
width: 50,
|
||||
height: 50,
|
||||
@ -257,6 +262,7 @@ const curves = {
|
||||
console.error('Could not make subsurface');
|
||||
return;
|
||||
}
|
||||
console.log('SurfaceAPI1 subSurface type = '+subSurface.reportBackendType() );
|
||||
|
||||
// draw a small "scene"
|
||||
const paint = new CanvasKit.SkPaint();
|
||||
|
@ -1463,7 +1463,10 @@ EMSCRIPTEN_BINDINGS(Skia) {
|
||||
.function("makeSurface", optional_override([](SkSurface& self, SimpleImageInfo sii)->sk_sp<SkSurface> {
|
||||
return self.makeSurface(toSkImageInfo(sii));
|
||||
}), allow_raw_pointers())
|
||||
.function("width", &SkSurface::width);
|
||||
.function("width", &SkSurface::width)
|
||||
.function("reportBackendType", optional_override([](SkSurface& self)->std::string {
|
||||
return self.getCanvas()->getGrContext() == nullptr ? "CPU" : "GPU";
|
||||
}));
|
||||
|
||||
#ifndef SK_NO_FONTS
|
||||
class_<SkTextBlob>("SkTextBlob")
|
||||
|
@ -520,6 +520,7 @@ var CanvasKit = {
|
||||
/** @return {CanvasKit.SkImage} */
|
||||
makeImageSnapshot: function() {},
|
||||
makeSurface: function() {},
|
||||
reportBackendType: function() {},
|
||||
grContext: {},
|
||||
|
||||
// private API
|
||||
|
Loading…
Reference in New Issue
Block a user