| 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/render_widget/blimp_document.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/threading/thread_task_runner_handle.h" | |
| 9 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" | |
| 10 #include "blimp/client/core/input/blimp_input_manager.h" | |
| 11 #include "blimp/client/core/render_widget/blimp_document_manager.h" | |
| 12 #include "blimp/client/core/switches/blimp_client_switches.h" | |
| 13 #include "cc/layers/layer.h" | |
| 14 | |
| 15 namespace blimp { | |
| 16 namespace client { | |
| 17 | |
| 18 BlimpDocument::BlimpDocument(int document_id, | |
| 19 BlimpCompositorDependencies* compositor_deps, | |
| 20 BlimpDocumentManager* document_manager) | |
| 21 : BlimpDocument(document_id, | |
| 22 BlimpCompositor::Create(compositor_deps, this), | |
| 23 compositor_deps, | |
| 24 document_manager) {} | |
| 25 | |
| 26 BlimpDocument::BlimpDocument(int document_id, | |
| 27 std::unique_ptr<BlimpCompositor> compositor, | |
| 28 BlimpCompositorDependencies* compositor_deps, | |
| 29 BlimpDocumentManager* document_manager) | |
| 30 : document_id_(document_id), | |
| 31 compositor_(std::move(compositor)), | |
| 32 manager_(document_manager) { | |
| 33 input_manager_ = | |
| 34 BlimpInputManager::Create(this, base::ThreadTaskRunnerHandle::Get(), | |
| 35 compositor_deps->GetCompositorTaskRunner(), | |
| 36 compositor_->GetInputHandler()); | |
| 37 } | |
| 38 | |
| 39 BlimpDocument::~BlimpDocument() { | |
| 40 compositor_.reset(); | |
| 41 | |
| 42 // Destroy the old input manager state. | |
| 43 // It is important to destroy the LayerTreeHost before destroying the input | |
| 44 // manager as it has a reference to the cc::InputHandlerClient owned by the | |
| 45 // BlimpInputManager. | |
| 46 input_manager_.reset(); | |
| 47 } | |
| 48 | |
| 49 BlimpCompositor* BlimpDocument::GetCompositor() { | |
| 50 return compositor_.get(); | |
| 51 } | |
| 52 | |
| 53 bool BlimpDocument::OnTouchEvent(const ui::MotionEvent& motion_event) { | |
| 54 if (input_manager_) | |
| 55 return input_manager_->OnTouchEvent(motion_event); | |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 void BlimpDocument::SendCompositorMessage( | |
| 60 const cc::proto::CompositorMessage& message) { | |
| 61 manager_->SendCompositorMessage(document_id_, message); | |
| 62 } | |
| 63 | |
| 64 void BlimpDocument::SendWebGestureEvent( | |
| 65 const blink::WebGestureEvent& gesture_event) { | |
| 66 manager_->SendWebGestureEvent(document_id_, gesture_event); | |
| 67 } | |
| 68 | |
| 69 } // namespace client | |
| 70 } // namespace blimp | |
| OLD | NEW |