handle different bounds for every frame
b:skia:11045 Change-Id: I0547b329fde8edcbc275992c7c5168e788294ba8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341045 Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Commit-Queue: Nathaniel Nifong <nifong@google.com>
This commit is contained in:
parent
b5f880a3f6
commit
e38a9e7f18
@ -135,14 +135,21 @@ class SkpDebugPlayer {
|
||||
surface->getCanvas()->flush();
|
||||
}
|
||||
|
||||
const SkIRect getBounds() {
|
||||
// Gets the bounds for the given frame
|
||||
// (or layer update, assuming there is one at that frame for fInspectedLayer)
|
||||
const SkIRect getBoundsForFrame(int32_t frame) {
|
||||
if (fInspectedLayer < 0) {
|
||||
return fBounds;
|
||||
return fBoundsArray[frame];
|
||||
}
|
||||
auto summary = fLayerManager->event(fInspectedLayer, fp);
|
||||
return SkIRect::MakeWH(summary.layerWidth, summary.layerHeight);
|
||||
}
|
||||
|
||||
// Gets the bounds for the current frame
|
||||
const SkIRect getBounds() {
|
||||
return getBoundsForFrame(fp);
|
||||
}
|
||||
|
||||
// returns the debugcanvas of the current frame, or the current draw event when inspecting
|
||||
// a layer.
|
||||
DebugCanvas* visibleCanvas() {
|
||||
@ -371,8 +378,8 @@ class SkpDebugPlayer {
|
||||
}
|
||||
SkDebugf("Parsed SKP file.\n");
|
||||
// Make debug canvas using bounds from SkPicture
|
||||
fBounds = picture->cullRect().roundOut();
|
||||
std::unique_ptr<DebugCanvas> debugCanvas = std::make_unique<DebugCanvas>(fBounds);
|
||||
fBoundsArray.push_back(picture->cullRect().roundOut());
|
||||
std::unique_ptr<DebugCanvas> debugCanvas = std::make_unique<DebugCanvas>(fBoundsArray.back());
|
||||
|
||||
// Only draw picture to the debug canvas once.
|
||||
debugCanvas->drawPicture(picture);
|
||||
@ -403,8 +410,8 @@ class SkpDebugPlayer {
|
||||
int i = 0;
|
||||
for (const auto& page : pages) {
|
||||
// Make debug canvas using bounds from SkPicture
|
||||
fBounds = page.fPicture->cullRect().roundOut();
|
||||
std::unique_ptr<DebugCanvas> debugCanvas = std::make_unique<DebugCanvas>(fBounds);
|
||||
fBoundsArray.push_back(page.fPicture->cullRect().roundOut());
|
||||
std::unique_ptr<DebugCanvas> debugCanvas = std::make_unique<DebugCanvas>(fBoundsArray.back());
|
||||
debugCanvas->setLayerManagerAndFrame(fLayerManager.get(), i);
|
||||
|
||||
// Only draw picture to the debug canvas once.
|
||||
@ -441,8 +448,9 @@ class SkpDebugPlayer {
|
||||
std::vector<std::unique_ptr<DebugCanvas>> frames;
|
||||
// The index of the current frame (into the vector above)
|
||||
int fp = 0;
|
||||
// The width and height of the animation. (in practice the bounds of the last loaded frame)
|
||||
SkIRect fBounds;
|
||||
// The width and height of every frame.
|
||||
// frame sizes are known to change in Android Skia RenderEngine because it interleves pictures from different applications.
|
||||
std::vector<SkIRect> fBoundsArray;
|
||||
// image resources from a loaded file
|
||||
std::vector<sk_sp<SkImage>> fImages;
|
||||
|
||||
@ -541,6 +549,7 @@ EMSCRIPTEN_BINDINGS(my_module) {
|
||||
.function("drawTo", &SkpDebugPlayer::drawTo, allow_raw_pointers())
|
||||
.function("findCommandByPixel", &SkpDebugPlayer::findCommandByPixel, allow_raw_pointers())
|
||||
.function("getBounds", &SkpDebugPlayer::getBounds)
|
||||
.function("getBoundsForFrame", &SkpDebugPlayer::getBoundsForFrame)
|
||||
.function("getFrameCount", &SkpDebugPlayer::getFrameCount)
|
||||
.function("getImageResource", &SkpDebugPlayer::getImageResource)
|
||||
.function("getImageCount", &SkpDebugPlayer::getImageCount)
|
||||
|
Loading…
Reference in New Issue
Block a user