[Impeller] Prepare a SkiaGPU-less iOS build. (flutter/engine#52748)
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
This commit is contained in:
@@ -305,6 +305,87 @@
|
||||
"script": "flutter/testing/scenario_app/run_ios_tests.sh"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cas_archive": false,
|
||||
"drone_dimensions":
|
||||
[
|
||||
"os=Mac-13",
|
||||
"device_type=none"
|
||||
],
|
||||
"gclient_variables":
|
||||
{
|
||||
"download_android_deps": false,
|
||||
"use_rbe": true
|
||||
},
|
||||
"gn":
|
||||
[
|
||||
"--ios",
|
||||
"--runtime-mode",
|
||||
"release",
|
||||
"--no-stripped",
|
||||
"--no-lto",
|
||||
"--xcode-symlinks",
|
||||
"--rbe",
|
||||
"--no-goma",
|
||||
"--slimpeller"
|
||||
],
|
||||
"name": "ci/macos/ios_release_slimpeller",
|
||||
"description": "Builds a Slimpeller release mode engine that targets iOS from a macOS host.",
|
||||
"ninja":
|
||||
{
|
||||
"config": "ios_release_slimpeller",
|
||||
"targets":
|
||||
[]
|
||||
},
|
||||
"properties":
|
||||
{
|
||||
"$flutter/osx_sdk":
|
||||
{
|
||||
"sdk_version": "15a240d"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cas_archive": false,
|
||||
"drone_dimensions":
|
||||
[
|
||||
"os=Mac-13",
|
||||
"device_type=none"
|
||||
],
|
||||
"gclient_variables":
|
||||
{
|
||||
"download_android_deps": false,
|
||||
"use_rbe": true
|
||||
},
|
||||
"gn":
|
||||
[
|
||||
"--ios",
|
||||
"--runtime-mode",
|
||||
"debug",
|
||||
"--unoptimized",
|
||||
"--no-stripped",
|
||||
"--no-lto",
|
||||
"--xcode-symlinks",
|
||||
"--rbe",
|
||||
"--no-goma",
|
||||
"--slimpeller"
|
||||
],
|
||||
"name": "ci/macos/ios_debug_unopt_slimpeller",
|
||||
"description": "Builds an unoptimized debug mode engine with Slimpeller that targets iOS from a macOS host.",
|
||||
"ninja":
|
||||
{
|
||||
"config": "ios_debug_unopt_slimpeller",
|
||||
"targets":
|
||||
[]
|
||||
},
|
||||
"properties":
|
||||
{
|
||||
"$flutter/osx_sdk":
|
||||
{
|
||||
"sdk_version": "15a240d"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -39877,6 +39877,7 @@ ORIGIN: ../../../flutter/common/graphics/persistent_cache.cc + ../../../flutter/
|
||||
ORIGIN: ../../../flutter/common/graphics/persistent_cache.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/common/graphics/texture.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/common/graphics/texture.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/common/macros.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/common/settings.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/common/settings.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/common/task_runners.cc + ../../../flutter/LICENSE
|
||||
@@ -42752,6 +42753,7 @@ FILE: ../../../flutter/common/graphics/persistent_cache.cc
|
||||
FILE: ../../../flutter/common/graphics/persistent_cache.h
|
||||
FILE: ../../../flutter/common/graphics/texture.cc
|
||||
FILE: ../../../flutter/common/graphics/texture.h
|
||||
FILE: ../../../flutter/common/macros.h
|
||||
FILE: ../../../flutter/common/settings.cc
|
||||
FILE: ../../../flutter/common/settings.h
|
||||
FILE: ../../../flutter/common/task_runners.cc
|
||||
|
||||
@@ -10,6 +10,7 @@ config("flutter_config") {
|
||||
|
||||
source_set("common") {
|
||||
sources = [
|
||||
"macros.h",
|
||||
"settings.cc",
|
||||
"settings.h",
|
||||
"task_runners.cc",
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/common/graphics/persistent_cache.h"
|
||||
|
||||
#include <future>
|
||||
@@ -483,3 +485,5 @@ PersistentCache::GetSkpsFromAssetManager() const {
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_COMMON_GRAPHICS_PERSISTENT_CACHE_H_
|
||||
#define FLUTTER_COMMON_GRAPHICS_PERSISTENT_CACHE_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
@@ -179,4 +181,6 @@ class PersistentCache : public GrContextOptions::PersistentCache {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_COMMON_GRAPHICS_PERSISTENT_CACHE_H_
|
||||
|
||||
20
engine/src/flutter/common/macros.h
Normal file
20
engine/src/flutter/common/macros.h
Normal file
@@ -0,0 +1,20 @@
|
||||
// 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.
|
||||
|
||||
#ifndef FLUTTER_COMMON_MACROS_H_
|
||||
#define FLUTTER_COMMON_MACROS_H_
|
||||
|
||||
#if SLIMPELLER
|
||||
|
||||
#define ONLY_IN_SLIMPELLER(code) code
|
||||
#define NOT_SLIMPELLER(code)
|
||||
|
||||
#else // SLIMPELLER
|
||||
|
||||
#define ONLY_IN_SLIMPELLER(code)
|
||||
#define NOT_SLIMPELLER(code) code
|
||||
|
||||
#endif // SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_COMMON_MACROS_H_
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/display_list/skia/dl_sk_canvas.h"
|
||||
|
||||
#include "flutter/display_list/skia/dl_sk_conversions.h"
|
||||
@@ -352,3 +354,5 @@ void DlSkCanvasAdapter::Flush() {
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_DISPLAY_LIST_SKIA_DL_SK_CANVAS_H_
|
||||
#define FLUTTER_DISPLAY_LIST_SKIA_DL_SK_CANVAS_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/display_list/dl_canvas.h"
|
||||
#include "flutter/display_list/skia/dl_sk_types.h"
|
||||
#include "impeller/typographer/text_frame.h"
|
||||
@@ -163,4 +165,6 @@ class DlSkCanvasAdapter final : public virtual DlCanvas {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_DISPLAY_LIST_SKIA_DL_SK_CANVAS_H_
|
||||
|
||||
@@ -224,12 +224,16 @@ bool CompositorContext::ShouldPerformPartialRepaint(
|
||||
|
||||
void CompositorContext::OnGrContextCreated() {
|
||||
texture_registry_->OnGrContextCreated();
|
||||
#if !SLIMPELLER
|
||||
raster_cache_.Clear();
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
void CompositorContext::OnGrContextDestroyed() {
|
||||
texture_registry_->OnGrContextDestroyed();
|
||||
#if !SLIMPELLER
|
||||
raster_cache_.Clear();
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "flutter/common/graphics/texture.h"
|
||||
#include "flutter/common/macros.h"
|
||||
#include "flutter/flow/diff_context.h"
|
||||
#include "flutter/flow/embedded_views.h"
|
||||
#include "flutter/flow/layer_snapshot_store.h"
|
||||
@@ -182,7 +183,9 @@ class CompositorContext {
|
||||
|
||||
void OnGrContextDestroyed();
|
||||
|
||||
#if !SLIMPELLER
|
||||
RasterCache& raster_cache() { return raster_cache_; }
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
std::shared_ptr<TextureRegistry> texture_registry() {
|
||||
return texture_registry_;
|
||||
@@ -195,7 +198,7 @@ class CompositorContext {
|
||||
LayerSnapshotStore& snapshot_store() { return layer_snapshot_store_; }
|
||||
|
||||
private:
|
||||
RasterCache raster_cache_;
|
||||
NOT_SLIMPELLER(RasterCache raster_cache_);
|
||||
std::shared_ptr<TextureRegistry> texture_registry_;
|
||||
Stopwatch raster_time_;
|
||||
Stopwatch ui_time_;
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/flow/diff_context.h"
|
||||
|
||||
#include "flutter/flow/layers/layer.h"
|
||||
#include "flutter/flow/raster_cache_util.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
|
||||
@@ -206,12 +206,14 @@ FrameTiming FrameTimingsRecorder::RecordRasterEnd(const RasterCache* cache) {
|
||||
raster_end_ = fml::TimePoint::Now();
|
||||
raster_end_wall_time_ = fml::TimePoint::CurrentWallTime();
|
||||
if (cache) {
|
||||
#if !SLIMPELLER
|
||||
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();
|
||||
#endif // !SLIMPELLER
|
||||
} else {
|
||||
layer_cache_count_ = layer_cache_bytes_ = picture_cache_count_ =
|
||||
picture_cache_bytes_ = 0;
|
||||
|
||||
@@ -12,25 +12,35 @@ AutoCache::AutoCache(RasterCacheItem* raster_cache_item,
|
||||
: raster_cache_item_(raster_cache_item),
|
||||
context_(context),
|
||||
matrix_(matrix) {
|
||||
#if !SLIMPELLER
|
||||
if (IsCacheEnabled()) {
|
||||
raster_cache_item->PrerollSetup(context, matrix);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
bool AutoCache::IsCacheEnabled() {
|
||||
#if SLIMPELLER
|
||||
return false;
|
||||
#else // SLIMPELLER
|
||||
return raster_cache_item_ && context_ && context_->raster_cache;
|
||||
#endif // SLIMPELLER
|
||||
}
|
||||
|
||||
AutoCache::~AutoCache() {
|
||||
#if !SLIMPELLER
|
||||
if (IsCacheEnabled()) {
|
||||
raster_cache_item_->PrerollFinalize(context_, matrix_);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
CacheableContainerLayer::CacheableContainerLayer(int layer_cached_threshold,
|
||||
bool can_cache_children) {
|
||||
#if !SLIMPELLER
|
||||
layer_raster_cache_item_ = LayerRasterCacheItem::Make(
|
||||
this, layer_cached_threshold, can_cache_children);
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "flutter/flow/layers/container_layer.h"
|
||||
#include "flutter/flow/layers/layer_raster_cache_item.h"
|
||||
#include "flutter/flow/raster_cache_util.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
@@ -25,7 +26,7 @@ class AutoCache {
|
||||
private:
|
||||
inline bool IsCacheEnabled();
|
||||
RasterCacheItem* raster_cache_item_ = nullptr;
|
||||
PrerollContext* context_ = nullptr;
|
||||
[[maybe_unused]] PrerollContext* context_ = nullptr;
|
||||
const SkMatrix matrix_;
|
||||
};
|
||||
|
||||
@@ -36,12 +37,14 @@ class CacheableContainerLayer : public ContainerLayer {
|
||||
RasterCacheUtil::kMinimumRendersBeforeCachingFilterLayer,
|
||||
bool can_cache_children = false);
|
||||
|
||||
#if !SLIMPELLER
|
||||
const LayerRasterCacheItem* raster_cache_item() const {
|
||||
return layer_raster_cache_item_.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<LayerRasterCacheItem> layer_raster_cache_item_;
|
||||
#endif // !SLIMPELLER
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@@ -44,12 +44,14 @@ class ClipShapeLayer : public CacheableContainerLayer {
|
||||
void Preroll(PrerollContext* context) override {
|
||||
bool uses_save_layer = UsesSaveLayer();
|
||||
|
||||
#if !SLIMPELLER
|
||||
// We can use the raster_cache for children only when the use_save_layer is
|
||||
// true so if use_save_layer is false we pass the layer_raster_item is
|
||||
// nullptr which mean we don't do raster cache logic.
|
||||
AutoCache cache =
|
||||
AutoCache(uses_save_layer ? layer_raster_cache_item_.get() : nullptr,
|
||||
context, context->state_stack.transform_3x3());
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
Layer::AutoPrerollSaveLayerState save =
|
||||
Layer::AutoPrerollSaveLayerState::Create(context, UsesSaveLayer());
|
||||
@@ -83,6 +85,7 @@ class ClipShapeLayer : public CacheableContainerLayer {
|
||||
return;
|
||||
}
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (context.raster_cache) {
|
||||
mutator.integralTransform();
|
||||
auto restore_apply = context.state_stack.applyState(
|
||||
@@ -94,6 +97,7 @@ class ClipShapeLayer : public CacheableContainerLayer {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
mutator.saveLayer(paint_bounds());
|
||||
PaintChildren(context);
|
||||
|
||||
@@ -39,8 +39,10 @@ void ColorFilterLayer::Diff(DiffContext* context, const Layer* old_layer) {
|
||||
void ColorFilterLayer::Preroll(PrerollContext* context) {
|
||||
Layer::AutoPrerollSaveLayerState save =
|
||||
Layer::AutoPrerollSaveLayerState::Create(context);
|
||||
#if !SLIMPELLER
|
||||
AutoCache cache = AutoCache(layer_raster_cache_item_.get(), context,
|
||||
context->state_stack.transform_3x3());
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
ContainerLayer::Preroll(context);
|
||||
|
||||
@@ -66,6 +68,7 @@ void ColorFilterLayer::Paint(PaintContext& context) const {
|
||||
|
||||
auto mutator = context.state_stack.save();
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (context.raster_cache) {
|
||||
// Always apply the integral transform in the presence of a raster cache
|
||||
// whether or not we will draw from the cache
|
||||
@@ -81,11 +84,13 @@ void ColorFilterLayer::Paint(PaintContext& context) const {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
// Now apply the color filter and then try rendering children either from
|
||||
// cache or directly.
|
||||
mutator.applyColorFilter(paint_bounds(), filter_);
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (context.raster_cache && layer_raster_cache_item_->IsCacheChildren()) {
|
||||
DlPaint paint;
|
||||
if (layer_raster_cache_item_->Draw(context,
|
||||
@@ -93,6 +98,7 @@ void ColorFilterLayer::Paint(PaintContext& context) const {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
PaintChildren(context);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@ DisplayListLayer::DisplayListLayer(const SkPoint& offset,
|
||||
: offset_(offset), display_list_(std::move(display_list)) {
|
||||
if (display_list_) {
|
||||
bounds_ = display_list_->bounds().makeOffset(offset_.x(), offset_.y());
|
||||
#if !SLIMPELLER
|
||||
display_list_raster_cache_item_ = DisplayListRasterCacheItem::Make(
|
||||
display_list_, offset_, is_complex, will_change);
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,8 +97,10 @@ bool DisplayListLayer::Compare(DiffContext::Statistics& statistics,
|
||||
void DisplayListLayer::Preroll(PrerollContext* context) {
|
||||
DisplayList* disp_list = display_list();
|
||||
|
||||
#if !SLIMPELLER
|
||||
AutoCache cache = AutoCache(display_list_raster_cache_item_.get(), context,
|
||||
context->state_stack.transform_3x3());
|
||||
#endif // !SLIMPELLER
|
||||
if (disp_list->can_apply_group_opacity()) {
|
||||
context->renderable_state_flags = LayerStateStack::kCallerCanApplyOpacity;
|
||||
}
|
||||
@@ -110,6 +114,7 @@ void DisplayListLayer::Paint(PaintContext& context) const {
|
||||
auto mutator = context.state_stack.save();
|
||||
mutator.translate(offset_.x(), offset_.y());
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (context.raster_cache) {
|
||||
// Always apply the integral transform in the presence of a raster cache
|
||||
// whether or not we successfully draw from the cache
|
||||
@@ -124,9 +129,12 @@ void DisplayListLayer::Paint(PaintContext& context) const {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
SkScalar opacity = context.state_stack.outstanding_opacity();
|
||||
|
||||
#if !SLIMPELLER
|
||||
// Leaf layer tracing was never supported in the Impeller backend.
|
||||
if (context.enable_leaf_layer_tracing) {
|
||||
const auto canvas_size = context.canvas->GetBaseLayerSize();
|
||||
auto offscreen_surface =
|
||||
@@ -156,6 +164,7 @@ void DisplayListLayer::Paint(PaintContext& context) const {
|
||||
raster_data, device_bounds);
|
||||
context.layer_snapshot_store->Add(snapshot_data);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
context.canvas->DrawDisplayList(display_list_, opacity);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/common/macros.h"
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/flow/layers/display_list_raster_cache_item.h"
|
||||
#include "flutter/flow/layers/layer.h"
|
||||
@@ -37,6 +38,7 @@ class DisplayListLayer : public Layer {
|
||||
|
||||
void Paint(PaintContext& context) const override;
|
||||
|
||||
#if !SLIMPELLER
|
||||
const DisplayListRasterCacheItem* raster_cache_item() const {
|
||||
return display_list_raster_cache_item_.get();
|
||||
}
|
||||
@@ -45,9 +47,11 @@ class DisplayListLayer : public Layer {
|
||||
return RasterCacheKeyID(display_list()->unique_id(),
|
||||
RasterCacheKeyType::kDisplayList);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
private:
|
||||
std::unique_ptr<DisplayListRasterCacheItem> display_list_raster_cache_item_;
|
||||
NOT_SLIMPELLER(std::unique_ptr<DisplayListRasterCacheItem>
|
||||
display_list_raster_cache_item_);
|
||||
|
||||
SkPoint offset_;
|
||||
SkRect bounds_;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/flow/layers/display_list_raster_cache_item.h"
|
||||
|
||||
#include <optional>
|
||||
@@ -174,3 +176,5 @@ bool DisplayListRasterCacheItem::TryToPrepareRasterCache(
|
||||
display_list_->rtree());
|
||||
}
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_FLOW_LAYERS_DISPLAY_LIST_RASTER_CACHE_ITEM_H_
|
||||
#define FLUTTER_FLOW_LAYERS_DISPLAY_LIST_RASTER_CACHE_ITEM_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
@@ -59,4 +61,10 @@ class DisplayListRasterCacheItem : public RasterCacheItem {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#else // !SLIMPELLER
|
||||
|
||||
class DisplayListRasterCacheItem;
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_FLOW_LAYERS_DISPLAY_LIST_RASTER_CACHE_ITEM_H_
|
||||
|
||||
@@ -56,8 +56,10 @@ void ImageFilterLayer::Preroll(PrerollContext* context) {
|
||||
Layer::AutoPrerollSaveLayerState save =
|
||||
Layer::AutoPrerollSaveLayerState::Create(context);
|
||||
|
||||
#if !SLIMPELLER
|
||||
AutoCache cache = AutoCache(layer_raster_cache_item_.get(), context,
|
||||
context->state_stack.transform_3x3());
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
SkRect child_bounds = SkRect::MakeEmpty();
|
||||
|
||||
@@ -85,15 +87,20 @@ void ImageFilterLayer::Preroll(PrerollContext* context) {
|
||||
|
||||
set_paint_bounds(child_bounds);
|
||||
|
||||
#if !SLIMPELLER
|
||||
// CacheChildren only when the transformed_filter_ doesn't equal null.
|
||||
// So in here we reset the LayerRasterCacheItem cache state.
|
||||
layer_raster_cache_item_->MarkNotCacheChildren();
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
transformed_filter_ =
|
||||
filter_->makeWithLocalMatrix(context->state_stack.transform_3x3());
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (transformed_filter_) {
|
||||
layer_raster_cache_item_->MarkCacheChildren();
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
void ImageFilterLayer::Paint(PaintContext& context) const {
|
||||
@@ -101,6 +108,7 @@ void ImageFilterLayer::Paint(PaintContext& context) const {
|
||||
|
||||
auto mutator = context.state_stack.save();
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (context.raster_cache) {
|
||||
// Try drawing the layer cache item from the cache before applying the
|
||||
// image filter if it was cached with the filter applied.
|
||||
@@ -112,10 +120,13 @@ void ImageFilterLayer::Paint(PaintContext& context) const {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
// Only apply the offset if not being raster-cached to avoid the offset being
|
||||
// applied twice.
|
||||
mutator.translate(offset_);
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (context.raster_cache) {
|
||||
mutator.integralTransform();
|
||||
}
|
||||
@@ -132,6 +143,7 @@ void ImageFilterLayer::Paint(PaintContext& context) const {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
// Now apply the image filter and then try rendering the children.
|
||||
mutator.applyImageFilter(child_paint_bounds(), filter_);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/common/graphics/texture.h"
|
||||
#include "flutter/common/macros.h"
|
||||
#include "flutter/display_list/dl_canvas.h"
|
||||
#include "flutter/flow/diff_context.h"
|
||||
#include "flutter/flow/embedded_views.h"
|
||||
@@ -52,7 +53,7 @@ static constexpr SkRect kGiantRect = SkRect::MakeLTRB(-1E9F, -1E9F, 1E9F, 1E9F);
|
||||
enum Clip { kNone, kHardEdge, kAntiAlias, kAntiAliasWithSaveLayer };
|
||||
|
||||
struct PrerollContext {
|
||||
RasterCache* raster_cache;
|
||||
NOT_SLIMPELLER(RasterCache* raster_cache);
|
||||
GrDirectContext* gr_context;
|
||||
ExternalViewEmbedder* view_embedder;
|
||||
LayerStateStack& state_stack;
|
||||
@@ -111,7 +112,7 @@ struct PaintContext {
|
||||
const Stopwatch& raster_time;
|
||||
const Stopwatch& ui_time;
|
||||
std::shared_ptr<TextureRegistry> texture_registry;
|
||||
const RasterCache* raster_cache;
|
||||
NOT_SLIMPELLER(const RasterCache* raster_cache);
|
||||
|
||||
// Snapshot store to collect leaf layer snapshots. The store is non-null
|
||||
// only when leaf layer tracing is enabled.
|
||||
@@ -249,9 +250,11 @@ class Layer {
|
||||
|
||||
uint64_t unique_id() const { return unique_id_; }
|
||||
|
||||
#if !SLIMPELLER
|
||||
virtual RasterCacheKeyID caching_key_id() const {
|
||||
return RasterCacheKeyID(unique_id_, RasterCacheKeyType::kLayer);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
virtual const ContainerLayer* as_container_layer() const { return nullptr; }
|
||||
virtual const DisplayListLayer* as_display_list_layer() const {
|
||||
return nullptr;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/flow/layers/layer_raster_cache_item.h"
|
||||
#include "flutter/flow/layers/container_layer.h"
|
||||
#include "flutter/flow/raster_cache_item.h"
|
||||
@@ -196,3 +198,5 @@ bool LayerRasterCacheItem::Draw(const PaintContext& context,
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_FLOW_LAYERS_LAYER_RASTER_CACHE_ITEM_H_
|
||||
#define FLUTTER_FLOW_LAYERS_LAYER_RASTER_CACHE_ITEM_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
@@ -69,4 +71,6 @@ class LayerRasterCacheItem : public RasterCacheItem {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_FLOW_LAYERS_LAYER_RASTER_CACHE_ITEM_H_
|
||||
|
||||
@@ -40,23 +40,23 @@ bool LayerTree::Preroll(CompositorContext::ScopedFrame& frame,
|
||||
LayerStateStack state_stack;
|
||||
state_stack.set_preroll_delegate(cull_rect,
|
||||
frame.root_surface_transformation());
|
||||
RasterCache* cache =
|
||||
ignore_raster_cache ? nullptr : &frame.context().raster_cache();
|
||||
|
||||
raster_cache_items_.clear();
|
||||
|
||||
PrerollContext context = {
|
||||
// clang-format off
|
||||
.raster_cache = cache,
|
||||
.gr_context = frame.gr_context(),
|
||||
.view_embedder = frame.view_embedder(),
|
||||
.state_stack = state_stack,
|
||||
.dst_color_space = sk_ref_sp<SkColorSpace>(color_space),
|
||||
.surface_needs_readback = false,
|
||||
.raster_time = frame.context().raster_time(),
|
||||
.ui_time = frame.context().ui_time(),
|
||||
.texture_registry = frame.context().texture_registry(),
|
||||
.raster_cached_entries = &raster_cache_items_,
|
||||
// clang-format on
|
||||
#if !SLIMPELLER
|
||||
.raster_cache =
|
||||
ignore_raster_cache ? nullptr : &frame.context().raster_cache(),
|
||||
#endif // !SLIMPELLER
|
||||
.gr_context = frame.gr_context(),
|
||||
.view_embedder = frame.view_embedder(),
|
||||
.state_stack = state_stack,
|
||||
.dst_color_space = sk_ref_sp<SkColorSpace>(color_space),
|
||||
.surface_needs_readback = false,
|
||||
.raster_time = frame.context().raster_time(),
|
||||
.ui_time = frame.context().ui_time(),
|
||||
.texture_registry = frame.context().texture_registry(),
|
||||
.raster_cached_entries = &raster_cache_items_,
|
||||
};
|
||||
|
||||
root_layer_->Preroll(&context);
|
||||
@@ -64,6 +64,7 @@ bool LayerTree::Preroll(CompositorContext::ScopedFrame& frame,
|
||||
return context.surface_needs_readback;
|
||||
}
|
||||
|
||||
#if !SLIMPELLER
|
||||
void LayerTree::TryToRasterCache(
|
||||
const std::vector<RasterCacheItem*>& raster_cached_items,
|
||||
const PaintContext* paint_context,
|
||||
@@ -91,6 +92,7 @@ void LayerTree::TryToRasterCache(
|
||||
i++;
|
||||
}
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
|
||||
bool ignore_raster_cache) const {
|
||||
@@ -114,8 +116,12 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
|
||||
}
|
||||
|
||||
SkColorSpace* color_space = GetColorSpace(frame.canvas());
|
||||
|
||||
#if !SLIMPELLER
|
||||
RasterCache* cache =
|
||||
ignore_raster_cache ? nullptr : &frame.context().raster_cache();
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
PaintContext context = {
|
||||
// clang-format off
|
||||
.state_stack = state_stack,
|
||||
@@ -126,7 +132,9 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
|
||||
.raster_time = frame.context().raster_time(),
|
||||
.ui_time = frame.context().ui_time(),
|
||||
.texture_registry = frame.context().texture_registry(),
|
||||
#if !SLIMPELLER
|
||||
.raster_cache = cache,
|
||||
#endif // !SLIMPELLER
|
||||
.layer_snapshot_store = snapshot_store,
|
||||
.enable_leaf_layer_tracing = enable_leaf_layer_tracing_,
|
||||
.impeller_enabled = !!frame.aiks_context(),
|
||||
@@ -134,10 +142,12 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (cache) {
|
||||
cache->EvictUnusedCacheEntries();
|
||||
TryToRasterCache(raster_cache_items_, &context, ignore_raster_cache);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
if (root_layer_->needs_painting(context)) {
|
||||
root_layer_->Paint(context);
|
||||
@@ -158,8 +168,10 @@ sk_sp<DisplayList> LayerTree::Flatten(
|
||||
// No root surface transformation. So assume identity.
|
||||
preroll_state_stack.set_preroll_delegate(bounds);
|
||||
PrerollContext preroll_context{
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
#if !SLIMPELLER
|
||||
.raster_cache = nullptr,
|
||||
#endif // !SLIMPELLER
|
||||
.gr_context = gr_context,
|
||||
.view_embedder = nullptr,
|
||||
.state_stack = preroll_state_stack,
|
||||
@@ -183,7 +195,9 @@ sk_sp<DisplayList> LayerTree::Flatten(
|
||||
.raster_time = unused_stopwatch,
|
||||
.ui_time = unused_stopwatch,
|
||||
.texture_registry = texture_registry,
|
||||
#if !SLIMPELLER
|
||||
.raster_cache = nullptr,
|
||||
#endif // !SLIMPELLER
|
||||
.layer_snapshot_store = nullptr,
|
||||
.enable_leaf_layer_tracing = false,
|
||||
// clang-format on
|
||||
|
||||
@@ -35,10 +35,12 @@ class LayerTree {
|
||||
bool ignore_raster_cache = false,
|
||||
SkRect cull_rect = kGiantRect);
|
||||
|
||||
#if !SLIMPELLER
|
||||
static void TryToRasterCache(
|
||||
const std::vector<RasterCacheItem*>& raster_cached_entries,
|
||||
const PaintContext* paint_context,
|
||||
bool ignore_raster_cache = false);
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
void Paint(CompositorContext::ScopedFrame& frame,
|
||||
bool ignore_raster_cache = false) const;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/flow/layers/offscreen_surface.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkColorSpace.h"
|
||||
@@ -87,3 +89,5 @@ bool OffscreenSurface::IsValid() const {
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_FLOW_LAYERS_OFFSCREEN_SURFACE_H_
|
||||
#define FLUTTER_FLOW_LAYERS_OFFSCREEN_SURFACE_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
|
||||
@@ -41,4 +43,6 @@ class OffscreenSurface {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_FLOW_LAYERS_OFFSCREEN_SURFACE_H_
|
||||
|
||||
@@ -39,8 +39,11 @@ void OpacityLayer::Preroll(PrerollContext* context) {
|
||||
mutator.translate(offset_);
|
||||
mutator.applyOpacity(SkRect(), DlColor::toOpacity(alpha_));
|
||||
|
||||
#if !SLIMPELLER
|
||||
AutoCache auto_cache = AutoCache(layer_raster_cache_item_.get(), context,
|
||||
context->state_stack.transform_3x3());
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
Layer::AutoPrerollSaveLayerState save =
|
||||
Layer::AutoPrerollSaveLayerState::Create(context);
|
||||
|
||||
@@ -56,12 +59,14 @@ void OpacityLayer::Preroll(PrerollContext* context) {
|
||||
|
||||
set_paint_bounds(paint_bounds().makeOffset(offset_.fX, offset_.fY));
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (children_can_accept_opacity()) {
|
||||
// For opacity layer, we can use raster_cache children only when the
|
||||
// children can't accept opacity so if the children_can_accept_opacity we
|
||||
// should tell the AutoCache object don't do raster_cache.
|
||||
auto_cache.ShouldNotBeCached();
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
void OpacityLayer::Paint(PaintContext& context) const {
|
||||
@@ -69,12 +74,16 @@ void OpacityLayer::Paint(PaintContext& context) const {
|
||||
|
||||
auto mutator = context.state_stack.save();
|
||||
mutator.translate(offset_.fX, offset_.fY);
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (context.raster_cache) {
|
||||
mutator.integralTransform();
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
mutator.applyOpacity(child_paint_bounds(), opacity());
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (!children_can_accept_opacity()) {
|
||||
DlPaint paint;
|
||||
if (layer_raster_cache_item_->Draw(context,
|
||||
@@ -82,6 +91,7 @@ void OpacityLayer::Paint(PaintContext& context) const {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
PaintChildren(context);
|
||||
}
|
||||
|
||||
@@ -37,9 +37,10 @@ void ShaderMaskLayer::Diff(DiffContext* context, const Layer* old_layer) {
|
||||
void ShaderMaskLayer::Preroll(PrerollContext* context) {
|
||||
Layer::AutoPrerollSaveLayerState save =
|
||||
Layer::AutoPrerollSaveLayerState::Create(context);
|
||||
#if !SLIMPELLER
|
||||
AutoCache cache = AutoCache(layer_raster_cache_item_.get(), context,
|
||||
context->state_stack.transform_3x3());
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
ContainerLayer::Preroll(context);
|
||||
// We always paint with a saveLayer (or a cached rendering),
|
||||
// so we can always apply opacity in any of those cases.
|
||||
@@ -51,6 +52,7 @@ void ShaderMaskLayer::Paint(PaintContext& context) const {
|
||||
|
||||
auto mutator = context.state_stack.save();
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (context.raster_cache) {
|
||||
mutator.integralTransform();
|
||||
|
||||
@@ -60,6 +62,7 @@ void ShaderMaskLayer::Paint(PaintContext& context) const {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
auto shader_rect = SkRect::MakeWH(mask_rect_.width(), mask_rect_.height());
|
||||
|
||||
mutator.saveLayer(paint_bounds());
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/flow/raster_cache.h"
|
||||
|
||||
#include <cstddef>
|
||||
@@ -309,3 +311,5 @@ RasterCacheMetrics& RasterCache::GetMetricsForKind(RasterCacheKeyKind kind) {
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_FLOW_RASTER_CACHE_H_
|
||||
#define FLUTTER_FLOW_RASTER_CACHE_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -274,4 +276,10 @@ class RasterCache {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#else // !SLIMPELLER
|
||||
|
||||
class RasterCache;
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_FLOW_RASTER_CACHE_H_
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_FLOW_RASTER_CACHE_ITEM_H_
|
||||
#define FLUTTER_FLOW_RASTER_CACHE_ITEM_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
@@ -74,4 +76,6 @@ class RasterCacheItem {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_FLOW_RASTER_CACHE_ITEM_H_
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/flow/raster_cache_key.h"
|
||||
#include <optional>
|
||||
#include "flutter/flow/layers/container_layer.h"
|
||||
#include "flutter/flow/layers/display_list_layer.h"
|
||||
#include "flutter/flow/layers/layer.h"
|
||||
namespace flutter {
|
||||
|
||||
//
|
||||
namespace flutter {
|
||||
|
||||
std::optional<std::vector<RasterCacheKeyID>> RasterCacheKeyID::LayerChildrenIds(
|
||||
const Layer* layer) {
|
||||
@@ -27,3 +28,5 @@ std::optional<std::vector<RasterCacheKeyID>> RasterCacheKeyID::LayerChildrenIds(
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_FLOW_RASTER_CACHE_KEY_H_
|
||||
#define FLUTTER_FLOW_RASTER_CACHE_KEY_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
@@ -128,4 +130,6 @@ class RasterCacheKey {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_FLOW_RASTER_CACHE_KEY_H_
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
|
||||
#include "flutter/common/macros.h"
|
||||
#include "flutter/fml/memory/ref_counted.h"
|
||||
#include "flutter/fml/memory/weak_ptr.h"
|
||||
#include "flutter/fml/task_runner.h"
|
||||
@@ -40,6 +41,7 @@ class UnrefQueue : public fml::RefCountedThreadSafe<UnrefQueue<T>> {
|
||||
}
|
||||
}
|
||||
|
||||
#if !SLIMPELLER
|
||||
void DeleteTexture(const GrBackendTexture& texture) {
|
||||
// drain_immediate_ should only be used on Impeller.
|
||||
FML_DCHECK(!drain_immediate_);
|
||||
@@ -51,6 +53,7 @@ class UnrefQueue : public fml::RefCountedThreadSafe<UnrefQueue<T>> {
|
||||
[strong = fml::Ref(this)]() { strong->Drain(); }, drain_delay_);
|
||||
}
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
// Usually, the drain is called automatically. However, during IO manager
|
||||
// shutdown (when the platform side reference to the OpenGL context is about
|
||||
@@ -60,14 +63,20 @@ class UnrefQueue : public fml::RefCountedThreadSafe<UnrefQueue<T>> {
|
||||
void Drain() {
|
||||
TRACE_EVENT0("flutter", "SkiaUnrefQueue::Drain");
|
||||
std::deque<SkRefCnt*> skia_objects;
|
||||
std::deque<GrBackendTexture> textures;
|
||||
|
||||
NOT_SLIMPELLER(std::deque<GrBackendTexture> textures);
|
||||
|
||||
{
|
||||
std::scoped_lock lock(mutex_);
|
||||
objects_.swap(skia_objects);
|
||||
textures_.swap(textures);
|
||||
NOT_SLIMPELLER(textures_.swap(textures));
|
||||
drain_pending_ = false;
|
||||
}
|
||||
DoDrain(skia_objects, textures, context_);
|
||||
DoDrain(skia_objects,
|
||||
#if !SLIMPELLER
|
||||
textures,
|
||||
#endif // !SLIMPELLER
|
||||
context_);
|
||||
}
|
||||
|
||||
void UpdateResourceContext(sk_sp<ResourceContext> context) {
|
||||
@@ -79,7 +88,7 @@ class UnrefQueue : public fml::RefCountedThreadSafe<UnrefQueue<T>> {
|
||||
const fml::TimeDelta drain_delay_;
|
||||
std::mutex mutex_;
|
||||
std::deque<SkRefCnt*> objects_;
|
||||
std::deque<GrBackendTexture> textures_;
|
||||
NOT_SLIMPELLER(std::deque<GrBackendTexture> textures_);
|
||||
bool drain_pending_ = false;
|
||||
sk_sp<ResourceContext> context_;
|
||||
// Enabled when there is an impeller context, which removes the usage of
|
||||
@@ -105,21 +114,31 @@ class UnrefQueue : public fml::RefCountedThreadSafe<UnrefQueue<T>> {
|
||||
ResourceContext* raw_context = context_.release();
|
||||
fml::TaskRunner::RunNowOrPostTask(
|
||||
task_runner_, [objects = std::move(objects_),
|
||||
textures = std::move(textures_), raw_context]() mutable {
|
||||
#if !SLIMPELLER
|
||||
textures = std::move(textures_),
|
||||
#endif // !SLIMPELLER
|
||||
raw_context]() mutable {
|
||||
sk_sp<ResourceContext> context(raw_context);
|
||||
DoDrain(objects, textures, context);
|
||||
DoDrain(objects,
|
||||
#if !SLIMPELLER
|
||||
textures,
|
||||
#endif // !SLIMPELLER
|
||||
context);
|
||||
context.reset();
|
||||
});
|
||||
}
|
||||
|
||||
// static
|
||||
static void DoDrain(const std::deque<SkRefCnt*>& skia_objects,
|
||||
#if !SLIMPELLER
|
||||
const std::deque<GrBackendTexture>& textures,
|
||||
#endif // !SLIMPELLER
|
||||
sk_sp<ResourceContext> context) {
|
||||
for (SkRefCnt* skia_object : skia_objects) {
|
||||
skia_object->unref();
|
||||
}
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (context) {
|
||||
for (const GrBackendTexture& texture : textures) {
|
||||
context->deleteBackendTexture(texture);
|
||||
@@ -131,6 +150,7 @@ class UnrefQueue : public fml::RefCountedThreadSafe<UnrefQueue<T>> {
|
||||
|
||||
context->flushAndSubmit(GrSyncCpu::kYes);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
FML_FRIEND_REF_COUNTED_THREAD_SAFE(UnrefQueue);
|
||||
@@ -141,8 +161,7 @@ class UnrefQueue : public fml::RefCountedThreadSafe<UnrefQueue<T>> {
|
||||
using SkiaUnrefQueue = UnrefQueue<GrDirectContext>;
|
||||
|
||||
/// An object whose deallocation needs to be performed on an specific unref
|
||||
/// queue. The template argument U need to have a call operator that returns
|
||||
/// that unref queue.
|
||||
/// queue.
|
||||
template <class T>
|
||||
class SkiaGPUObject {
|
||||
public:
|
||||
|
||||
@@ -27,8 +27,13 @@ SurfaceFrame::SurfaceFrame(sk_sp<SkSurface> surface,
|
||||
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
|
||||
|
||||
@@ -102,7 +102,9 @@ class SurfaceFrame {
|
||||
private:
|
||||
bool submitted_ = false;
|
||||
|
||||
#if !SLIMPELLER
|
||||
DlSkCanvasAdapter adapter_;
|
||||
#endif // !SLIMPELLER
|
||||
sk_sp<DisplayListBuilder> dl_builder_;
|
||||
sk_sp<SkSurface> surface_;
|
||||
DlCanvas* canvas_ = nullptr;
|
||||
|
||||
@@ -85,6 +85,10 @@ static sk_sp<DlImage> CreateDeferredImage(
|
||||
}
|
||||
#endif // IMPELLER_SUPPORTS_RENDERING
|
||||
|
||||
#if SLIMPELLER
|
||||
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
||||
return nullptr;
|
||||
#else // SLIMPELLER
|
||||
const auto& frame_size = layer_tree->frame_size();
|
||||
const SkImageInfo image_info =
|
||||
SkImageInfo::Make(frame_size.width(), frame_size.height(),
|
||||
@@ -92,6 +96,7 @@ static sk_sp<DlImage> CreateDeferredImage(
|
||||
return DlDeferredImageGPUSkia::MakeFromLayerTree(
|
||||
image_info, std::move(layer_tree), std::move(snapshot_delegate),
|
||||
raster_task_runner, std::move(unref_queue));
|
||||
#endif // SLIMPELLER
|
||||
}
|
||||
|
||||
void Scene::RasterizeToImage(uint32_t width,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/lib/ui/painting/display_list_deferred_image_gpu_skia.h"
|
||||
|
||||
#include "flutter/fml/make_copyable.h"
|
||||
@@ -226,3 +228,5 @@ void DlDeferredImageGPUSkia::ImageWrapper::DeleteTexture() {
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_LIB_UI_PAINTING_DISPLAY_LIST_DEFERRED_IMAGE_GPU_SKIA_H_
|
||||
#define FLUTTER_LIB_UI_PAINTING_DISPLAY_LIST_DEFERRED_IMAGE_GPU_SKIA_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
@@ -148,4 +150,6 @@ class DlDeferredImageGPUSkia final : public DlImage {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_LIB_UI_PAINTING_DISPLAY_LIST_DEFERRED_IMAGE_GPU_SKIA_H_
|
||||
|
||||
@@ -28,11 +28,16 @@ std::unique_ptr<ImageDecoder> ImageDecoder::Make(
|
||||
gpu_disabled_switch);
|
||||
}
|
||||
#endif // IMPELLER_SUPPORTS_RENDERING
|
||||
#if !SLIMPELLER
|
||||
return std::make_unique<ImageDecoderSkia>(
|
||||
runners, //
|
||||
std::move(concurrent_task_runner), //
|
||||
std::move(io_manager) //
|
||||
);
|
||||
#else // !SLIMPELLER
|
||||
FML_LOG(FATAL) << "Could not setup an image decoder.";
|
||||
return nullptr;
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
ImageDecoder::ImageDecoder(
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/lib/ui/painting/image_decoder_skia.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -329,3 +331,5 @@ void ImageDecoderSkia::Decode(fml::RefPtr<ImageDescriptor> descriptor_ref_ptr,
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_SKIA_H_
|
||||
#define FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_SKIA_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/lib/ui/painting/image_decoder.h"
|
||||
|
||||
@@ -37,4 +39,6 @@ class ImageDecoderSkia final : public ImageDecoder {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_SKIA_H_
|
||||
|
||||
@@ -147,9 +147,14 @@ void EncodeImageAndInvokeDataCallback(
|
||||
return;
|
||||
}
|
||||
#endif // IMPELLER_SUPPORTS_RENDERING
|
||||
#if !SLIMPELLER
|
||||
ConvertImageToRasterSkia(image, encode_task, raster_task_runner,
|
||||
io_task_runner, resource_context, snapshot_delegate,
|
||||
is_gpu_disabled_sync_switch);
|
||||
|
||||
#else // !SLIMPELLER
|
||||
FML_LOG(FATAL) << "Unsupported renderer.";
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/lib/ui/painting/image_encoding.h"
|
||||
#include "flutter/lib/ui/painting/image_encoding_impl.h"
|
||||
|
||||
@@ -100,3 +102,5 @@ void ConvertImageToRasterSkia(
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_ENCODING_SKIA_H_
|
||||
#define FLUTTER_LIB_UI_PAINTING_IMAGE_ENCODING_SKIA_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/common/task_runners.h"
|
||||
#include "flutter/display_list/image/dl_image.h"
|
||||
#include "flutter/fml/synchronization/sync_switch.h"
|
||||
@@ -23,4 +25,6 @@ void ConvertImageToRasterSkia(
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_LIB_UI_PAINTING_IMAGE_ENCODING_SKIA_H_
|
||||
|
||||
@@ -154,6 +154,7 @@ MultiFrameCodec::State::GetNextFrameImage(
|
||||
}
|
||||
#endif // IMPELLER_SUPPORTS_RENDERING
|
||||
|
||||
#if !SLIMPELLER
|
||||
sk_sp<SkImage> skImage;
|
||||
gpu_disable_sync_switch->Execute(
|
||||
fml::SyncSwitch::Handlers()
|
||||
@@ -179,6 +180,9 @@ MultiFrameCodec::State::GetNextFrameImage(
|
||||
|
||||
return std::make_pair(DlImageGPU::Make({skImage, std::move(unref_queue)}),
|
||||
std::string());
|
||||
#else // !SLIMPELLER
|
||||
return std::make_pair(nullptr, "Unsupported backend.");
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
void MultiFrameCodec::State::GetNextFrameAndInvokeCallback(
|
||||
|
||||
@@ -71,11 +71,16 @@ static sk_sp<DlImage> CreateDeferredImage(
|
||||
}
|
||||
#endif // IMPELLER_SUPPORTS_RENDERING
|
||||
|
||||
#if SLIMPELLER
|
||||
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
||||
return nullptr;
|
||||
#else // SLIMPELLER
|
||||
const SkImageInfo image_info = SkImageInfo::Make(
|
||||
width, height, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
return DlDeferredImageGPUSkia::Make(
|
||||
image_info, std::move(display_list), std::move(snapshot_delegate),
|
||||
raster_task_runner, std::move(unref_queue));
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -24,16 +24,25 @@ class SnapshotDelegate {
|
||||
/// @brief A data structure used by the Skia implementation of deferred
|
||||
/// GPU based images.
|
||||
struct GpuImageResult {
|
||||
GpuImageResult(const GrBackendTexture& p_texture,
|
||||
sk_sp<GrDirectContext> p_context,
|
||||
sk_sp<SkImage> p_image = nullptr,
|
||||
const std::string& p_error = "")
|
||||
: texture(p_texture),
|
||||
GpuImageResult(
|
||||
#if !SLIMPELLER
|
||||
const GrBackendTexture& p_texture,
|
||||
#endif // !SLIMPELLER
|
||||
sk_sp<GrDirectContext> p_context,
|
||||
sk_sp<SkImage> p_image = nullptr,
|
||||
const std::string& p_error = "")
|
||||
:
|
||||
#if !SLIMPELLER
|
||||
texture(p_texture),
|
||||
#endif // !SLIMPELLER
|
||||
context(std::move(p_context)),
|
||||
image(std::move(p_image)),
|
||||
error(p_error) {}
|
||||
error(p_error) {
|
||||
}
|
||||
|
||||
#if !SLIMPELLER
|
||||
const GrBackendTexture texture;
|
||||
#endif // !SLIMPELLER
|
||||
// If texture.isValid() == true, this is a pointer to a GrDirectContext that
|
||||
// can be used to create an image from the texture.
|
||||
sk_sp<GrDirectContext> context;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/shell/common/context_options.h"
|
||||
|
||||
#include "flutter/common/graphics/persistent_cache.h"
|
||||
@@ -41,3 +43,5 @@ GrContextOptions MakeDefaultContextOptions(ContextType type,
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_SHELL_COMMON_CONTEXT_OPTIONS_H_
|
||||
#define FLUTTER_SHELL_COMMON_CONTEXT_OPTIONS_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
@@ -40,4 +42,6 @@ GrContextOptions MakeDefaultContextOptions(
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_SHELL_COMMON_CONTEXT_OPTIONS_H_
|
||||
|
||||
@@ -47,7 +47,8 @@ namespace flutter {
|
||||
|
||||
// The rasterizer will tell Skia to purge cached resources that have not been
|
||||
// used within this interval.
|
||||
static constexpr std::chrono::milliseconds kSkiaCleanupExpiration(15000);
|
||||
[[maybe_unused]] static constexpr std::chrono::milliseconds
|
||||
kSkiaCleanupExpiration(15000);
|
||||
|
||||
Rasterizer::Rasterizer(Delegate& delegate,
|
||||
MakeGpuImageBehavior gpu_image_behavior)
|
||||
@@ -121,9 +122,11 @@ void Rasterizer::Teardown() {
|
||||
auto context_switch = surface_->MakeRenderContextCurrent();
|
||||
if (context_switch->GetResult()) {
|
||||
compositor_context_->OnGrContextDestroyed();
|
||||
#if !SLIMPELLER
|
||||
if (auto* context = surface_->GetContext()) {
|
||||
context->purgeUnlockedResources(GrPurgeResourceOptions::kAllResources);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
surface_.reset();
|
||||
}
|
||||
@@ -165,6 +168,7 @@ void Rasterizer::DisableThreadMergerIfNeeded() {
|
||||
}
|
||||
|
||||
void Rasterizer::NotifyLowMemoryWarning() const {
|
||||
#if !SLIMPELLER
|
||||
if (!surface_) {
|
||||
FML_DLOG(INFO)
|
||||
<< "Rasterizer::NotifyLowMemoryWarning called with no surface.";
|
||||
@@ -181,6 +185,7 @@ void Rasterizer::NotifyLowMemoryWarning() const {
|
||||
return;
|
||||
}
|
||||
context->performDeferredCleanup(std::chrono::milliseconds(0));
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
void Rasterizer::CollectView(int64_t view_id) {
|
||||
@@ -323,6 +328,7 @@ DrawStatus Rasterizer::ToDrawStatus(DoDrawStatus status) {
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
#if !SLIMPELLER
|
||||
namespace {
|
||||
std::unique_ptr<SnapshotDelegate::GpuImageResult> MakeBitmapImage(
|
||||
const sk_sp<DisplayList>& display_list,
|
||||
@@ -352,10 +358,15 @@ std::unique_ptr<SnapshotDelegate::GpuImageResult> MakeBitmapImage(
|
||||
image ? "" : "Unable to create image");
|
||||
}
|
||||
} // namespace
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
std::unique_ptr<Rasterizer::GpuImageResult> Rasterizer::MakeSkiaGpuImage(
|
||||
sk_sp<DisplayList> display_list,
|
||||
const SkImageInfo& image_info) {
|
||||
#if SLIMPELLER
|
||||
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
||||
return nullptr;
|
||||
#else // SLIMPELLER
|
||||
TRACE_EVENT0("flutter", "Rasterizer::MakeGpuImage");
|
||||
FML_DCHECK(display_list);
|
||||
|
||||
@@ -420,6 +431,7 @@ std::unique_ptr<Rasterizer::GpuImageResult> Rasterizer::MakeSkiaGpuImage(
|
||||
texture, sk_ref_sp(context), nullptr, "");
|
||||
}));
|
||||
return result;
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
void Rasterizer::MakeRasterSnapshot(
|
||||
@@ -470,8 +482,10 @@ Rasterizer::DoDrawResult Rasterizer::DoDraw(
|
||||
return DoDrawResult{DoDrawStatus::kNotSetUp};
|
||||
}
|
||||
|
||||
#if !SLIMPELLER
|
||||
PersistentCache* persistent_cache = PersistentCache::GetCacheForProcess();
|
||||
persistent_cache->ResetStoredNewShaders();
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
DoDrawResult result =
|
||||
DrawToSurfaces(*frame_timings_recorder, std::move(tasks));
|
||||
@@ -481,12 +495,14 @@ Rasterizer::DoDrawResult Rasterizer::DoDraw(
|
||||
return DoDrawResult{DoDrawStatus::kGpuUnavailable};
|
||||
}
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (persistent_cache->IsDumpingSkp() &&
|
||||
persistent_cache->StoredNewShaders()) {
|
||||
auto screenshot =
|
||||
ScreenshotLastLayerTree(ScreenshotType::SkiaPicture, false);
|
||||
persistent_cache->DumpSkp(*screenshot.data);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
// TODO(liyuqian): in Fuchsia, the rasterization doesn't finish when
|
||||
// Rasterizer::DoDraw finishes. Future work is needed to adapt the timestamp
|
||||
@@ -655,12 +671,16 @@ std::unique_ptr<FrameItem> Rasterizer::DrawToSurfacesUnsafe(
|
||||
}
|
||||
// TODO(dkwingsmt): Pass in raster cache(s) for all views.
|
||||
// See https://github.com/flutter/flutter/issues/135530, item 4.
|
||||
frame_timings_recorder.RecordRasterEnd(&compositor_context_->raster_cache());
|
||||
frame_timings_recorder.RecordRasterEnd(
|
||||
NOT_SLIMPELLER(&compositor_context_->raster_cache()));
|
||||
|
||||
FireNextFrameCallbackIfPresent();
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (surface_->GetContext()) {
|
||||
surface_->GetContext()->performDeferredCleanup(kSkiaCleanupExpiration);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
if (resubmitted_tasks.empty()) {
|
||||
return nullptr;
|
||||
@@ -717,7 +737,7 @@ DrawSurfaceStatus Rasterizer::DrawToSurfaceUnsafe(
|
||||
surface_->GetAiksContext().get() // aiks context
|
||||
);
|
||||
if (compositor_frame) {
|
||||
compositor_context_->raster_cache().BeginFrame();
|
||||
NOT_SLIMPELLER(compositor_context_->raster_cache().BeginFrame());
|
||||
|
||||
std::unique_ptr<FrameDamage> damage;
|
||||
// when leaf layer tracing is enabled we wish to repaint the whole frame
|
||||
@@ -777,11 +797,13 @@ DrawSurfaceStatus Rasterizer::DrawToSurfaceUnsafe(
|
||||
frame->Submit();
|
||||
}
|
||||
|
||||
#if !SLIMPELLER
|
||||
// Do not update raster cache metrics for kResubmit because that status
|
||||
// indicates that the frame was not actually painted.
|
||||
if (frame_status != RasterStatus::kResubmit) {
|
||||
compositor_context_->raster_cache().EndFrame();
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
if (frame_status == RasterStatus::kResubmit) {
|
||||
return DrawSurfaceStatus::kRetry;
|
||||
@@ -801,6 +823,9 @@ Rasterizer::ViewRecord& Rasterizer::EnsureViewRecord(int64_t view_id) {
|
||||
static sk_sp<SkData> ScreenshotLayerTreeAsPicture(
|
||||
flutter::LayerTree* tree,
|
||||
flutter::CompositorContext& compositor_context) {
|
||||
#if SLIMPELLER
|
||||
return nullptr;
|
||||
#else // SLIMPELLER
|
||||
FML_DCHECK(tree != nullptr);
|
||||
SkPictureRecorder recorder;
|
||||
recorder.beginRecording(
|
||||
@@ -830,6 +855,7 @@ static sk_sp<SkData> ScreenshotLayerTreeAsPicture(
|
||||
#endif
|
||||
|
||||
return recorder.finishRecordingAsPicture()->serialize(&procs);
|
||||
#endif // SLIMPELLER
|
||||
}
|
||||
|
||||
static void RenderFrameForScreenshot(
|
||||
@@ -955,6 +981,10 @@ Rasterizer::ScreenshotLayerTreeAsImage(
|
||||
}
|
||||
#endif // IMPELLER_SUPPORTS_RENDERING
|
||||
|
||||
#if SLIMPELLER
|
||||
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
||||
return {nullptr, ScreenshotFormat::kUnknown};
|
||||
#else // SLIMPELLER
|
||||
GrDirectContext* surface_context = GetGrContext();
|
||||
// Attempt to create a snapshot surface depending on whether we have access
|
||||
// to a valid GPU rendering context.
|
||||
@@ -984,6 +1014,7 @@ Rasterizer::ScreenshotLayerTreeAsImage(
|
||||
|
||||
return std::make_pair(snapshot_surface->GetRasterData(compressed),
|
||||
ScreenshotFormat::kUnknown);
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
Rasterizer::Screenshot Rasterizer::ScreenshotLastLayerTree(
|
||||
@@ -1080,6 +1111,7 @@ void Rasterizer::FireNextFrameCallbackIfPresent() {
|
||||
}
|
||||
|
||||
void Rasterizer::SetResourceCacheMaxBytes(size_t max_bytes, bool from_user) {
|
||||
#if !SLIMPELLER
|
||||
user_override_resource_cache_bytes_ |= from_user;
|
||||
|
||||
if (!from_user && user_override_resource_cache_bytes_) {
|
||||
@@ -1102,9 +1134,13 @@ void Rasterizer::SetResourceCacheMaxBytes(size_t max_bytes, bool from_user) {
|
||||
|
||||
context->setResourceCacheLimit(max_bytes);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
std::optional<size_t> Rasterizer::GetResourceCacheMaxBytes() const {
|
||||
#if SLIMPELLER
|
||||
return std::nullopt;
|
||||
#else // SLIMPELLER
|
||||
if (!surface_) {
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -1113,6 +1149,7 @@ std::optional<size_t> Rasterizer::GetResourceCacheMaxBytes() const {
|
||||
return context->getResourceCacheLimit();
|
||||
}
|
||||
return std::nullopt;
|
||||
#endif // SLIMPELLER
|
||||
}
|
||||
|
||||
Rasterizer::Screenshot::Screenshot() {}
|
||||
|
||||
@@ -747,7 +747,7 @@ class Rasterizer final : public SnapshotDelegate,
|
||||
|
||||
bool is_torn_down_ = false;
|
||||
Delegate& delegate_;
|
||||
MakeGpuImageBehavior gpu_image_behavior_;
|
||||
[[maybe_unused]] MakeGpuImageBehavior gpu_image_behavior_;
|
||||
std::weak_ptr<impeller::Context> impeller_context_;
|
||||
std::unique_ptr<Surface> surface_;
|
||||
std::unique_ptr<SnapshotSurfaceProducer> snapshot_surface_producer_;
|
||||
|
||||
@@ -41,7 +41,9 @@ RunConfiguration::RunConfiguration(
|
||||
std::unique_ptr<IsolateConfiguration> configuration)
|
||||
: RunConfiguration(std::move(configuration),
|
||||
std::make_shared<AssetManager>()) {
|
||||
#if !SLIMPELLER
|
||||
PersistentCache::SetAssetManager(asset_manager_);
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
RunConfiguration::RunConfiguration(
|
||||
@@ -49,7 +51,9 @@ RunConfiguration::RunConfiguration(
|
||||
std::shared_ptr<AssetManager> asset_manager)
|
||||
: isolate_configuration_(std::move(configuration)),
|
||||
asset_manager_(std::move(asset_manager)) {
|
||||
#if !SLIMPELLER
|
||||
PersistentCache::SetAssetManager(asset_manager_);
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
RunConfiguration::RunConfiguration(RunConfiguration&&) = default;
|
||||
|
||||
@@ -142,7 +142,9 @@ void PerformInitializationTasks(Settings& settings) {
|
||||
}
|
||||
});
|
||||
|
||||
#if !SLIMPELLER
|
||||
PersistentCache::SetCacheSkSL(settings.cache_sksl);
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -525,8 +527,10 @@ Shell::Shell(DartVMRef vm,
|
||||
}
|
||||
|
||||
Shell::~Shell() {
|
||||
#if !SLIMPELLER
|
||||
PersistentCache::GetCacheForProcess()->RemoveWorkerTaskRunner(
|
||||
task_runners_.GetIOTaskRunner());
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
vm_->GetServiceProtocol()->RemoveHandler(this);
|
||||
|
||||
@@ -779,6 +783,7 @@ bool Shell::Setup(std::unique_ptr<PlatformView> platform_view,
|
||||
|
||||
is_set_up_ = true;
|
||||
|
||||
#if !SLIMPELLER
|
||||
PersistentCache::GetCacheForProcess()->AddWorkerTaskRunner(
|
||||
task_runners_.GetIOTaskRunner());
|
||||
|
||||
@@ -788,6 +793,7 @@ bool Shell::Setup(std::unique_ptr<PlatformView> platform_view,
|
||||
if (settings_.purge_persistent_cache) {
|
||||
PersistentCache::GetCacheForProcess()->Purge();
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1886,6 +1892,7 @@ bool Shell::OnServiceProtocolGetSkSLs(
|
||||
response->AddMember("type", "GetSkSLs", response->GetAllocator());
|
||||
|
||||
rapidjson::Value shaders_json(rapidjson::kObjectType);
|
||||
#if !SLIMPELLER
|
||||
PersistentCache* persistent_cache = PersistentCache::GetCacheForProcess();
|
||||
std::vector<PersistentCache::SkSLCache> sksls = persistent_cache->LoadSkSLs();
|
||||
for (const auto& sksl : sksls) {
|
||||
@@ -1904,6 +1911,7 @@ bool Shell::OnServiceProtocolGetSkSLs(
|
||||
rapidjson::Value shader_key(encode_result.second, response->GetAllocator());
|
||||
shaders_json.AddMember(shader_key, shader_value, response->GetAllocator());
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
response->AddMember("SkSLs", shaders_json, response->GetAllocator());
|
||||
return true;
|
||||
}
|
||||
@@ -1912,15 +1920,22 @@ bool Shell::OnServiceProtocolEstimateRasterCacheMemory(
|
||||
const ServiceProtocol::Handler::ServiceProtocolMap& params,
|
||||
rapidjson::Document* response) {
|
||||
FML_DCHECK(task_runners_.GetRasterTaskRunner()->RunsTasksOnCurrentThread());
|
||||
|
||||
uint64_t layer_cache_byte_size = 0u;
|
||||
uint64_t picture_cache_byte_size = 0u;
|
||||
|
||||
#if !SLIMPELLER
|
||||
const auto& raster_cache = rasterizer_->compositor_context()->raster_cache();
|
||||
layer_cache_byte_size = raster_cache.EstimateLayerCacheByteSize();
|
||||
picture_cache_byte_size = raster_cache.EstimatePictureCacheByteSize();
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
response->SetObject();
|
||||
response->AddMember("type", "EstimateRasterCacheMemory",
|
||||
response->GetAllocator());
|
||||
response->AddMember<uint64_t>("layerBytes",
|
||||
raster_cache.EstimateLayerCacheByteSize(),
|
||||
response->AddMember<uint64_t>("layerBytes", layer_cache_byte_size,
|
||||
response->GetAllocator());
|
||||
response->AddMember<uint64_t>("pictureBytes",
|
||||
raster_cache.EstimatePictureCacheByteSize(),
|
||||
response->AddMember<uint64_t>("pictureBytes", picture_cache_byte_size,
|
||||
response->GetAllocator());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,13 @@ std::unique_ptr<SnapshotController> SnapshotController::Make(
|
||||
return std::make_unique<SnapshotControllerImpeller>(delegate);
|
||||
}
|
||||
#endif // IMPELLER_SUPPORTS_RENDERING
|
||||
#if !SLIMPELLER
|
||||
return std::make_unique<SnapshotControllerSkia>(delegate);
|
||||
#else // !SLIMPELLER
|
||||
FML_LOG(FATAL)
|
||||
<< "Cannot create a Skia snapshot controller in an Impeller build.";
|
||||
return nullptr;
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
SnapshotController::SnapshotController(const Delegate& delegate)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/shell/common/snapshot_controller_skia.h"
|
||||
|
||||
#include "display_list/image/dl_image.h"
|
||||
@@ -171,3 +173,5 @@ void SnapshotControllerSkia::CacheRuntimeStage(
|
||||
const std::shared_ptr<impeller::RuntimeStage>& runtime_stage) {}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_SHELL_COMMON_SNAPSHOT_CONTROLLER_SKIA_H_
|
||||
#define FLUTTER_SHELL_COMMON_SNAPSHOT_CONTROLLER_SKIA_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/shell/common/snapshot_controller.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
@@ -38,4 +40,6 @@ class SnapshotControllerSkia : public SnapshotController {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_SHELL_COMMON_SNAPSHOT_CONTROLLER_SKIA_H_
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_SKIA_H_
|
||||
#define FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_SKIA_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/common/graphics/msaa_sample_count.h"
|
||||
#include "flutter/flow/surface.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
@@ -71,4 +73,6 @@ class SK_API_AVAILABLE_CA_METAL_LAYER GPUSurfaceMetalSkia : public Surface {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_SKIA_H_
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_skia.h"
|
||||
|
||||
#import <Metal/Metal.h>
|
||||
@@ -272,3 +274,5 @@ bool GPUSurfaceMetalSkia::AllowsDrawingWhenGpuDisabled() const {
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_FLUTTERDARWINCONTEXTMETALSKIA_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_FLUTTERDARWINCONTEXTMETALSKIA_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#import <CoreVideo/CVMetalTextureCache.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Metal/Metal.h>
|
||||
@@ -75,4 +77,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_FLUTTERDARWINCONTEXTMETALSKIA_H_
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h"
|
||||
|
||||
#include "flutter/common/graphics/persistent_cache.h"
|
||||
@@ -106,3 +108,5 @@ FLUTTER_ASSERT_ARC
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -295,6 +295,9 @@ FLUTTER_ASSERT_ARC
|
||||
grContext:(nonnull GrDirectContext*)grContext
|
||||
width:(size_t)width
|
||||
height:(size_t)height {
|
||||
#if SLIMPELLER
|
||||
return nullptr;
|
||||
#else // SLIMPELLER
|
||||
GrMtlTextureInfo ySkiaTextureInfo;
|
||||
ySkiaTextureInfo.fTexture = sk_cfp<const void*>{(__bridge_retained const void*)yTex};
|
||||
|
||||
@@ -315,12 +318,17 @@ FLUTTER_ASSERT_ARC
|
||||
return SkImages::TextureFromYUVATextures(grContext, yuvaBackendTextures,
|
||||
/*imageColorSpace=*/nullptr,
|
||||
/*releaseProc*/ nullptr, /*releaseContext*/ nullptr);
|
||||
#endif // SLIMPELLER
|
||||
}
|
||||
|
||||
+ (sk_sp<SkImage>)wrapRGBATexture:(id<MTLTexture>)rgbaTex
|
||||
grContext:(nonnull GrDirectContext*)grContext
|
||||
width:(size_t)width
|
||||
height:(size_t)height {
|
||||
#if SLIMPELLER
|
||||
return nullptr;
|
||||
#else // SLIMPELLER
|
||||
|
||||
GrMtlTextureInfo skiaTextureInfo;
|
||||
skiaTextureInfo.fTexture = sk_cfp<const void*>{(__bridge_retained const void*)rgbaTex};
|
||||
|
||||
@@ -331,5 +339,6 @@ FLUTTER_ASSERT_ARC
|
||||
kBGRA_8888_SkColorType, kPremul_SkAlphaType,
|
||||
/*colorSpace=*/nullptr, /*releaseProc*/ nullptr,
|
||||
/*releaseContext*/ nullptr);
|
||||
#endif // SLIMPELLER
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -34,7 +34,13 @@ std::unique_ptr<IOSContext> IOSContext::Create(
|
||||
case IOSRenderingAPI::kMetal:
|
||||
switch (backend) {
|
||||
case IOSRenderingBackend::kSkia:
|
||||
#if !SLIMPELLER
|
||||
return std::make_unique<IOSContextMetalSkia>(msaa_samples);
|
||||
|
||||
#else // !SLIMPELLER
|
||||
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
||||
return nullptr;
|
||||
#endif // !SLIMPELLER
|
||||
case IOSRenderingBackend::kImpeller:
|
||||
return std::make_unique<IOSContextMetalImpeller>(is_gpu_disabled_sync_switch);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_SKIA_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_SKIA_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
@@ -51,4 +53,6 @@ class IOSContextMetalSkia final : public IOSContext {
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_SKIA_H_
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#import "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h"
|
||||
|
||||
#include "flutter/common/graphics/persistent_cache.h"
|
||||
@@ -58,3 +60,5 @@ std::unique_ptr<Texture> IOSContextMetalSkia::CreateExternalTexture(
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -22,10 +22,15 @@ std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> conte
|
||||
if ([layer.get() isKindOfClass:[CAMetalLayer class]]) {
|
||||
switch (context->GetBackend()) {
|
||||
case IOSRenderingBackend::kSkia:
|
||||
#if !SLIMPELLER
|
||||
return std::make_unique<IOSSurfaceMetalSkia>(
|
||||
fml::scoped_nsobject<CAMetalLayer>((CAMetalLayer*)layer.get()), // Metal layer
|
||||
std::move(context) // context
|
||||
);
|
||||
#else // !SLIMPELLER
|
||||
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
||||
return nullptr;
|
||||
#endif // !SLIMPELLER
|
||||
break;
|
||||
case IOSRenderingBackend::kImpeller:
|
||||
return std::make_unique<IOSSurfaceMetalImpeller>(
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_delegate.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface.h"
|
||||
@@ -61,4 +63,6 @@ class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalSkia final : public IOSSurf
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h"
|
||||
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_delegate.h"
|
||||
@@ -117,3 +119,5 @@ bool IOSSurfaceMetalSkia::AllowsDrawingWhenGpuDisabled() const {
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -550,6 +550,7 @@ InferMetalPlatformViewCreationCallback(
|
||||
config->metal.present_command_queue),
|
||||
metal_dispatch_table, view_embedder);
|
||||
} else {
|
||||
#if !SLIMPELLER
|
||||
flutter::EmbedderSurfaceMetal::MetalDispatchTable metal_dispatch_table = {
|
||||
.present = metal_present,
|
||||
.get_texture = metal_get_texture,
|
||||
@@ -559,6 +560,9 @@ InferMetalPlatformViewCreationCallback(
|
||||
const_cast<flutter::GPUMTLCommandQueueHandle>(
|
||||
config->metal.present_command_queue),
|
||||
metal_dispatch_table, view_embedder);
|
||||
#else // !SLIMPELLER
|
||||
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
||||
#endif // !SLIMPELLER
|
||||
}
|
||||
|
||||
// The static leak checker gets confused by the use of fml::MakeCopyable.
|
||||
@@ -913,7 +917,7 @@ static sk_sp<SkSurface> MakeSkSurfaceFromBackingStore(
|
||||
GrDirectContext* context,
|
||||
const FlutterBackingStoreConfig& config,
|
||||
const FlutterMetalBackingStore* metal) {
|
||||
#ifdef SHELL_ENABLE_METAL
|
||||
#if defined(SHELL_ENABLE_METAL) && !SLIMPELLER
|
||||
GrMtlTextureInfo texture_info;
|
||||
if (!metal->texture.texture) {
|
||||
FML_LOG(ERROR) << "Embedder supplied null Metal texture.";
|
||||
@@ -1774,6 +1778,7 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
|
||||
icu_data_path = SAFE_ACCESS(args, icu_data_path, nullptr);
|
||||
}
|
||||
|
||||
#if !SLIMPELLER
|
||||
if (SAFE_ACCESS(args, persistent_cache_path, nullptr) != nullptr) {
|
||||
std::string persistent_cache_path =
|
||||
SAFE_ACCESS(args, persistent_cache_path, nullptr);
|
||||
@@ -1783,6 +1788,7 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
|
||||
if (SAFE_ACCESS(args, is_persistent_cache_read_only, false)) {
|
||||
flutter::PersistentCache::gIsReadOnly = true;
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
fml::CommandLine command_line;
|
||||
if (SAFE_ACCESS(args, command_line_argc, 0) != 0 &&
|
||||
|
||||
@@ -133,6 +133,10 @@ bool EmbedderExternalView::Render(const EmbedderRenderTarget& render_target,
|
||||
}
|
||||
#endif // IMPELLER_SUPPORTS_RENDERING
|
||||
|
||||
#if SLIMPELLER
|
||||
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
||||
return false;
|
||||
#else // SLIMPELLER
|
||||
auto skia_surface = render_target.GetSkiaSurface();
|
||||
if (!skia_surface) {
|
||||
return false;
|
||||
@@ -153,6 +157,7 @@ bool EmbedderExternalView::Render(const EmbedderRenderTarget& render_target,
|
||||
slice_->render_into(&dl_canvas);
|
||||
dl_canvas.RestoreToCount(restore_count);
|
||||
dl_canvas.Flush();
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -466,15 +466,18 @@ void EmbedderExternalViewEmbedder::SubmitFlutterView(
|
||||
auto deferred_cleanup_render_targets =
|
||||
render_target_cache.ClearAllRenderTargetsInCache();
|
||||
|
||||
#if !SLIMPELLER
|
||||
// The OpenGL context could have been trampled by the embedder at this point
|
||||
// as it attempted to collect old render targets and create new ones. Tell
|
||||
// Skia to not rely on existing bindings.
|
||||
if (context) {
|
||||
context->resetContext(kAll_GrBackendState);
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
builder.Render();
|
||||
|
||||
#if !SLIMPELLER
|
||||
// We are going to be transferring control back over to the embedder there
|
||||
// the context may be trampled upon again. Flush all operations to the
|
||||
// underlying rendering API.
|
||||
@@ -483,6 +486,7 @@ void EmbedderExternalViewEmbedder::SubmitFlutterView(
|
||||
if (context) {
|
||||
context->flushAndSubmit();
|
||||
}
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
{
|
||||
auto presentation_time_optional = frame->submit_info().presentation_time;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_METAL_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_METAL_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_delegate.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_skia.h"
|
||||
@@ -15,6 +17,9 @@
|
||||
|
||||
namespace flutter {
|
||||
|
||||
// TODO(148235): This class is Skia specific and there is another on
|
||||
// specifically for Impeller called EmbedderSurfaceMetalImpeller. Rename this to
|
||||
// EmbedderSurfaceMetalSkia to avoid confusion.
|
||||
class EmbedderSurfaceMetal final : public EmbedderSurface,
|
||||
public GPUSurfaceMetalDelegate {
|
||||
public:
|
||||
@@ -67,4 +72,6 @@ class EmbedderSurfaceMetal final : public EmbedderSurface,
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_METAL_H_
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "flutter/shell/platform/embedder/embedder_surface_metal.h"
|
||||
|
||||
#include "flutter/common/graphics/msaa_sample_count.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_delegate.h"
|
||||
#import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h"
|
||||
#include "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h"
|
||||
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
||||
|
||||
FLUTTER_ASSERT_NOT_ARC
|
||||
@@ -80,3 +83,5 @@ bool EmbedderSurfaceMetal::PresentTexture(GPUMTLTextureInfo texture) const {
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
@@ -392,6 +392,9 @@ def to_gn_args(args):
|
||||
if args.target_os != 'ios':
|
||||
raise Exception('--simulator is only supported for iOS')
|
||||
|
||||
if args.slimpeller and args.target_os != 'ios':
|
||||
raise Exception('--slimpeller is only supported for iOS.')
|
||||
|
||||
runtime_mode = args.runtime_mode
|
||||
|
||||
gn_args = {}
|
||||
@@ -441,6 +444,10 @@ def to_gn_args(args):
|
||||
gn_args['is_clang'] = True
|
||||
else:
|
||||
gn_args['is_clang'] = args.clang
|
||||
if args.slimpeller:
|
||||
gn_args['skia_enable_graphite'] = False
|
||||
gn_args['skia_enable_ganesh'] = False
|
||||
gn_args['slimpeller'] = True
|
||||
|
||||
if args.target_os == 'android' or args.target_os == 'ios':
|
||||
gn_args['skia_gl_standard'] = 'gles'
|
||||
|
||||
Reference in New Issue
Block a user