Flutter Engine
The Flutter Engine
Classes | Functions | Variables
debugger_bindings.cpp File Reference
#include "include/codec/SkCodec.h"
#include "include/core/SkImage.h"
#include "include/core/SkPicture.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
#include "include/docs/SkMultiPictureDocument.h"
#include "include/encode/SkPngEncoder.h"
#include "src/base/SkBase64.h"
#include "src/core/SkPicturePriv.h"
#include "src/utils/SkJSONWriter.h"
#include "tools/SkSharingProc.h"
#include "tools/UrlDataManager.h"
#include "tools/debugger/DebugCanvas.h"
#include "tools/debugger/DebugLayerManager.h"
#include "tools/debugger/DrawCommand.h"
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include <map>
#include <emscripten.h>
#include <emscripten/bind.h>
#include "modules/canvaskit/WasmCommon.h"

Go to the source code of this file.

Classes

struct  ImageInfoNoColorspace
 
class  SkpDebugPlayer
 

Functions

uint32_t MinVersion ()
 
ImageInfoNoColorspace toImageInfoNoColorspace (const SkImageInfo &ii)
 
static sk_sp< SkImagedeserializeImage (sk_sp< SkData > data, std::optional< SkAlphaType >, void *)
 
 EMSCRIPTEN_BINDINGS (my_module)
 

Variables

static constexpr char kMultiMagic [] = "Skia Multi-Picture Doc\n\n"
 

Function Documentation

◆ deserializeImage()

static sk_sp< SkImage > deserializeImage ( sk_sp< SkData data,
std::optional< SkAlphaType ,
void *   
)
static

Definition at line 69 of file debugger_bindings.cpp.

69 {
70 std::unique_ptr<SkCodec> codec = DecodeImageData(std::move(data));
71 if (!codec) {
72 SkDebugf("Could not decode an image\n");
73 return nullptr;
74 }
75 sk_sp<SkImage> img = std::get<0>(codec->getImage());
76 if (!img) {
77 SkDebugf("Could not make an image from a codec\n");
78 return nullptr;
79 }
80 return img;
81}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
std::unique_ptr< SkCodec > DecodeImageData(sk_sp< SkData > data)
const myers::Point & get< 0 >(const myers::Segment &s)
Definition: Myers.h:80
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ EMSCRIPTEN_BINDINGS()

EMSCRIPTEN_BINDINGS ( my_module  )

Definition at line 499 of file debugger_bindings.cpp.

