only report cache entries with images for RasterCache metrics (flutter/engine#29369)
This commit is contained in:
@@ -24,7 +24,6 @@ void CompositorContext::BeginFrame(ScopedFrame& frame,
|
||||
|
||||
void CompositorContext::EndFrame(ScopedFrame& frame,
|
||||
bool enable_instrumentation) {
|
||||
raster_cache_.SweepAfterFrame();
|
||||
if (enable_instrumentation) {
|
||||
raster_time_.Stop();
|
||||
}
|
||||
|
||||
@@ -130,28 +130,26 @@ void FrameTimingsRecorder::RecordBuildEnd(fml::TimePoint build_end) {
|
||||
build_end_ = build_end;
|
||||
}
|
||||
|
||||
void FrameTimingsRecorder::RecordRasterStart(fml::TimePoint raster_start,
|
||||
const RasterCache* cache) {
|
||||
void FrameTimingsRecorder::RecordRasterStart(fml::TimePoint raster_start) {
|
||||
std::scoped_lock state_lock(state_mutex_);
|
||||
FML_DCHECK(state_ == State::kBuildEnd);
|
||||
state_ = State::kRasterStart;
|
||||
raster_start_ = raster_start;
|
||||
sweep_count_at_raster_start_ = cache ? cache->sweep_count() : -1;
|
||||
}
|
||||
|
||||
FrameTiming FrameTimingsRecorder::RecordRasterEnd(const RasterCache* cache) {
|
||||
std::scoped_lock state_lock(state_mutex_);
|
||||
FML_DCHECK(state_ == State::kRasterStart);
|
||||
FML_DCHECK(sweep_count_at_raster_start_ ==
|
||||
(cache ? cache->sweep_count() : -1));
|
||||
state_ = State::kRasterEnd;
|
||||
raster_end_ = fml::TimePoint::Now();
|
||||
raster_end_wall_time_ = fml::TimePoint::CurrentWallTime();
|
||||
if (cache) {
|
||||
layer_cache_count_ = cache->GetLayerCachedEntriesCount();
|
||||
layer_cache_bytes_ = cache->EstimateLayerCacheByteSize();
|
||||
picture_cache_count_ = cache->GetPictureCachedEntriesCount();
|
||||
picture_cache_bytes_ = cache->EstimatePictureCacheByteSize();
|
||||
const RasterCacheMetrics& layer_metrics = cache->layer_metrics();
|
||||
const RasterCacheMetrics& picture_metrics = cache->picture_metrics();
|
||||
layer_cache_count_ = layer_metrics.total_count();
|
||||
layer_cache_bytes_ = layer_metrics.total_bytes();
|
||||
picture_cache_count_ = picture_metrics.total_count();
|
||||
picture_cache_bytes_ = picture_metrics.total_bytes();
|
||||
} else {
|
||||
layer_cache_count_ = layer_cache_bytes_ = picture_cache_count_ =
|
||||
picture_cache_bytes_ = 0;
|
||||
@@ -197,7 +195,6 @@ std::unique_ptr<FrameTimingsRecorder> FrameTimingsRecorder::CloneUntil(
|
||||
|
||||
if (state >= State::kRasterStart) {
|
||||
recorder->raster_start_ = raster_start_;
|
||||
recorder->sweep_count_at_raster_start_ = sweep_count_at_raster_start_;
|
||||
}
|
||||
|
||||
if (state >= State::kRasterEnd) {
|
||||
|
||||
@@ -93,8 +93,7 @@ class FrameTimingsRecorder {
|
||||
void RecordBuildEnd(fml::TimePoint build_end);
|
||||
|
||||
/// Records a raster start event.
|
||||
void RecordRasterStart(fml::TimePoint raster_start,
|
||||
const RasterCache* cache = nullptr);
|
||||
void RecordRasterStart(fml::TimePoint raster_start);
|
||||
|
||||
/// Clones the recorder until (and including) the specified state.
|
||||
std::unique_ptr<FrameTimingsRecorder> CloneUntil(State state);
|
||||
@@ -131,7 +130,6 @@ class FrameTimingsRecorder {
|
||||
fml::TimePoint raster_end_;
|
||||
fml::TimePoint raster_end_wall_time_;
|
||||
|
||||
int sweep_count_at_raster_start_;
|
||||
size_t layer_cache_count_;
|
||||
size_t layer_cache_bytes_;
|
||||
size_t picture_cache_count_;
|
||||
|
||||
@@ -91,10 +91,10 @@ TEST(FrameTimingsRecorderTest, RecordRasterTimesWithCache) {
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
MockRasterCache cache(1, 10);
|
||||
cache.SweepAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
const auto raster_start = fml::TimePoint::Now();
|
||||
recorder->RecordRasterStart(raster_start, &cache);
|
||||
recorder->RecordRasterStart(raster_start);
|
||||
|
||||
cache.AddMockLayer(100, 100);
|
||||
size_t layer_bytes = cache.EstimateLayerCacheByteSize();
|
||||
@@ -103,6 +103,8 @@ TEST(FrameTimingsRecorderTest, RecordRasterTimesWithCache) {
|
||||
size_t picture_bytes = cache.EstimatePictureCacheByteSize();
|
||||
EXPECT_GT(picture_bytes, 0u);
|
||||
|
||||
cache.CleanupAfterFrame();
|
||||
|
||||
const auto before_raster_end_wall_time = fml::TimePoint::CurrentWallTime();
|
||||
std::this_thread::sleep_for(1ms);
|
||||
const auto timing = recorder->RecordRasterEnd(&cache);
|
||||
@@ -123,32 +125,6 @@ TEST(FrameTimingsRecorderTest, RecordRasterTimesWithCache) {
|
||||
#if !defined(OS_FUCHSIA) && !defined(OS_WIN) && \
|
||||
(FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
|
||||
|
||||
TEST(FrameTimingsRecorderTest, ThrowAfterUnexpectedCacheSweep) {
|
||||
auto recorder = std::make_unique<FrameTimingsRecorder>();
|
||||
|
||||
const auto st = fml::TimePoint::Now();
|
||||
const auto en = st + fml::TimeDelta::FromMillisecondsF(16);
|
||||
recorder->RecordVsync(st, en);
|
||||
|
||||
const auto build_start = fml::TimePoint::Now();
|
||||
const auto build_end = build_start + fml::TimeDelta::FromMillisecondsF(16);
|
||||
recorder->RecordBuildStart(build_start);
|
||||
recorder->RecordBuildEnd(build_end);
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
MockRasterCache cache;
|
||||
|
||||
const auto raster_start = fml::TimePoint::Now();
|
||||
recorder->RecordRasterStart(raster_start, &cache);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
cache.SweepAfterFrame();
|
||||
EXPECT_EXIT(recorder->RecordRasterEnd(&cache),
|
||||
::testing::KilledBySignal(SIGABRT),
|
||||
"Check failed: sweep_count_at_raster_start_ == \\(cache \\? "
|
||||
"cache->sweep_count\\(\\) : -1\\).");
|
||||
}
|
||||
|
||||
TEST(FrameTimingsRecorderTest, ThrowWhenRecordBuildBeforeVsync) {
|
||||
auto recorder = std::make_unique<FrameTimingsRecorder>();
|
||||
|
||||
@@ -276,13 +252,13 @@ TEST(FrameTimingsRecorderTest, ClonedHasSameRasterEnd) {
|
||||
TEST(FrameTimingsRecorderTest, ClonedHasSameRasterEndWithCache) {
|
||||
auto recorder = std::make_unique<FrameTimingsRecorder>();
|
||||
MockRasterCache cache(1, 10);
|
||||
cache.SweepAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
const auto now = fml::TimePoint::Now();
|
||||
recorder->RecordVsync(now, now + fml::TimeDelta::FromMilliseconds(16));
|
||||
recorder->RecordBuildStart(fml::TimePoint::Now());
|
||||
recorder->RecordBuildEnd(fml::TimePoint::Now());
|
||||
recorder->RecordRasterStart(fml::TimePoint::Now(), &cache);
|
||||
recorder->RecordRasterStart(fml::TimePoint::Now());
|
||||
|
||||
cache.AddMockLayer(100, 100);
|
||||
size_t layer_bytes = cache.EstimateLayerCacheByteSize();
|
||||
@@ -291,6 +267,7 @@ TEST(FrameTimingsRecorderTest, ClonedHasSameRasterEndWithCache) {
|
||||
size_t picture_bytes = cache.EstimatePictureCacheByteSize();
|
||||
EXPECT_GT(picture_bytes, 0u);
|
||||
|
||||
cache.CleanupAfterFrame();
|
||||
recorder->RecordRasterEnd(&cache);
|
||||
|
||||
auto cloned = recorder->CloneUntil(FrameTimingsRecorder::State::kRasterEnd);
|
||||
|
||||
@@ -380,20 +380,26 @@ bool RasterCache::Draw(const Layer* layer,
|
||||
return false;
|
||||
}
|
||||
|
||||
void RasterCache::SweepAfterFrame() {
|
||||
TraceStatsToTimeline();
|
||||
SweepOneCacheAfterFrame(picture_cache_);
|
||||
SweepOneCacheAfterFrame(display_list_cache_);
|
||||
SweepOneCacheAfterFrame(layer_cache_);
|
||||
void RasterCache::PrepareNewFrame() {
|
||||
picture_cached_this_frame_ = 0;
|
||||
display_list_cached_this_frame_ = 0;
|
||||
sweep_count_++;
|
||||
}
|
||||
|
||||
void RasterCache::CleanupAfterFrame() {
|
||||
picture_metrics_ = {};
|
||||
layer_metrics_ = {};
|
||||
SweepOneCacheAfterFrame(picture_cache_, picture_metrics_);
|
||||
SweepOneCacheAfterFrame(display_list_cache_, picture_metrics_);
|
||||
SweepOneCacheAfterFrame(layer_cache_, layer_metrics_);
|
||||
TraceStatsToTimeline();
|
||||
}
|
||||
|
||||
void RasterCache::Clear() {
|
||||
picture_cache_.clear();
|
||||
display_list_cache_.clear();
|
||||
layer_cache_.clear();
|
||||
picture_metrics_ = {};
|
||||
layer_metrics_ = {};
|
||||
}
|
||||
|
||||
size_t RasterCache::GetCachedEntriesCount() const {
|
||||
@@ -426,10 +432,10 @@ void RasterCache::TraceStatsToTimeline() const {
|
||||
FML_TRACE_COUNTER(
|
||||
"flutter", //
|
||||
"RasterCache", reinterpret_cast<int64_t>(this), //
|
||||
"LayerCount", GetLayerCachedEntriesCount(), //
|
||||
"LayerMBytes", EstimateLayerCacheByteSize() / kMegaByteSizeInBytes, //
|
||||
"PictureCount", GetPictureCachedEntriesCount(), //
|
||||
"PictureMBytes", EstimatePictureCacheByteSize() / kMegaByteSizeInBytes);
|
||||
"LayerCount", layer_metrics_.total_count(), //
|
||||
"LayerMBytes", layer_metrics_.total_bytes() / kMegaByteSizeInBytes, //
|
||||
"PictureCount", picture_metrics_.total_count(), //
|
||||
"PictureMBytes", picture_metrics_.total_bytes() / kMegaByteSizeInBytes);
|
||||
|
||||
#endif // !FLUTTER_RELEASE
|
||||
}
|
||||
|
||||
@@ -44,6 +44,42 @@ class RasterCacheResult {
|
||||
|
||||
struct PrerollContext;
|
||||
|
||||
struct RasterCacheMetrics {
|
||||
/**
|
||||
* The number of cache entries with images evicted in this frame.
|
||||
*/
|
||||
size_t eviction_count = 0;
|
||||
|
||||
/**
|
||||
* The size of all of the images evicted in this frame.
|
||||
*/
|
||||
size_t eviction_bytes = 0;
|
||||
|
||||
/**
|
||||
* The number of cache entries with images used in this frame.
|
||||
*/
|
||||
size_t in_use_count = 0;
|
||||
|
||||
/**
|
||||
* The size of all of the images used in this frame.
|
||||
*/
|
||||
size_t in_use_bytes = 0;
|
||||
|
||||
/**
|
||||
* The total cache entries that had images during this frame whether
|
||||
* they were used in the frame or held memory during the frame and then
|
||||
* were evicted after it ended.
|
||||
*/
|
||||
size_t total_count() const { return in_use_count + eviction_count; }
|
||||
|
||||
/**
|
||||
* The size of all of the cached images during this frame whether
|
||||
* they were used in the frame or held memory during the frame and then
|
||||
* were evicted after it ended.
|
||||
*/
|
||||
size_t total_bytes() const { return in_use_bytes + eviction_bytes; }
|
||||
};
|
||||
|
||||
class RasterCache {
|
||||
public:
|
||||
// The default max number of picture and display list raster caches to be
|
||||
@@ -178,16 +214,29 @@ class RasterCache {
|
||||
SkCanvas& canvas,
|
||||
SkPaint* paint = nullptr) const;
|
||||
|
||||
void SweepAfterFrame();
|
||||
void PrepareNewFrame();
|
||||
void CleanupAfterFrame();
|
||||
|
||||
void Clear();
|
||||
|
||||
void SetCheckboardCacheImages(bool checkerboard);
|
||||
|
||||
const RasterCacheMetrics& picture_metrics() const { return picture_metrics_; }
|
||||
const RasterCacheMetrics& layer_metrics() const { return layer_metrics_; }
|
||||
|
||||
size_t GetCachedEntriesCount() const;
|
||||
|
||||
/**
|
||||
* Return the number of map entries in the layer cache regardless of whether
|
||||
* the entries have been populated with an image.
|
||||
*/
|
||||
size_t GetLayerCachedEntriesCount() const;
|
||||
|
||||
/**
|
||||
* Return the number of map entries in the picture caches (SkPicture and
|
||||
* DisplayList) regardless of whether the entries have been populated with
|
||||
* an image.
|
||||
*/
|
||||
size_t GetPictureCachedEntriesCount() const;
|
||||
|
||||
/**
|
||||
@@ -211,15 +260,6 @@ class RasterCache {
|
||||
*/
|
||||
size_t EstimateLayerCacheByteSize() const;
|
||||
|
||||
/**
|
||||
* @brief Return the count of cache sweeps that have occured.
|
||||
*
|
||||
* The sweep count will help to determine if a sweep of the cache may have
|
||||
* removed expired entries since the last time the method was called.
|
||||
* The count will increment even if the sweep performs no evictions.
|
||||
*/
|
||||
int sweep_count() const { return sweep_count_; }
|
||||
|
||||
/**
|
||||
* @brief Return the number of frames that a picture must be prepared
|
||||
* before it will be cached. If the number is 0, then no picture will
|
||||
@@ -238,18 +278,26 @@ class RasterCache {
|
||||
};
|
||||
|
||||
template <class Cache>
|
||||
static void SweepOneCacheAfterFrame(Cache& cache) {
|
||||
static void SweepOneCacheAfterFrame(Cache& cache,
|
||||
RasterCacheMetrics& metrics) {
|
||||
std::vector<typename Cache::iterator> dead;
|
||||
|
||||
for (auto it = cache.begin(); it != cache.end(); ++it) {
|
||||
Entry& entry = it->second;
|
||||
if (!entry.used_this_frame) {
|
||||
dead.push_back(it);
|
||||
} else if (entry.image) {
|
||||
metrics.in_use_count++;
|
||||
metrics.in_use_bytes += entry.image->image_bytes();
|
||||
}
|
||||
entry.used_this_frame = false;
|
||||
}
|
||||
|
||||
for (auto it : dead) {
|
||||
if (it->second.image) {
|
||||
metrics.eviction_count++;
|
||||
metrics.eviction_bytes += it->second.image->image_bytes();
|
||||
}
|
||||
cache.erase(it);
|
||||
}
|
||||
}
|
||||
@@ -265,7 +313,8 @@ class RasterCache {
|
||||
const size_t picture_and_display_list_cache_limit_per_frame_;
|
||||
size_t picture_cached_this_frame_ = 0;
|
||||
size_t display_list_cached_this_frame_ = 0;
|
||||
int sweep_count_ = 0;
|
||||
RasterCacheMetrics layer_metrics_;
|
||||
RasterCacheMetrics picture_metrics_;
|
||||
mutable PictureRasterCacheKey::Map<Entry> picture_cache_;
|
||||
mutable DisplayListRasterCacheKey::Map<Entry> display_list_cache_;
|
||||
mutable LayerRasterCacheKey::Map<Entry> layer_cache_;
|
||||
|
||||
@@ -83,12 +83,15 @@ TEST(RasterCache, ThresholdIsRespectedForSkPicture) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, matrix));
|
||||
// 1st access.
|
||||
ASSERT_FALSE(cache.Draw(*picture, dummy_canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.CleanupAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, matrix));
|
||||
@@ -96,7 +99,8 @@ TEST(RasterCache, ThresholdIsRespectedForSkPicture) {
|
||||
// 2nd access.
|
||||
ASSERT_FALSE(cache.Draw(*picture, dummy_canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.CleanupAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
// Now Prepare should cache it.
|
||||
ASSERT_TRUE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
@@ -104,6 +108,52 @@ TEST(RasterCache, ThresholdIsRespectedForSkPicture) {
|
||||
ASSERT_TRUE(cache.Draw(*picture, dummy_canvas));
|
||||
}
|
||||
|
||||
TEST(RasterCache, MetricsOmitUnpopulatedEntries) {
|
||||
size_t threshold = 2;
|
||||
flutter::RasterCache cache(threshold);
|
||||
|
||||
SkMatrix matrix = SkMatrix::I();
|
||||
|
||||
auto picture = GetSamplePicture();
|
||||
|
||||
SkCanvas dummy_canvas;
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, matrix));
|
||||
// 1st access.
|
||||
ASSERT_FALSE(cache.Draw(*picture, dummy_canvas));
|
||||
|
||||
cache.CleanupAfterFrame();
|
||||
ASSERT_EQ(cache.picture_metrics().total_count(), 0u);
|
||||
ASSERT_EQ(cache.picture_metrics().total_bytes(), 0u);
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, matrix));
|
||||
|
||||
// 2nd access.
|
||||
ASSERT_FALSE(cache.Draw(*picture, dummy_canvas));
|
||||
|
||||
cache.CleanupAfterFrame();
|
||||
ASSERT_EQ(cache.picture_metrics().total_count(), 0u);
|
||||
ASSERT_EQ(cache.picture_metrics().total_bytes(), 0u);
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
// Now Prepare should cache it.
|
||||
ASSERT_TRUE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, matrix));
|
||||
ASSERT_TRUE(cache.Draw(*picture, dummy_canvas));
|
||||
|
||||
cache.CleanupAfterFrame();
|
||||
ASSERT_EQ(cache.picture_metrics().total_count(), 1u);
|
||||
// 150w * 100h * 4bpp
|
||||
ASSERT_EQ(cache.picture_metrics().total_bytes(), 60000u);
|
||||
}
|
||||
|
||||
TEST(RasterCache, ThresholdIsRespectedForDisplayList) {
|
||||
size_t threshold = 2;
|
||||
flutter::RasterCache cache(threshold);
|
||||
@@ -116,12 +166,15 @@ TEST(RasterCache, ThresholdIsRespectedForDisplayList) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
display_list.get(), true, false, matrix));
|
||||
// 1st access.
|
||||
ASSERT_FALSE(cache.Draw(*display_list, dummy_canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.CleanupAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
display_list.get(), true, false, matrix));
|
||||
@@ -129,7 +182,8 @@ TEST(RasterCache, ThresholdIsRespectedForDisplayList) {
|
||||
// 2nd access.
|
||||
ASSERT_FALSE(cache.Draw(*display_list, dummy_canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.CleanupAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
// Now Prepare should cache it.
|
||||
ASSERT_TRUE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
@@ -149,6 +203,8 @@ TEST(RasterCache, AccessThresholdOfZeroDisablesCachingForSkPicture) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, matrix));
|
||||
|
||||
@@ -167,6 +223,8 @@ TEST(RasterCache, AccessThresholdOfZeroDisablesCachingForDisplayList) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
display_list.get(), true, false, matrix));
|
||||
|
||||
@@ -185,6 +243,8 @@ TEST(RasterCache, PictureCacheLimitPerFrameIsRespectedWhenZeroForSkPicture) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, matrix));
|
||||
|
||||
@@ -203,6 +263,8 @@ TEST(RasterCache, PictureCacheLimitPerFrameIsRespectedWhenZeroForDisplayList) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
display_list.get(), true, false, matrix));
|
||||
|
||||
@@ -221,18 +283,25 @@ TEST(RasterCache, SweepsRemoveUnusedSkPictures) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, matrix)); // 1
|
||||
ASSERT_FALSE(cache.Draw(*picture, dummy_canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.CleanupAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_TRUE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, matrix)); // 2
|
||||
ASSERT_TRUE(cache.Draw(*picture, dummy_canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.SweepAfterFrame(); // Extra frame without a Get image access.
|
||||
cache.CleanupAfterFrame();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
cache.CleanupAfterFrame(); // Extra frame without a Get image access.
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Draw(*picture, dummy_canvas));
|
||||
}
|
||||
@@ -249,18 +318,25 @@ TEST(RasterCache, SweepsRemoveUnusedDisplayLists) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
display_list.get(), true, false, matrix)); // 1
|
||||
ASSERT_FALSE(cache.Draw(*display_list, dummy_canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.CleanupAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_TRUE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
display_list.get(), true, false, matrix)); // 2
|
||||
ASSERT_TRUE(cache.Draw(*display_list, dummy_canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.SweepAfterFrame(); // Extra frame without a Get image access.
|
||||
cache.CleanupAfterFrame();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
cache.CleanupAfterFrame(); // Extra frame without a Get image access.
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Draw(*display_list, dummy_canvas));
|
||||
}
|
||||
@@ -287,11 +363,14 @@ TEST(RasterCache, DeviceRectRoundOutForSkPicture) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, ctm));
|
||||
ASSERT_FALSE(cache.Draw(*picture, canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.CleanupAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_TRUE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), true, false, ctm));
|
||||
@@ -321,11 +400,14 @@ TEST(RasterCache, DeviceRectRoundOutForDisplayList) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
display_list.get(), true, false, ctm));
|
||||
ASSERT_FALSE(cache.Draw(*display_list, canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.CleanupAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_TRUE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
display_list.get(), true, false, ctm));
|
||||
@@ -349,11 +431,14 @@ TEST(RasterCache, NestedOpCountMetricUsedForSkPicture) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), false, false, matrix));
|
||||
ASSERT_FALSE(cache.Draw(*picture, dummy_canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.CleanupAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_TRUE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
picture.get(), false, false, matrix));
|
||||
@@ -374,11 +459,14 @@ TEST(RasterCache, NestedOpCountMetricUsedForDisplayList) {
|
||||
|
||||
PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder();
|
||||
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_FALSE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
display_list.get(), false, false, matrix));
|
||||
ASSERT_FALSE(cache.Draw(*display_list, dummy_canvas));
|
||||
|
||||
cache.SweepAfterFrame();
|
||||
cache.CleanupAfterFrame();
|
||||
cache.PrepareNewFrame();
|
||||
|
||||
ASSERT_TRUE(cache.Prepare(&preroll_context_holder.preroll_context,
|
||||
display_list.get(), false, false, matrix));
|
||||
|
||||
@@ -147,8 +147,6 @@ void Rasterizer::DrawLastLayerTree(
|
||||
if (!last_layer_tree_ || !surface_) {
|
||||
return;
|
||||
}
|
||||
frame_timings_recorder->RecordRasterStart(
|
||||
fml::TimePoint::Now(), &compositor_context_->raster_cache());
|
||||
DrawToSurface(*frame_timings_recorder, *last_layer_tree_);
|
||||
}
|
||||
|
||||
@@ -381,9 +379,6 @@ RasterStatus Rasterizer::DoDraw(
|
||||
return RasterStatus::kFailed;
|
||||
}
|
||||
|
||||
frame_timings_recorder->RecordRasterStart(
|
||||
fml::TimePoint::Now(), &compositor_context_->raster_cache());
|
||||
|
||||
PersistentCache* persistent_cache = PersistentCache::GetCacheForProcess();
|
||||
persistent_cache->ResetStoredNewShaders();
|
||||
|
||||
@@ -541,6 +536,9 @@ RasterStatus Rasterizer::DrawToSurfaceUnsafe(
|
||||
raster_thread_merger_ // thread merger
|
||||
);
|
||||
if (compositor_frame) {
|
||||
compositor_context_->raster_cache().PrepareNewFrame();
|
||||
frame_timings_recorder.RecordRasterStart(fml::TimePoint::Now());
|
||||
|
||||
RasterStatus raster_status = compositor_frame->Raster(layer_tree, false);
|
||||
if (raster_status == RasterStatus::kFailed ||
|
||||
raster_status == RasterStatus::kSkipAndRetry) {
|
||||
@@ -555,6 +553,7 @@ RasterStatus Rasterizer::DrawToSurfaceUnsafe(
|
||||
frame->Submit();
|
||||
}
|
||||
|
||||
compositor_context_->raster_cache().CleanupAfterFrame();
|
||||
frame_timings_recorder.RecordRasterEnd(
|
||||
&compositor_context_->raster_cache());
|
||||
FireNextFrameCallbackIfPresent();
|
||||
|
||||
Reference in New Issue
Block a user