|
10 | 10 | #include "flutter/fml/make_copyable.h" |
11 | 11 | #include "flutter/fml/trace_event.h" |
12 | 12 | #include "flutter/impeller/core/allocator.h" |
13 | | -#include "flutter/impeller/core/texture.h" |
14 | 13 | #include "flutter/impeller/display_list/dl_image_impeller.h" |
15 | 14 | #include "flutter/impeller/renderer/command_buffer.h" |
16 | 15 | #include "flutter/impeller/renderer/context.h" |
17 | | -#include "flutter/lib/ui/painting/image_decoder_skia.h" |
18 | 16 | #include "impeller/base/strings.h" |
19 | 17 | #include "impeller/display_list/skia_conversions.h" |
20 | 18 | #include "impeller/geometry/size.h" |
| 19 | + |
21 | 20 | #include "third_party/skia/include/core/SkAlphaType.h" |
22 | 21 | #include "third_party/skia/include/core/SkBitmap.h" |
23 | 22 | #include "third_party/skia/include/core/SkColorSpace.h" |
|
32 | 31 |
|
33 | 32 | namespace flutter { |
34 | 33 |
|
35 | | -class MallocDeviceBuffer : public impeller::DeviceBuffer { |
36 | | - public: |
37 | | - explicit MallocDeviceBuffer(impeller::DeviceBufferDescriptor desc) |
38 | | - : impeller::DeviceBuffer(desc) { |
39 | | - data_ = static_cast<uint8_t*>(malloc(desc.size)); |
40 | | - } |
41 | | - |
42 | | - ~MallocDeviceBuffer() override { free(data_); } |
43 | | - |
44 | | - bool SetLabel(const std::string& label) override { return true; } |
45 | | - |
46 | | - bool SetLabel(const std::string& label, impeller::Range range) override { |
47 | | - return true; |
48 | | - } |
49 | | - |
50 | | - uint8_t* OnGetContents() const override { return data_; } |
51 | | - |
52 | | - bool OnCopyHostBuffer(const uint8_t* source, |
53 | | - impeller::Range source_range, |
54 | | - size_t offset) override { |
55 | | - memcpy(data_ + offset, source + source_range.offset, source_range.length); |
56 | | - return true; |
57 | | - } |
58 | | - |
59 | | - private: |
60 | | - uint8_t* data_; |
61 | | - |
62 | | - FML_DISALLOW_COPY_AND_ASSIGN(MallocDeviceBuffer); |
63 | | -}; |
64 | | - |
65 | | -#ifdef FML_OS_ANDROID |
66 | | -static constexpr bool kShouldUseMallocDeviceBuffer = true; |
67 | | -#else |
68 | | -static constexpr bool kShouldUseMallocDeviceBuffer = false; |
69 | | -#endif // FML_OS_ANDROID |
70 | | - |
71 | 34 | namespace { |
72 | 35 | /** |
73 | 36 | * Loads the gamut as a set of three points (triangle). |
@@ -522,8 +485,7 @@ void ImageDecoderImpeller::Decode(fml::RefPtr<ImageDescriptor> descriptor, |
522 | 485 | gpu_disabled_switch]() { |
523 | 486 | sk_sp<DlImage> image; |
524 | 487 | std::string decode_error; |
525 | | - if (!kShouldUseMallocDeviceBuffer && |
526 | | - context->GetCapabilities()->SupportsBufferToTextureBlits()) { |
| 488 | + if (context->GetCapabilities()->SupportsBufferToTextureBlits()) { |
527 | 489 | std::tie(image, decode_error) = UploadTextureToPrivate( |
528 | 490 | context, bitmap_result.device_buffer, bitmap_result.image_info, |
529 | 491 | bitmap_result.sk_bitmap, gpu_disabled_switch); |
@@ -567,9 +529,7 @@ bool ImpellerAllocator::allocPixelRef(SkBitmap* bitmap) { |
567 | 529 | (bitmap->width() * bitmap->bytesPerPixel()); |
568 | 530 |
|
569 | 531 | std::shared_ptr<impeller::DeviceBuffer> device_buffer = |
570 | | - kShouldUseMallocDeviceBuffer |
571 | | - ? std::make_shared<MallocDeviceBuffer>(descriptor) |
572 | | - : allocator_->CreateBuffer(descriptor); |
| 532 | + allocator_->CreateBuffer(descriptor); |
573 | 533 |
|
574 | 534 | struct ImpellerPixelRef final : public SkPixelRef { |
575 | 535 | ImpellerPixelRef(int w, int h, void* s, size_t r) |
|
0 commit comments