mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
The size of the LTO build of the engine with the dylib compressed is as follows: ```sh $ du -k libFlutter* 5236 libFlutter.dylib.tar.gz 4324 libFlutterSlimpeller.dylib.tar.gz ``` Sizes are in KiB. This represents a binary size reduction of 17.41% of the compressed artifacts. The compression ratios will likely differ based on the compression scheme. Uncompressed, the sizes are: ```sh $ du -k libFlutter* 16920 libFlutter.dylib 14044 libFlutterSlimpeller.dylib ``` This represents a binary size reduction of 16.99% which is in the same ballpark. The really mucky bit was backing out the raster cache and persistent cache. I want to clean that up in a later patch so that those TUs are part of a separate submodule. Opting out of Impeller will lead to a fatal log at startup saying the opt-out is disallowed. Fixes https://github.com/flutter/flutter/issues/126606
91 lines
2.6 KiB
C++
91 lines
2.6 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/surface_frame.h"
|
|
|
|
#include <limits>
|
|
#include <utility>
|
|
|
|
#include "flutter/fml/logging.h"
|
|
#include "flutter/fml/trace_event.h"
|
|
|
|
#include "third_party/skia/include/core/SkSurface.h"
|
|
#include "third_party/skia/include/utils/SkNWayCanvas.h"
|
|
|
|
namespace flutter {
|
|
|
|
SurfaceFrame::SurfaceFrame(sk_sp<SkSurface> surface,
|
|
FramebufferInfo framebuffer_info,
|
|
const SubmitCallback& submit_callback,
|
|
SkISize frame_size,
|
|
std::unique_ptr<GLContextResult> context_result,
|
|
bool display_list_fallback)
|
|
: surface_(std::move(surface)),
|
|
framebuffer_info_(framebuffer_info),
|
|
submit_callback_(submit_callback),
|
|
context_result_(std::move(context_result)) {
|
|
FML_DCHECK(submit_callback_);
|
|
if (surface_) {
|
|
#if !SLIMPELLER
|
|
adapter_.set_canvas(surface_->getCanvas());
|
|
canvas_ = &adapter_;
|
|
#else // !SLIMPELLER
|
|
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
|
return;
|
|
#endif // !SLIMPELLER
|
|
} else if (display_list_fallback) {
|
|
FML_DCHECK(!frame_size.isEmpty());
|
|
// The root frame of a surface will be filled by the layer_tree which
|
|
// performs branch culling so it will be unlikely to need an rtree for
|
|
// further culling during `DisplayList::Dispatch`. Further, this canvas
|
|
// will live underneath any platform views so we do not need to compute
|
|
// exact coverage to describe "pixel ownership" to the platform.
|
|
dl_builder_ = sk_make_sp<DisplayListBuilder>(SkRect::Make(frame_size),
|
|
/*prepare_rtree=*/false);
|
|
canvas_ = dl_builder_.get();
|
|
}
|
|
}
|
|
|
|
bool SurfaceFrame::Submit() {
|
|
TRACE_EVENT0("flutter", "SurfaceFrame::Submit");
|
|
if (submitted_) {
|
|
return false;
|
|
}
|
|
|
|
submitted_ = PerformSubmit();
|
|
|
|
return submitted_;
|
|
}
|
|
|
|
bool SurfaceFrame::IsSubmitted() const {
|
|
return submitted_;
|
|
}
|
|
|
|
DlCanvas* SurfaceFrame::Canvas() {
|
|
return canvas_;
|
|
}
|
|
|
|
sk_sp<SkSurface> SurfaceFrame::SkiaSurface() const {
|
|
return surface_;
|
|
}
|
|
|
|
bool SurfaceFrame::PerformSubmit() {
|
|
if (submit_callback_ == nullptr) {
|
|
return false;
|
|
}
|
|
|
|
if (submit_callback_(*this, Canvas())) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
sk_sp<DisplayList> SurfaceFrame::BuildDisplayList() {
|
|
TRACE_EVENT0("impeller", "SurfaceFrame::BuildDisplayList");
|
|
return dl_builder_ ? dl_builder_->Build() : nullptr;
|
|
}
|
|
|
|
} // namespace flutter
|