mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
The new ui.Codec API is a superset of the implementation in image_decoding.cc. While we are not using ui.decodeImageFromList in the framework anymore, we keep the dart function for backward compatability, and just make it a thin wrapper around the codec API.
84 lines
3.0 KiB
C++
84 lines
3.0 KiB
C++
// Copyright 2014 The Chromium 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/lib/ui/dart_ui.h"
|
|
|
|
#include "flutter/lib/ui/compositing/scene.h"
|
|
#include "flutter/lib/ui/compositing/scene_builder.h"
|
|
#include "flutter/lib/ui/dart_runtime_hooks.h"
|
|
#include "flutter/lib/ui/painting/canvas.h"
|
|
#include "flutter/lib/ui/painting/codec.h"
|
|
#include "flutter/lib/ui/painting/frame_info.h"
|
|
#include "flutter/lib/ui/painting/gradient.h"
|
|
#include "flutter/lib/ui/painting/image.h"
|
|
#include "flutter/lib/ui/painting/image_filter.h"
|
|
#include "flutter/lib/ui/painting/image_shader.h"
|
|
#include "flutter/lib/ui/painting/mask_filter.h"
|
|
#include "flutter/lib/ui/painting/path.h"
|
|
#include "flutter/lib/ui/painting/picture.h"
|
|
#include "flutter/lib/ui/painting/picture_recorder.h"
|
|
#include "flutter/lib/ui/painting/vertices.h"
|
|
#include "flutter/lib/ui/semantics/semantics_update.h"
|
|
#include "flutter/lib/ui/semantics/semantics_update_builder.h"
|
|
#include "flutter/lib/ui/text/paragraph.h"
|
|
#include "flutter/lib/ui/text/paragraph_builder.h"
|
|
#include "flutter/lib/ui/window/window.h"
|
|
#include "lib/fxl/build_config.h"
|
|
#include "lib/tonic/converter/dart_converter.h"
|
|
#include "lib/tonic/logging/dart_error.h"
|
|
|
|
using tonic::ToDart;
|
|
|
|
namespace blink {
|
|
namespace {
|
|
|
|
static tonic::DartLibraryNatives* g_natives;
|
|
|
|
Dart_NativeFunction GetNativeFunction(Dart_Handle name,
|
|
int argument_count,
|
|
bool* auto_setup_scope) {
|
|
return g_natives->GetNativeFunction(name, argument_count, auto_setup_scope);
|
|
}
|
|
|
|
const uint8_t* GetSymbol(Dart_NativeFunction native_function) {
|
|
return g_natives->GetSymbol(native_function);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
void DartUI::InitForGlobal() {
|
|
if (!g_natives) {
|
|
g_natives = new tonic::DartLibraryNatives();
|
|
Canvas::RegisterNatives(g_natives);
|
|
CanvasGradient::RegisterNatives(g_natives);
|
|
CanvasImage::RegisterNatives(g_natives);
|
|
CanvasPath::RegisterNatives(g_natives);
|
|
Codec::RegisterNatives(g_natives);
|
|
DartRuntimeHooks::RegisterNatives(g_natives);
|
|
FrameInfo::RegisterNatives(g_natives);
|
|
ImageFilter::RegisterNatives(g_natives);
|
|
ImageShader::RegisterNatives(g_natives);
|
|
MaskFilter::RegisterNatives(g_natives);
|
|
Paragraph::RegisterNatives(g_natives);
|
|
ParagraphBuilder::RegisterNatives(g_natives);
|
|
Picture::RegisterNatives(g_natives);
|
|
PictureRecorder::RegisterNatives(g_natives);
|
|
Scene::RegisterNatives(g_natives);
|
|
SceneBuilder::RegisterNatives(g_natives);
|
|
SceneHost::RegisterNatives(g_natives);
|
|
SemanticsUpdate::RegisterNatives(g_natives);
|
|
SemanticsUpdateBuilder::RegisterNatives(g_natives);
|
|
Vertices::RegisterNatives(g_natives);
|
|
Window::RegisterNatives(g_natives);
|
|
}
|
|
}
|
|
|
|
void DartUI::InitForIsolate() {
|
|
FXL_DCHECK(g_natives);
|
|
DART_CHECK_VALID(Dart_SetNativeResolver(Dart_LookupLibrary(ToDart("dart:ui")),
|
|
GetNativeFunction, GetSymbol));
|
|
}
|
|
|
|
} // namespace blink
|