This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Made toByteData work on wide gamut images (always downscaling to sRGB). #39932
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b599167
Made toByteData work on wide gamut images (always downscaling to sRGB).
gaaclarke 22cd9a3
added unit test
gaaclarke 88ed94b
cleaned up the tests
gaaclarke 5ba4db6
fixed up after rebase
gaaclarke f15abb5
added test for bgr10_xr
gaaclarke daec67a
added license update
gaaclarke 5d073e1
added docstrings
gaaclarke 37d0121
moved the license listing to excluded
gaaclarke 5f4a0cb
moved impeller/renderer/mocks.h to impeller/renderer/testing/mocks.h
gaaclarke b69c32a
removed mocks.h from excluded and listed its directory instead
gaaclarke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "gmock/gmock.h" | ||
| #include "impeller/renderer/allocator.h" | ||
| #include "impeller/renderer/command_buffer.h" | ||
| #include "impeller/renderer/context.h" | ||
| #include "impeller/renderer/render_target.h" | ||
| #include "impeller/renderer/texture.h" | ||
|
|
||
| namespace impeller { | ||
| namespace testing { | ||
|
|
||
| class MockDeviceBuffer : public DeviceBuffer { | ||
| public: | ||
| MockDeviceBuffer(const DeviceBufferDescriptor& desc) : DeviceBuffer(desc) {} | ||
| MOCK_METHOD3(CopyHostBuffer, | ||
| bool(const uint8_t* source, Range source_range, size_t offset)); | ||
|
|
||
| MOCK_METHOD1(SetLabel, bool(const std::string& label)); | ||
|
|
||
| MOCK_METHOD2(SetLabel, bool(const std::string& label, Range range)); | ||
|
|
||
| MOCK_CONST_METHOD0(OnGetContents, uint8_t*()); | ||
|
|
||
| MOCK_METHOD3(OnCopyHostBuffer, | ||
| bool(const uint8_t* source, Range source_range, size_t offset)); | ||
| }; | ||
|
|
||
| class MockAllocator : public Allocator { | ||
| public: | ||
| MOCK_CONST_METHOD0(GetMaxTextureSizeSupported, ISize()); | ||
| MOCK_METHOD1( | ||
| OnCreateBuffer, | ||
| std::shared_ptr<DeviceBuffer>(const DeviceBufferDescriptor& desc)); | ||
| MOCK_METHOD1(OnCreateTexture, | ||
| std::shared_ptr<Texture>(const TextureDescriptor& desc)); | ||
| }; | ||
|
|
||
| class MockBlitPass : public BlitPass { | ||
| public: | ||
| MOCK_CONST_METHOD0(IsValid, bool()); | ||
| MOCK_CONST_METHOD1( | ||
| EncodeCommands, | ||
| bool(const std::shared_ptr<Allocator>& transients_allocator)); | ||
| MOCK_METHOD1(OnSetLabel, void(std::string label)); | ||
|
|
||
| MOCK_METHOD5(OnCopyTextureToTextureCommand, | ||
| bool(std::shared_ptr<Texture> source, | ||
| std::shared_ptr<Texture> destination, | ||
| IRect source_region, | ||
| IPoint destination_origin, | ||
| std::string label)); | ||
|
|
||
| MOCK_METHOD5(OnCopyTextureToBufferCommand, | ||
| bool(std::shared_ptr<Texture> source, | ||
| std::shared_ptr<DeviceBuffer> destination, | ||
| IRect source_region, | ||
| size_t destination_offset, | ||
| std::string label)); | ||
|
|
||
| MOCK_METHOD2(OnGenerateMipmapCommand, | ||
| bool(std::shared_ptr<Texture> texture, std::string label)); | ||
| }; | ||
|
|
||
| class MockCommandBuffer : public CommandBuffer { | ||
| public: | ||
| MockCommandBuffer(std::weak_ptr<const Context> context) | ||
| : CommandBuffer(context) {} | ||
| MOCK_CONST_METHOD0(IsValid, bool()); | ||
| MOCK_CONST_METHOD1(SetLabel, void(const std::string& label)); | ||
| MOCK_CONST_METHOD0(OnCreateBlitPass, std::shared_ptr<BlitPass>()); | ||
| MOCK_METHOD1(OnSubmitCommands, bool(CompletionCallback callback)); | ||
| MOCK_CONST_METHOD0(OnCreateComputePass, std::shared_ptr<ComputePass>()); | ||
| MOCK_METHOD1(OnCreateRenderPass, | ||
| std::shared_ptr<RenderPass>(RenderTarget render_target)); | ||
| }; | ||
|
|
||
| class MockImpellerContext : public Context { | ||
| public: | ||
| MOCK_CONST_METHOD0(IsValid, bool()); | ||
|
|
||
| MOCK_CONST_METHOD0(GetResourceAllocator, std::shared_ptr<Allocator>()); | ||
|
|
||
| MOCK_CONST_METHOD0(GetShaderLibrary, std::shared_ptr<ShaderLibrary>()); | ||
|
|
||
| MOCK_CONST_METHOD0(GetSamplerLibrary, std::shared_ptr<SamplerLibrary>()); | ||
|
|
||
| MOCK_CONST_METHOD0(GetPipelineLibrary, std::shared_ptr<PipelineLibrary>()); | ||
|
|
||
| MOCK_CONST_METHOD0(CreateCommandBuffer, std::shared_ptr<CommandBuffer>()); | ||
|
|
||
| MOCK_CONST_METHOD0(GetWorkQueue, std::shared_ptr<WorkQueue>()); | ||
|
|
||
| MOCK_CONST_METHOD0(GetGPUTracer, std::shared_ptr<GPUTracer>()); | ||
|
|
||
| MOCK_CONST_METHOD0(GetColorAttachmentPixelFormat, PixelFormat()); | ||
|
|
||
| MOCK_CONST_METHOD0(GetDeviceCapabilities, const IDeviceCapabilities&()); | ||
| }; | ||
|
|
||
| class MockTexture : public Texture { | ||
| public: | ||
| MockTexture(const TextureDescriptor& desc) : Texture(desc) {} | ||
| MOCK_METHOD1(SetLabel, void(std::string_view label)); | ||
| MOCK_METHOD3(SetContents, | ||
| bool(const uint8_t* contents, size_t length, size_t slice)); | ||
| MOCK_METHOD2(SetContents, | ||
| bool(std::shared_ptr<const fml::Mapping> mapping, size_t slice)); | ||
| MOCK_CONST_METHOD0(IsValid, bool()); | ||
| MOCK_CONST_METHOD0(GetSize, ISize()); | ||
| MOCK_METHOD3(OnSetContents, | ||
| bool(const uint8_t* contents, size_t length, size_t slice)); | ||
| MOCK_METHOD2(OnSetContents, | ||
| bool(std::shared_ptr<const fml::Mapping> mapping, size_t slice)); | ||
| }; | ||
|
|
||
| } // namespace testing | ||
| } // namespace impeller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this public for easier testing. With a little bit of work I could make the tests work on the existing public api. There is just a bit of threading work required to do that.