Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ vars = {
# Dart is: https://github.com/dart-lang/sdk/blob/main/DEPS.
# You can use //tools/dart/create_updated_flutter_deps.py to produce
# updated revision list of existing dependencies.
'dart_revision': '654db247514fd82fe4037af9c7ef419cab8484b5',
'dart_revision': '63c2197b976931c6472d9dc9574f98ff2ae9408c',

# WARNING: DO NOT EDIT MANUALLY
# The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py
Expand Down
13 changes: 11 additions & 2 deletions ci/firebase_testlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
import subprocess
import sys

BUCKET = 'gs://flutter_firebase_testlab'
if 'STORAGE_BUCKET' not in os.environ:
print('The GCP storage bucket must be provided as an environment variable.')
sys.exit(1)
BUCKET = os.environ['STORAGE_BUCKET']

if 'GCP_PROJECT' not in os.environ:
print('The GCP project must be provided as an environment variable.')
sys.exit(1)
PROJECT = os.environ['GCP_PROJECT']

script_dir = os.path.dirname(os.path.realpath(__file__))
buildroot_dir = os.path.abspath(os.path.join(script_dir, '..', '..'))
out_dir = os.path.join(buildroot_dir, 'out')
Expand All @@ -28,7 +37,7 @@ def run_firebase_test(apk, results_dir):
[
'gcloud',
'--project',
'flutter-infra',
PROJECT,
'firebase',
'test',
'android',
Expand Down
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -2397,6 +2397,8 @@ FILE: ../../../flutter/shell/platform/windows/window_state.h
FILE: ../../../flutter/shell/platform/windows/window_win32.cc
FILE: ../../../flutter/shell/platform/windows/window_win32.h
FILE: ../../../flutter/shell/platform/windows/window_win32_unittests.cc
FILE: ../../../flutter/shell/platform/windows/windows_proc_table.cc
FILE: ../../../flutter/shell/platform/windows/windows_proc_table.h
FILE: ../../../flutter/shell/profiling/sampling_profiler.cc
FILE: ../../../flutter/shell/profiling/sampling_profiler.h
FILE: ../../../flutter/shell/profiling/sampling_profiler_unittest.cc
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/licenses_third_party
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Signature: af6717216660c358a8a89f8c8a9cf21b
Signature: afc25a44d546c441153d3dd3a92c0ddf

UNUSED LICENSES:

Expand Down
21 changes: 21 additions & 0 deletions impeller/compiler/impellerc_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include <filesystem>
#include <system_error>

#include "flutter/fml/backtrace.h"
#include "flutter/fml/command_line.h"
Expand All @@ -20,6 +21,21 @@
namespace impeller {
namespace compiler {

// Sets the file access mode of the file at path 'p' to 0644.
static bool SetPermissiveAccess(const std::filesystem::path& p) {
auto permissions =
std::filesystem::perms::owner_read | std::filesystem::perms::owner_write |
std::filesystem::perms::group_read | std::filesystem::perms::others_read;
std::error_code error;
std::filesystem::permissions(p, permissions, error);
if (error) {
std::cerr << "Failed to set access on file '" << p
<< "': " << error.message() << std::endl;
return false;
}
return true;
}

bool Main(const fml::CommandLine& command_line) {
fml::InstallCrashHandler();
if (command_line.HasOption("help")) {
Expand Down Expand Up @@ -110,6 +126,11 @@ bool Main(const fml::CommandLine& command_line) {
<< std::endl;
return false;
}
// Tools that consume the runtime stage data expect the access mode to
// be 0644.
if (!SetPermissiveAccess(sl_file_name)) {
return false;
}
} else {
if (!fml::WriteAtomically(*switches.working_directory,
sl_file_name.string().c_str(),
Expand Down
1 change: 1 addition & 0 deletions lib/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ if (enable_unittests) {
dart_main = "fixtures/ui_test.dart"
fixtures = [
"fixtures/DashInNooglerHat.jpg",
"fixtures/DashInNooglerHat%20WithSpace.jpg",
"fixtures/Horizontal.jpg",
"fixtures/Horizontal.png",
"fixtures/hello_loop_2.gif",
Expand Down
17 changes: 0 additions & 17 deletions lib/ui/compositing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@ class Scene extends NativeFieldWrapperClass1 {
@pragma('vm:entry-point')
Scene._();

/// Synchronously creates a handle to an image from this scene.
///
/// {@macro dart.ui.painting.Picture.toImageSync}
Image toImageSync(int width, int height) {
if (width <= 0 || height <= 0) {
throw Exception('Invalid image dimensions.');
}

final _Image image = _Image._();
final String? result = _toImageSync(width, height, image);
if (result != null) {
throw PictureRasterizationException._(result);
}
return Image._(image, image.width, image.height);
}
String? _toImageSync(int width, int height, _Image outImage) native 'Scene_toImageSync';

/// Creates a raster image representation of the current state of the scene.
/// This is a slow operation that is performed on a background thread.
///
Expand Down
19 changes: 0 additions & 19 deletions lib/ui/compositing/scene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace flutter {
IMPLEMENT_WRAPPERTYPEINFO(ui, Scene);

#define FOR_EACH_BINDING(V) \
V(Scene, toImageSync) \
V(Scene, toImage) \
V(Scene, dispose)

Expand Down Expand Up @@ -67,24 +66,6 @@ void Scene::dispose() {
ClearDartWrapper();
}

Dart_Handle Scene::toImageSync(uint32_t width,
uint32_t height,
Dart_Handle raw_image_handle) {
TRACE_EVENT0("flutter", "Scene::toImageSync");

if (!layer_tree_) {
return tonic::ToDart("Scene did not contain a layer tree.");
}

auto picture = layer_tree_->Flatten(SkRect::MakeWH(width, height));
if (!picture) {
return tonic::ToDart("Could not flatten scene into a layer tree.");
}

Picture::RasterizeToImageSync(picture, width, height, raw_image_handle);
return Dart_Null();
}

Dart_Handle Scene::toImage(uint32_t width,
uint32_t height,
Dart_Handle raw_image_callback) {
Expand Down
4 changes: 0 additions & 4 deletions lib/ui/compositing/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class Scene : public RefCountedDartWrappable<Scene> {

std::unique_ptr<flutter::LayerTree> takeLayerTree();

Dart_Handle toImageSync(uint32_t width,
uint32_t height,
Dart_Handle raw_image_handle);

Dart_Handle toImage(uint32_t width,
uint32_t height,
Dart_Handle image_callback);
Expand Down
Binary file added lib/ui/fixtures/DashInNooglerHat%20WithSpace.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 7 additions & 31 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5375,35 +5375,6 @@ class Picture extends NativeFieldWrapperClass1 {
}
String? _toImage(int width, int height, _Callback<_Image?> callback) native 'Picture_toImage';

/// Synchronously creates a handle to an image of this picture.
///
/// {@template dart.ui.painting.Picture.toImageSync}
/// The returned image will be `width` pixels wide and `height` pixels high.
/// The picture is rasterized within the 0 (left), 0 (top), `width` (right),
/// `height` (bottom) bounds. Content outside these bounds is clipped.
///
/// The image object is created and returned synchronously, but is rasterized
/// asynchronously. If the rasterization fails, an exception will be thrown
/// when the image is drawn to a [Canvas].
///
/// If a GPU context is available, this image will be created as GPU resident
/// and not copied back to the host. This means the image will be more
/// efficient to draw.
///
/// If no GPU context is availalbe, the image will be rasterized on the CPU.
/// {@endtemplate}
Image toImageSync(int width, int height) {
assert(!_disposed);
if (width <= 0 || height <= 0) {
throw Exception('Invalid image dimensions.');
}

final _Image image = _Image._();
_toImageSync(width, height, image);
return Image._(image, image.width, image.height);
}
void _toImageSync(int width, int height, _Image outImage) native 'Picture_toImageSync';

/// Release the resources used by this object. The object is no longer usable
/// after this method is called.
void dispose() {
Expand Down Expand Up @@ -5703,9 +5674,14 @@ class ImmutableBuffer extends NativeFieldWrapperClass1 {
///
/// Throws an [Exception] if the asset does not exist.
static Future<ImmutableBuffer> fromAsset(String assetKey) {
// The flutter tool converts all asset keys with spaces into URI
// encoded paths (replacing ' ' with '%20', for example). We perform
// the same encoding here so that users can load assets with the same
// key they have written in the pubspec.
final String encodedKey = Uri(path: Uri.encodeFull(assetKey)).path;
final ImmutableBuffer instance = ImmutableBuffer._(0);
return _futurize((_Callback<int> callback) {
return instance._initFromAsset(assetKey, callback);
return instance._initFromAsset(encodedKey, callback);
}).then((int length) => instance.._length = length);
}

Expand Down Expand Up @@ -5912,7 +5888,7 @@ Future<T> _futurize<T>(_Callbacker<T> callbacker) {
}

/// An exception thrown by [Canvas.drawImage] and related methods when drawing
/// an [Image] created via [Picture.toImageSync] that is in an invalid state.
/// an [Image] that is in an invalid state.
///
/// This exception may be thrown if the requested image dimensions exceeded the
/// maximum 2D texture size allowed by the GPU, or if no GPU surface or context
Expand Down
41 changes: 0 additions & 41 deletions lib/ui/painting/picture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Picture);

#define FOR_EACH_BINDING(V) \
V(Picture, toImage) \
V(Picture, toImageSync) \
V(Picture, dispose) \
V(Picture, GetAllocationSize)

Expand Down Expand Up @@ -53,46 +52,6 @@ Dart_Handle Picture::toImage(uint32_t width,
raw_image_callback);
}

void Picture::toImageSync(uint32_t width,
uint32_t height,
Dart_Handle raw_image_handle) {
FML_DCHECK(display_list_.skia_object());
RasterizeToImageSync(display_list_.skia_object(), width, height,
raw_image_handle);
}

// static
void Picture::RasterizeToImageSync(sk_sp<DisplayList> display_list,
uint32_t width,
uint32_t height,
Dart_Handle raw_image_handle) {
auto* dart_state = UIDartState::Current();
auto unref_queue = dart_state->GetSkiaUnrefQueue();
auto snapshot_delegate = dart_state->GetSnapshotDelegate();
auto raster_task_runner = dart_state->GetTaskRunners().GetRasterTaskRunner();

auto image = CanvasImage::Create();
auto dl_image = DlDeferredImageGPU::Make(SkISize::Make(width, height));
image->set_image(dl_image);

fml::TaskRunner::RunNowOrPostTask(
raster_task_runner,
[snapshot_delegate, unref_queue, dl_image = std::move(dl_image),
display_list = std::move(display_list)]() {
sk_sp<SkImage> sk_image;
std::string error;
std::tie(sk_image, error) = snapshot_delegate->MakeGpuImage(
display_list, dl_image->dimensions());
if (sk_image) {
dl_image->set_image(std::move(sk_image));
} else {
dl_image->set_error(std::move(error));
}
});

image->AssociateWithDartWrapper(raw_image_handle);
}

void Picture::dispose() {
display_list_.reset();
ClearDartWrapper();
Expand Down
9 changes: 0 additions & 9 deletions lib/ui/painting/picture.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,12 @@ class Picture : public RefCountedDartWrappable<Picture> {
uint32_t height,
Dart_Handle raw_image_callback);

void toImageSync(uint32_t width,
uint32_t height,
Dart_Handle raw_image_handle);

void dispose();

size_t GetAllocationSize() const override;

static void RegisterNatives(tonic::DartLibraryNatives* natives);

static void RasterizeToImageSync(sk_sp<DisplayList> display_list,
uint32_t width,
uint32_t height,
Dart_Handle raw_image_handle);

static Dart_Handle RasterizeToImage(sk_sp<DisplayList> display_list,
uint32_t width,
uint32_t height,
Expand Down
1 change: 0 additions & 1 deletion lib/web_ui/lib/canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ abstract class Canvas {

abstract class Picture {
Future<Image> toImage(int width, int height);
Image toImageSync(int width, int height);
void dispose();
bool get debugDisposed;
int get approximateBytesUsed;
Expand Down
1 change: 0 additions & 1 deletion lib/web_ui/lib/compositing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ part of ui;

abstract class Scene {
Future<Image> toImage(int width, int height);
Image toImageSync(int width, int height);
void dispose();
}

Expand Down
6 changes: 0 additions & 6 deletions lib/web_ui/lib/src/engine/canvaskit/layer_scene_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ class LayerScene implements ui.Scene {
final ui.Picture picture = layerTree.flatten();
return picture.toImage(width, height);
}

@override
ui.Image toImageSync(int width, int height) {
final ui.Picture picture = layerTree.flatten();
return picture.toImageSync(width, height);
}
}

class LayerSceneBuilder implements ui.SceneBuilder {
Expand Down
5 changes: 0 additions & 5 deletions lib/web_ui/lib/src/engine/canvaskit/picture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ class CkPicture extends ManagedSkiaObject<SkPicture> implements ui.Picture {

@override
Future<ui.Image> toImage(int width, int height) async {
return toImageSync(width, height);
}

@override
ui.Image toImageSync(int width, int height) {
assert(debugCheckNotDisposed('Cannot convert picture to image.'));
final SkSurface skSurface = canvasKit.MakeSurface(width, height);
final SkCanvas skCanvas = skSurface.getCanvas();
Expand Down
5 changes: 0 additions & 5 deletions lib/web_ui/lib/src/engine/html/scene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ class SurfaceScene implements ui.Scene {
throw UnsupportedError('toImage is not supported on the Web');
}

@override
ui.Image toImageSync(int width, int height) {
throw UnsupportedError('toImageSync is not supported on the Web');
}

/// Releases the resources used by this scene.
///
/// After calling this function, the scene is cannot be used further.
Expand Down
5 changes: 0 additions & 5 deletions lib/web_ui/lib/src/engine/picture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ class EnginePicture implements ui.Picture {
return onImageLoaded.future;
}

@override
ui.Image toImageSync(int width, int height) {
throw UnsupportedError('toImageSync is not supported on the HTML backend. Use drawPicture instead, or toImage.');
}

bool _disposed = false;

@override
Expand Down
Loading