Flutter Engine
 
Loading...
Searching...
No Matches
image_decoder_no_gl_unittests.h
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
5#ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_NO_GL_UNITTESTS_H_
6#define FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_NO_GL_UNITTESTS_H_
7
8#include <stdint.h>
9
17
18namespace impeller {
19
21 public:
23
24 void SetLabel(std::string_view label) override {}
25 void SetLabel(std::string_view label, std::string_view trailing) override {}
26 bool IsValid() const override { return true; }
27 ISize GetSize() const { return GetTextureDescriptor().size; }
28
29 bool OnSetContents(const uint8_t* contents, size_t length, size_t slice) {
30 return true;
31 }
32 bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
33 size_t slice) {
34 return true;
35 }
36};
37
39 public:
41 : DeviceBuffer(desc) {
42 bytes_ = static_cast<uint8_t*>(malloc(desc.size));
43 }
44
45 ~TestImpellerDeviceBuffer() { free(bytes_); }
46
47 private:
48 bool SetLabel(std::string_view label) override { return true; }
49
50 bool SetLabel(std::string_view label, Range range) override { return true; }
51
52 uint8_t* OnGetContents() const override { return bytes_; }
53
54 bool OnCopyHostBuffer(const uint8_t* source,
55 Range source_range,
56 size_t offset) override {
57 for (auto i = source_range.offset; i < source_range.length; i++, offset++) {
58 bytes_[offset] = source[i];
59 }
60 return true;
61 }
62
63 uint8_t* bytes_;
64};
65
67 public:
69
71
72 private:
73 uint16_t MinimumBytesPerRow(PixelFormat format) const override { return 0; }
74
75 ISize GetMaxTextureSizeSupported() const override {
76 return ISize{2048, 2048};
77 }
78
79 std::shared_ptr<DeviceBuffer> OnCreateBuffer(
80 const DeviceBufferDescriptor& desc) override {
81 return std::make_shared<TestImpellerDeviceBuffer>(desc);
82 }
83
84 std::shared_ptr<Texture> OnCreateTexture(const TextureDescriptor& desc,
85 bool threadsafe) override {
86 return std::make_shared<TestImpellerTexture>(desc);
87 }
88};
89
90} // namespace impeller
91
92namespace flutter {
93namespace testing {
94
95float HalfToFloat(uint16_t half);
96float DecodeBGR10(uint32_t x);
97
98} // namespace testing
99} // namespace flutter
100
101#endif // FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_NO_GL_UNITTESTS_H_
An object that allocates device memory.
Definition allocator.h:24
TestImpellerDeviceBuffer(DeviceBufferDescriptor desc)
bool OnSetContents(const uint8_t *contents, size_t length, size_t slice)
bool OnSetContents(std::shared_ptr< const fml::Mapping > mapping, size_t slice)
void SetLabel(std::string_view label) override
Label this resource for inspection in GPU debugging tools.
void SetLabel(std::string_view label, std::string_view trailing) override
Label this resource for inspection in GPU debugging tools, with label and trailing will be concatenat...
const TextureDescriptor & GetTextureDescriptor() const
Definition texture.cc:57
int32_t x
size_t length
float HalfToFloat(uint16_t half)
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:99
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...