mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This caused over-aggressive GCs, which vastly increased CPU usage benchmarks. * Revert "fix build (#20644)" This reverts commit b59793ee20be29463fac7a79635bf20253f04107. * Revert "Hint freed (#19842)" This reverts commit 3930ac1b25820baee3c67d921a0b009606cb3dae.
66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/flow/layers/picture_layer.h"
|
|
|
|
#include "flutter/fml/logging.h"
|
|
|
|
namespace flutter {
|
|
|
|
PictureLayer::PictureLayer(const SkPoint& offset,
|
|
SkiaGPUObject<SkPicture> picture,
|
|
bool is_complex,
|
|
bool will_change)
|
|
: offset_(offset),
|
|
picture_(std::move(picture)),
|
|
is_complex_(is_complex),
|
|
will_change_(will_change) {}
|
|
|
|
void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
|
TRACE_EVENT0("flutter", "PictureLayer::Preroll");
|
|
|
|
#if defined(LEGACY_FUCHSIA_EMBEDDER)
|
|
CheckForChildLayerBelow(context);
|
|
#endif
|
|
|
|
SkPicture* sk_picture = picture();
|
|
|
|
if (auto* cache = context->raster_cache) {
|
|
TRACE_EVENT0("flutter", "PictureLayer::RasterCache (Preroll)");
|
|
|
|
SkMatrix ctm = matrix;
|
|
ctm.postTranslate(offset_.x(), offset_.y());
|
|
#ifndef SUPPORT_FRACTIONAL_TRANSLATION
|
|
ctm = RasterCache::GetIntegralTransCTM(ctm);
|
|
#endif
|
|
cache->Prepare(context->gr_context, sk_picture, ctm,
|
|
context->dst_color_space, is_complex_, will_change_);
|
|
}
|
|
|
|
SkRect bounds = sk_picture->cullRect().makeOffset(offset_.x(), offset_.y());
|
|
set_paint_bounds(bounds);
|
|
}
|
|
|
|
void PictureLayer::Paint(PaintContext& context) const {
|
|
TRACE_EVENT0("flutter", "PictureLayer::Paint");
|
|
FML_DCHECK(picture_.get());
|
|
FML_DCHECK(needs_painting());
|
|
|
|
SkAutoCanvasRestore save(context.leaf_nodes_canvas, true);
|
|
context.leaf_nodes_canvas->translate(offset_.x(), offset_.y());
|
|
#ifndef SUPPORT_FRACTIONAL_TRANSLATION
|
|
context.leaf_nodes_canvas->setMatrix(RasterCache::GetIntegralTransCTM(
|
|
context.leaf_nodes_canvas->getTotalMatrix()));
|
|
#endif
|
|
|
|
if (context.raster_cache &&
|
|
context.raster_cache->Draw(*picture(), *context.leaf_nodes_canvas)) {
|
|
TRACE_EVENT_INSTANT0("flutter", "raster cache hit");
|
|
return;
|
|
}
|
|
picture()->playback(context.leaf_nodes_canvas);
|
|
}
|
|
|
|
} // namespace flutter
|