499 {
500
501 function("MinVersion", &MinVersion);
502
503 // The main class that the JavaScript in index.html uses
504 class_<SkpDebugPlayer>("SkpDebugPlayer")
505 .constructor<>()
506 .function("changeFrame", &SkpDebugPlayer::changeFrame)
507 .function("deleteCommand", &SkpDebugPlayer::deleteCommand)
508 .function("draw", &SkpDebugPlayer::draw, allow_raw_pointers())
509 .function("drawTo", &SkpDebugPlayer::drawTo, allow_raw_pointers())
510 .function("findCommandByPixel", &SkpDebugPlayer::findCommandByPixel, allow_raw_pointers())
511 .function("getBounds", &SkpDebugPlayer::getBounds)
512 .function("getBoundsForFrame", &SkpDebugPlayer::getBoundsForFrame)
513 .function("getFrameCount", &SkpDebugPlayer::getFrameCount)
514 .function("getImageResource", &SkpDebugPlayer::getImageResource)
515 .function("getImageCount", &SkpDebugPlayer::getImageCount)
516 .function("getImageInfo", &SkpDebugPlayer::getImageInfo)
517 .function("getLayerKeys", &SkpDebugPlayer::getLayerKeys)
518 .function("getLayerSummariesJs", &SkpDebugPlayer::getLayerSummariesJs)
519 .function("getSize", &SkpDebugPlayer::getSize)
520 .function("imageUseInfo", &SkpDebugPlayer::imageUseInfo)
521 .function("imageUseInfoForFrameJs", optional_override([](SkpDebugPlayer& self, const int frame)->JSObject {
522 // -1 as a node id is used throughout the application to mean no layer inspected.
523 return self.imageUseInfo(frame, -1);
524 }))
525 .function("jsonCommandList", &SkpDebugPlayer::jsonCommandList, allow_raw_pointers())
526 .function("lastCommandInfo", &SkpDebugPlayer::lastCommandInfo)
527 .function("loadSkp", &SkpDebugPlayer::loadSkp, allow_raw_pointers())
528 .function("setClipVizColor", &SkpDebugPlayer::setClipVizColor)
529 .function("setCommandVisibility", &SkpDebugPlayer::setCommandVisibility)
530 .function("setGpuOpBounds", &SkpDebugPlayer::setGpuOpBounds)
531 .function("setInspectedLayer", &SkpDebugPlayer::setInspectedLayer)
532 .function("setOriginVisible", &SkpDebugPlayer::setOriginVisible)
533 .function("setOverdrawVis", &SkpDebugPlayer::setOverdrawVis)
534 .function("setAndroidClipViz", &SkpDebugPlayer::setAndroidClipViz);
535
536 // Structs used as arguments or returns to the functions above
537 // TODO(kjlubick) handle this rect like the ones in CanvasKit
538 value_object<SkIRect>("SkIRect")
539 .field("fLeft", &SkIRect::fLeft)
540 .field("fTop", &SkIRect::fTop)
541 .field("fRight", &SkIRect::fRight)
542 .field("fBottom", &SkIRect::fBottom);
543 // emscripten provided the following convenience function for binding vector<T>
544 // https://emscripten.org/docs/api_reference/bind.h.html#_CPPv415register_vectorPKc
545 register_vector<DebugLayerManager::LayerSummary>("VectorLayerSummary");
546 value_object<DebugLayerManager::LayerSummary>("LayerSummary")
548 .field("frameOfLastUpdate", &DebugLayerManager::LayerSummary::frameOfLastUpdate)
551 .field("layerHeight", &DebugLayerManager::LayerSummary::layerHeight);
552
553 value_object<ImageInfoNoColorspace>("ImageInfoNoColorspace")
554 .field("width", &ImageInfoNoColorspace::width)
555 .field("height", &ImageInfoNoColorspace::height)
556 .field("colorType", &ImageInfoNoColorspace::colorType)
557 .field("alphaType", &ImageInfoNoColorspace::alphaType);
558}
emscripten::val JSObject
Definition: WasmCommon.h:28
std::string jsonCommandList(sk_sp< SkSurface > surface)
void setCommandVisibility(int index, bool visible)
int findCommandByPixel(SkSurface *surface, int x, int y, int commandIndex)
std::string getImageResource(int index)
void setAndroidClipViz(bool on)
void setOriginVisible(bool on)
JSObject imageUseInfo(int framenumber, int nodeid)
void setOverdrawVis(bool on)
std::string loadSkp(uintptr_t cptr, int length)
void draw(SkSurface *surface)
void changeFrame(int index)
const SkIRect getBoundsForFrame(int32_t frame)
JSArray getLayerSummariesJs()
void drawTo(SkSurface *surface, int32_t index)
void deleteCommand(int index)
void setClipVizColor(JSColor color)
void setGpuOpBounds(bool on)
const SkIRect getBounds()
std::string lastCommandInfo()
int getFrameCount() const
void setInspectedLayer(int nodeId)
ImageInfoNoColorspace getImageInfo(int index)
uint32_t MinVersion()
double frame
Definition: examples.cpp:31
Dart_NativeFunction function
Definition: fuchsia.cc:51
int32_t fBottom
larger y-axis bounds
Definition: SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition: SkRect.h:35

◆ MinVersion()

uint32_t MinVersion ( )

Definition at line 55 of file debugger_bindings.cpp.

◆ toImageInfoNoColorspace()

ImageInfoNoColorspace toImageInfoNoColorspace ( const SkImageInfo ii)

Definition at line 65 of file debugger_bindings.cpp.

65 {
66 return (ImageInfoNoColorspace){ii.width(), ii.height(), ii.colorType(), ii.alphaType()};
67}
int width() const
Definition: SkImageInfo.h:365
SkAlphaType alphaType() const
Definition: SkImageInfo.h:375
SkColorType colorType() const
Definition: SkImageInfo.h:373
int height() const
Definition: SkImageInfo.h:371

Variable Documentation

◆ kMultiMagic

constexpr char kMultiMagic[] = "Skia Multi-Picture Doc\n\n"
staticconstexpr

Definition at line 53 of file debugger_bindings.cpp.