add flow events to the timeline to track the lifecycle of cache images (flutter/engine#29298)
This commit is contained in:
@@ -20,8 +20,9 @@
|
||||
namespace flutter {
|
||||
|
||||
RasterCacheResult::RasterCacheResult(sk_sp<SkImage> image,
|
||||
const SkRect& logical_rect)
|
||||
: image_(std::move(image)), logical_rect_(logical_rect) {}
|
||||
const SkRect& logical_rect,
|
||||
const char* type)
|
||||
: image_(std::move(image)), logical_rect_(logical_rect), flow_(type) {}
|
||||
|
||||
void RasterCacheResult::draw(SkCanvas& canvas, const SkPaint* paint) const {
|
||||
TRACE_EVENT0("flutter", "RasterCacheResult::draw");
|
||||
@@ -32,6 +33,7 @@ void RasterCacheResult::draw(SkCanvas& canvas, const SkPaint* paint) const {
|
||||
std::abs(bounds.size().width() - image_->dimensions().width()) <= 1 &&
|
||||
std::abs(bounds.size().height() - image_->dimensions().height()) <= 1);
|
||||
canvas.resetMatrix();
|
||||
flow_.Step();
|
||||
canvas.drawImage(image_, bounds.fLeft, bounds.fTop, SkSamplingOptions(),
|
||||
paint);
|
||||
}
|
||||
@@ -117,6 +119,7 @@ static std::unique_ptr<RasterCacheResult> Rasterize(
|
||||
SkColorSpace* dst_color_space,
|
||||
bool checkerboard,
|
||||
const SkRect& logical_rect,
|
||||
const char* type,
|
||||
const std::function<void(SkCanvas*)>& draw_function) {
|
||||
TRACE_EVENT0("flutter", "RasterCachePopulate");
|
||||
SkIRect cache_rect = RasterCache::GetDeviceBounds(logical_rect, ctm);
|
||||
@@ -144,7 +147,7 @@ static std::unique_ptr<RasterCacheResult> Rasterize(
|
||||
}
|
||||
|
||||
return std::make_unique<RasterCacheResult>(surface->makeImageSnapshot(),
|
||||
logical_rect);
|
||||
logical_rect, type);
|
||||
}
|
||||
|
||||
std::unique_ptr<RasterCacheResult> RasterCache::RasterizePicture(
|
||||
@@ -154,7 +157,7 @@ std::unique_ptr<RasterCacheResult> RasterCache::RasterizePicture(
|
||||
SkColorSpace* dst_color_space,
|
||||
bool checkerboard) const {
|
||||
return Rasterize(context, ctm, dst_color_space, checkerboard,
|
||||
picture->cullRect(),
|
||||
picture->cullRect(), "RasterCacheFlow::SkPicture",
|
||||
[=](SkCanvas* canvas) { canvas->drawPicture(picture); });
|
||||
}
|
||||
|
||||
@@ -165,7 +168,7 @@ std::unique_ptr<RasterCacheResult> RasterCache::RasterizeDisplayList(
|
||||
SkColorSpace* dst_color_space,
|
||||
bool checkerboard) const {
|
||||
return Rasterize(context, ctm, dst_color_space, checkerboard,
|
||||
display_list->bounds(),
|
||||
display_list->bounds(), "RasterCacheFlow::DisplayList",
|
||||
[=](SkCanvas* canvas) { display_list->RenderTo(canvas); });
|
||||
}
|
||||
|
||||
@@ -188,7 +191,8 @@ std::unique_ptr<RasterCacheResult> RasterCache::RasterizeLayer(
|
||||
bool checkerboard) const {
|
||||
return Rasterize(
|
||||
context->gr_context, ctm, context->dst_color_space, checkerboard,
|
||||
layer->paint_bounds(), [layer, context](SkCanvas* canvas) {
|
||||
layer->paint_bounds(), "RasterCacheFlow::Layer",
|
||||
[layer, context](SkCanvas* canvas) {
|
||||
SkISize canvas_size = canvas->getBaseLayerSize();
|
||||
SkNWayCanvas internal_nodes_canvas(canvas_size.width(),
|
||||
canvas_size.height());
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "flutter/flow/raster_cache_key.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/memory/weak_ptr.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "third_party/skia/include/core/SkImage.h"
|
||||
#include "third_party/skia/include/core/SkSize.h"
|
||||
|
||||
@@ -19,7 +20,9 @@ namespace flutter {
|
||||
|
||||
class RasterCacheResult {
|
||||
public:
|
||||
RasterCacheResult(sk_sp<SkImage> image, const SkRect& logical_rect);
|
||||
RasterCacheResult(sk_sp<SkImage> image,
|
||||
const SkRect& logical_rect,
|
||||
const char* type);
|
||||
|
||||
virtual ~RasterCacheResult() = default;
|
||||
|
||||
@@ -36,6 +39,7 @@ class RasterCacheResult {
|
||||
private:
|
||||
sk_sp<SkImage> image_;
|
||||
SkRect logical_rect_;
|
||||
fml::tracing::TraceFlow flow_;
|
||||
};
|
||||
|
||||
struct PrerollContext;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
MockRasterCacheResult::MockRasterCacheResult(SkIRect device_rect)
|
||||
: RasterCacheResult(nullptr, SkRect::MakeEmpty()),
|
||||
: RasterCacheResult(nullptr, SkRect::MakeEmpty(), "RasterCacheFlow::test"),
|
||||
device_rect_(device_rect) {}
|
||||
|
||||
std::unique_ptr<RasterCacheResult> MockRasterCache::RasterizePicture(
|
||||
|
||||
@@ -370,13 +370,13 @@ class TraceFlow {
|
||||
other.nonce_ = 0;
|
||||
}
|
||||
|
||||
void Step(const char* label) const {
|
||||
TraceEventFlowStep0("flutter", label, nonce_);
|
||||
void Step(const char* label = nullptr) const {
|
||||
TraceEventFlowStep0("flutter", label ? label : label_, nonce_);
|
||||
}
|
||||
|
||||
void End(const char* label = nullptr) {
|
||||
if (nonce_ != 0) {
|
||||
TraceEventFlowEnd0("flutter", label == nullptr ? label_ : label, nonce_);
|
||||
TraceEventFlowEnd0("flutter", label ? label : label_, nonce_);
|
||||
nonce_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user