Chromium Code Reviews| Index: cc/ipc/copy_output_result_struct_traits.cc |
| diff --git a/cc/ipc/copy_output_result_struct_traits.cc b/cc/ipc/copy_output_result_struct_traits.cc |
| index 0398fe115cd52463b56fbf2a1a1540d3d96b2935..13e64b1667a4388f2a4b8daeb8e6b2a9cc088a15 100644 |
| --- a/cc/ipc/copy_output_result_struct_traits.cc |
| +++ b/cc/ipc/copy_output_result_struct_traits.cc |
| @@ -4,9 +4,60 @@ |
| #include "cc/ipc/copy_output_result_struct_traits.h" |
| +#include "mojo/public/cpp/bindings/strong_binding.h" |
| + |
| +namespace { |
| + |
| +class TextureMailboxReleaserImpl : public cc::mojom::TextureMailboxReleaser { |
|
Fady Samuel
2017/02/11 16:36:57
nit: Please add a comment about where this code ru
|
| + public: |
| + TextureMailboxReleaserImpl( |
| + std::unique_ptr<cc::SingleReleaseCallback> release_callback) |
| + : release_callback_(std::move(release_callback)) {} |
| + |
| + // mojom::TextureMailboxReleaser implementation: |
| + void Release(const gpu::SyncToken& sync_token, bool is_lost) override { |
| + release_callback_->Run(sync_token, is_lost); |
| + } |
| + |
| + private: |
| + std::unique_ptr<cc::SingleReleaseCallback> release_callback_; |
| +}; |
| + |
| +void Release(cc::mojom::TextureMailboxReleaserPtr ptr, |
|
Fady Samuel
2017/02/11 16:36:57
nit: Please a comment about where this is used: in
|
| + const gpu::SyncToken& sync_token, |
| + bool is_lost) { |
| + ptr->Release(sync_token, is_lost); |
| +} |
| + |
| +} // namespace |
| + |
| namespace mojo { |
| // static |
| +const SkBitmap& StructTraits<cc::mojom::CopyOutputResultDataView, |
| + std::unique_ptr<cc::CopyOutputResult>>:: |
| + bitmap(const std::unique_ptr<cc::CopyOutputResult>& result) { |
| + static SkBitmap* null_bitmap = new SkBitmap(); |
| + if (!result->bitmap_) |
| + return *null_bitmap; |
| + return *result->bitmap_; |
| +} |
| + |
| +// static |
| +cc::mojom::TextureMailboxReleaserPtr |
| +StructTraits<cc::mojom::CopyOutputResultDataView, |
| + std::unique_ptr<cc::CopyOutputResult>>:: |
| + releaser(const std::unique_ptr<cc::CopyOutputResult>& result) { |
| + if (!result->release_callback_) |
| + return {}; |
| + cc::mojom::TextureMailboxReleaserPtr releaser; |
| + auto impl = base::MakeUnique<TextureMailboxReleaserImpl>( |
| + std::move(result->release_callback_)); |
| + MakeStrongBinding(std::move(impl), MakeRequest(&releaser)); |
| + return releaser; |
| +} |
| + |
| +// static |
| bool StructTraits<cc::mojom::CopyOutputResultDataView, |
| std::unique_ptr<cc::CopyOutputResult>>:: |
| Read(cc::mojom::CopyOutputResultDataView data, |
| @@ -23,19 +74,15 @@ bool StructTraits<cc::mojom::CopyOutputResultDataView, |
| if (!data.ReadTextureMailbox(&result->texture_mailbox_)) |
| return false; |
| + auto releaser = data.TakeReleaser<cc::mojom::TextureMailboxReleaserPtr>(); |
| + if (releaser) { |
| + result->release_callback_ = cc::SingleReleaseCallback::Create( |
| + base::Bind(Release, base::Passed(&releaser))); |
| + } |
| + |
| *out_p = std::move(result); |
| return true; |
| } |
| -// static |
| -const SkBitmap& StructTraits<cc::mojom::CopyOutputResultDataView, |
| - std::unique_ptr<cc::CopyOutputResult>>:: |
| - bitmap(const std::unique_ptr<cc::CopyOutputResult>& result) { |
| - static SkBitmap* null_bitmap = new SkBitmap(); |
| - if (!result->bitmap_) |
| - return *null_bitmap; |
| - return *result->bitmap_; |
| -} |
| - |
| } // namespace mojo |