25#include <unordered_map>
30 auto* drawEvent = fDraws.find({
frame, nodeId});
33 "Could not set command playhead for event {%d, %d}, it is not tracked by"
34 "DebugLayerManager.\n",
39 const int count = drawEvent->debugCanvas->getSize();
44 for (
const auto&
f : relevantFrames) {
45 fDraws[{
f, nodeId}].image =
nullptr;
58 auto debugCanvas = std::make_unique<DebugCanvas>(layerBounds);
60 debugCanvas->setOverdrawViz(
false);
61 debugCanvas->setDrawGpuOpBounds(
false);
64 debugCanvas->setLayerManagerAndFrame(
this,
frame);
66 debugCanvas->drawPicture(
picture);
67 int numCommands = debugCanvas->getSize();
70 frame == 0 || dirty == layerBounds,
72 std::move(debugCanvas),
74 {layerBounds.
width(), layerBounds.height()},
77 fDraws.set(k, std::move(
event));
82 auto& evt = fDraws[{
frame, nodeId}];
83 evt.debugCanvas->drawTo(
surface->getCanvas(), evt.command);
98 uint32_t
i = relevantFrames.size()-1;
99 while (relevantFrames[
i] >
frame) {
i--; }
100 const int frameN = relevantFrames[
i];
102 auto& drawEvent = fDraws[{frameN, nodeId}];
104 if (drawEvent.image) {
105 return drawEvent.image;
109 while (
i>0 && !(fDraws[{relevantFrames[
i], nodeId}].fullRedraw)) {
i--; }
119 for (;
i<relevantFrames.size() && relevantFrames[
i]<=frameN;
i++) {
122 drawEvent.image =
surface->makeImageSnapshot();
123 return drawEvent.image;
127 auto* evt = fDraws.find({
frame, nodeId});
128 if (!evt) {
return {}; }
130 true, evt->debugCanvas->getSize(),
131 evt->layerBounds.width(), evt->layerBounds.height()
139 std::unordered_map<int, LayerSummary> summaryMap;
140 for (
const auto&
key : keys) {
141 auto* evt = fDraws.find(
key);
142 if (!evt) {
continue; }
145 int lastUpdate = (
key.frame <=
frame ?
key.frame : -1);
148 auto found = summaryMap.find(
key.nodeId);
149 if (found != summaryMap.end()) {
157 summaryMap.insert({
key.nodeId, {
158 key.nodeId, lastUpdate, evt->fullRedraw,
159 evt->layerBounds.width(), evt->layerBounds.height()
163 std::vector<LayerSummary>
result;
164 for (
auto it = summaryMap.begin(); it != summaryMap.end(); ++it) {
165 result.push_back(it->second);
172 for (
const auto&
key : keys) {
182 for (
const auto&
key : keys) {
183 if (
key.nodeId == nodeId) {
191 auto& evt = fDraws[{
frame, nodeId}];
192 return evt.debugCanvas.get();
196 for (
const auto&
key : keys) {
197 auto& evt = fDraws[
key];
198 evt.debugCanvas->setOverdrawViz(overdrawViz);
203 for (
const auto&
key : keys) {
204 auto& evt = fDraws[
key];
205 evt.debugCanvas->setClipVizColor(clipVizColor);
210 for (
const auto&
key : keys) {
211 auto& evt = fDraws[
key];
212 evt.debugCanvas->setDrawGpuOpBounds(drawGpuOpBounds);
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorTRANSPARENT
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
DrawEventSummary event(int nodeId, int frame) const
std::vector< int > listNodesForFrame(int frame) const
void setCommand(int nodeId, int frame, int command)
DebugCanvas * getEventDebugCanvas(int nodeid, int frame)
void drawLayerEventTo(SkSurface *, const int nodeId, const int frame)
void setClipVizColor(SkColor clipVizColor)
void setOverdrawViz(bool overdrawViz)
void storeSkPicture(int nodeId, int frame, const sk_sp< SkPicture > &picture, SkIRect dirty)
void setDrawGpuOpBounds(bool drawGpuOpBounds)
std::vector< int > listFramesForNode(int nodeId) const
sk_sp< SkImage > getLayerAsImage(const int nodeId, const int frame)
std::vector< LayerSummary > summarizeLayers(int frame) const
virtual SkRect cullRect() const =0
sk_sp< const SkPicture > picture
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
constexpr int32_t width() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
void roundOut(SkIRect *dst) const