| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium 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 #include "blimp/client/core/contents/blimp_contents_view_impl.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/callback_helpers.h" | |
| 9 #include "base/threading/thread_task_runner_handle.h" | |
| 10 #include "blimp/client/core/contents/blimp_contents_impl.h" | |
| 11 #include "cc/output/copy_output_request.h" | |
| 12 #include "cc/output/copy_output_result.h" | |
| 13 #include "ui/gfx/geometry/size.h" | |
| 14 | |
| 15 namespace blimp { | |
| 16 namespace client { | |
| 17 | |
| 18 namespace { | |
| 19 | |
| 20 void SendReadbackResult( | |
| 21 const BlimpContentsView::ReadbackRequestCallback& callback, | |
| 22 std::unique_ptr<cc::CopyOutputResult> result) { | |
| 23 callback.Run(result->TakeBitmap()); | |
| 24 } | |
| 25 | |
| 26 } // namespace | |
| 27 | |
| 28 BlimpContentsViewImpl::BlimpContentsViewImpl( | |
| 29 BlimpContentsImpl* blimp_contents, | |
| 30 scoped_refptr<cc::Layer> contents_layer) | |
| 31 : blimp_contents_(blimp_contents), | |
| 32 contents_layer_(std::move(contents_layer)), | |
| 33 weak_ptr_factory_(this) { | |
| 34 DCHECK(blimp_contents_); | |
| 35 DCHECK(contents_layer_); | |
| 36 } | |
| 37 | |
| 38 BlimpContentsViewImpl::~BlimpContentsViewImpl() = default; | |
| 39 | |
| 40 scoped_refptr<cc::Layer> BlimpContentsViewImpl::GetLayer() { | |
| 41 return contents_layer_; | |
| 42 } | |
| 43 | |
| 44 void BlimpContentsViewImpl::SetSizeAndScale(const gfx::Size& size, | |
| 45 float device_scale_factor) { | |
| 46 blimp_contents_->SetSizeAndScale(size, device_scale_factor); | |
| 47 } | |
| 48 | |
| 49 bool BlimpContentsViewImpl::OnTouchEvent(const ui::MotionEvent& motion_event) { | |
| 50 return blimp_contents_->document_manager()->OnTouchEvent(motion_event); | |
| 51 } | |
| 52 | |
| 53 void BlimpContentsViewImpl::CopyFromCompositingSurface( | |
| 54 const ReadbackRequestCallback& callback) { | |
| 55 blimp_contents_->document_manager()->RequestCopyOfCompositorOutput( | |
| 56 cc::CopyOutputRequest::CreateBitmapRequest( | |
| 57 base::Bind(&SendReadbackResult, callback)), | |
| 58 true); | |
| 59 } | |
| 60 | |
| 61 } // namespace client | |
| 62 } // namespace blimp | |
| OLD | NEW |