Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
images_impeller.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
9#include "third_party/skia/include/core/SkData.h"
10#include "third_party/skia/include/core/SkImage.h"
11
13 // TODO(jacksongardner):
14 // This function is just here so that we have references to these API
15 // functions in the build. If we don't reference them, they get LTO'd out and
16 // then emscripten gets fails to build the javascript support library. These
17 // all will eventually be actually used when we implement proper image
18 // support, at which time we can just remove this function entirely.
19 // https://github.com/flutter/flutter/issues/175371
20 SkwasmObject object = __builtin_wasm_ref_null_extern();
21 skwasm_setAssociatedObjectOnThread(0, nullptr, object);
25}
26
27namespace {
28// TODO(jacksongardner): Implement proper image support in wimp.
29// See https://github.com/flutter/flutter/issues/175371
30class StubImage : public flutter::DlImage {
31 public:
32 StubImage(int width, int height) : width_(width), height_(height) {}
33
34 static sk_sp<StubImage> Make(int width, int height) {
35 return sk_make_sp<StubImage>(width, height);
36 }
37
38 // |DlImage|
39 sk_sp<SkImage> skia_image() const override { return nullptr; }
40
41 // |DlImage|
42 std::shared_ptr<impeller::Texture> impeller_texture() const override {
43 return nullptr;
44 }
45
46 // |DlImage|
47 bool isOpaque() const override { return false; }
48
49 // |DlImage|
50 bool isTextureBacked() const override { return false; }
51
52 // |DlImage|
53 bool isUIThreadSafe() const override { return true; }
54
55 // |DlImage|
56 flutter::DlISize GetSize() const override {
57 return flutter::DlISize::MakeWH(width_, height_);
58 }
59
60 // |DlImage|
61 size_t GetApproximateByteSize() const override { return 0; }
62
63 private:
64 int width_;
65 int height_;
66};
67} // namespace
68
69namespace Skwasm {
70
71sk_sp<flutter::DlImage> MakeImageFromPicture(flutter::DisplayList* display_list,
72 int32_t width,
73 int32_t height) {
74 return StubImage::Make(width, height);
75}
76
77sk_sp<flutter::DlImage> MakeImageFromTexture(SkwasmObject texture_source,
78 int width,
79 int height,
80 Skwasm::Surface* surface) {
81 return StubImage::Make(width, height);
82}
83
84sk_sp<flutter::DlImage> MakeImageFromPixels(SkData* data,
85 int width,
86 int height,
87 Skwasm::PixelFormat pixel_format,
88 size_t row_byte_count) {
89 return StubImage::Make(width, height);
90}
91} // namespace Skwasm
Represents an image whose allocation is (usually) resident on device memory.
Definition dl_image.h:32
virtual size_t GetApproximateByteSize() const =0
virtual DlISize GetSize() const =0
virtual bool isTextureBacked() const =0
virtual bool isOpaque() const =0
If the pixel format of this image ignores alpha, this returns true. This method might conservatively ...
static sk_sp< DlImage > Make(const SkImage *image)
Definition dl_image.cc:11
virtual std::shared_ptr< impeller::Texture > impeller_texture() const =0
If this display list image is meant to be used by the Impeller backend, an Impeller texture instance....
virtual bool isUIThreadSafe() const =0
If the underlying platform image held by this object has no threading requirements for the release of...
virtual sk_sp< SkImage > skia_image() const =0
If this display list image is meant to be used by the Skia backend, an SkImage instance....
SKWASM_EXPORT void dummyAPICalls()
sk_sp< flutter::DlImage > MakeImageFromTexture(SkwasmObject texture_source, int width, int height, Skwasm::Surface *surface)
__externref_t SkwasmObject
Definition wrappers.h:18
sk_sp< flutter::DlImage > MakeImageFromPicture(flutter::DisplayList *display_list, int32_t width, int32_t height)
PixelFormat
Definition images.h:13
sk_sp< flutter::DlImage > MakeImageFromPixels(SkData *data, int width, int height, PixelFormat pixel_format, size_t row_byte_count)
int32_t height
int32_t width
#define SKWASM_EXPORT
Definition export.h:10
SkwasmObject skwasm_getAssociatedObject(void *pointer)
__externref_t SkwasmObject
unsigned int skwasm_createGlTextureFromTextureSource(SkwasmObject texture_source, int width, int height)
void skwasm_disposeAssociatedObjectOnThread(unsigned long thread_id, void *pointer)
void skwasm_setAssociatedObjectOnThread(unsigned long thread_id, void *pointer, SkwasmObject object)
static constexpr TSize MakeWH(Type width, Type height)
Definition size.h:43
std::shared_ptr< const fml::Mapping > data