Chromium Code Reviews| 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 #ifndef BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_RENDER_WIDGET_H_ | |
| 6 #define BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_RENDER_WIDGET_H_ | |
| 7 | |
| 8 #include "base/callback_forward.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "blimp/client/core/compositor/blimp_compositor.h" | |
| 11 #include "ui/gfx/native_widget_types.h" | |
| 12 | |
| 13 namespace cc { | |
| 14 namespace proto { | |
| 15 class CompositorMessage; | |
| 16 } // namespace proto | |
| 17 } // namespace cc | |
| 18 | |
| 19 namespace ui { | |
| 20 class MotionEvent; | |
| 21 } // namespace ui | |
| 22 | |
| 23 namespace blimp { | |
| 24 namespace client { | |
| 25 class BlimpCompositor; | |
| 26 class BlimpRenderWidgetDelegate; | |
| 27 class CompositorDepsProvider; | |
| 28 | |
| 29 // The BlimpRenderWidget is the blimp counterpart to the RenderWidget. This is | |
| 30 // the model object that owns all the compositing and input state for a render | |
| 31 // widget on the engine, and is our connection to the engine side renderer. | |
| 32 class BlimpRenderWidget : public BlimpCompositorClient { | |
| 33 public: | |
| 34 BlimpRenderWidget(int32_t render_widget_id, | |
| 35 CompositorDepsProvider* compositor_deps_provider, | |
| 36 BlimpRenderWidgetDelegate* delegate); | |
| 37 ~BlimpRenderWidget() override; | |
| 38 | |
| 39 int32_t GetId() const; | |
| 40 | |
| 41 void set_did_swap_buffers_callback(base::Closure callback) { | |
| 42 did_swap_buffers_callback_ = callback; | |
| 43 } | |
| 44 | |
| 45 // The following method is used when the compositor for the renderwidget has | |
| 46 // an on-screen context to draw directly to the native widget. It is legal to | |
| 47 // call this only if use_delegated_rendering is true for the | |
| 48 // CompositorDepsProvider passed when creating the widget. | |
| 49 virtual void SetAcceleratedWidget(gfx::AcceleratedWidget widget); | |
| 50 | |
| 51 virtual void SetVisible(bool visible); | |
| 52 | |
| 53 // Move to the BlimpRenderWidgetView. | |
| 54 bool OnTouchEvent(const ui::MotionEvent& motion_event); | |
| 55 | |
| 56 virtual void OnCompositorMessageReceived( | |
| 57 std::unique_ptr<cc::proto::CompositorMessage> message); | |
| 58 | |
| 59 BlimpCompositor* GetCompositorForTesting() const { return compositor_.get(); } | |
| 60 | |
| 61 private: | |
| 62 friend class BlimpRenderWidgetTest; | |
| 63 | |
| 64 class DirectRenderingDeps { | |
|
nyquist
2016/08/12 07:34:28
Could this just be a forward declaration in the da
Khushal
2016/08/13 00:03:22
That's an awesome idea. Thanks! Done!
| |
| 65 public: | |
| 66 explicit DirectRenderingDeps(BlimpRenderWidget* render_widget); | |
| 67 ~DirectRenderingDeps(); | |
| 68 | |
| 69 void SetAcceleratedWidget(gfx::AcceleratedWidget widget); | |
| 70 void SetVisible(bool visible); | |
| 71 | |
| 72 void RequestOutputSurface(); | |
| 73 | |
| 74 private: | |
| 75 void HandlePendingOutputSurfaceRequest(); | |
| 76 void UpdateVisibility(bool visible); | |
| 77 | |
| 78 BlimpRenderWidget* render_widget_; | |
| 79 | |
| 80 gfx::AcceleratedWidget window_; | |
| 81 bool visible_; | |
| 82 | |
| 83 // Whether there is an OutputSurface request pending from the current | |
| 84 // compositor. Becomes |true| if RequestOutputSurface is called, and |false| | |
| 85 // if compositor is deleted or we succeed in creating an OutputSurface. | |
| 86 bool output_surface_request_pending_; | |
| 87 }; | |
| 88 | |
| 89 // BlimpCompositorClient implementation. | |
| 90 void DidCompleteSwapBuffers() override; | |
| 91 void DidCommitAndDrawFrame() override; | |
| 92 void SendWebGestureEvent( | |
| 93 const blink::WebGestureEvent& gesture_event) override; | |
| 94 void SendCompositorMessage( | |
| 95 const cc::proto::CompositorMessage& message) override; | |
| 96 void RequestOutputSurface() override; | |
| 97 | |
| 98 const int32_t render_widget_id_; | |
| 99 | |
| 100 CompositorDepsProvider* compositor_deps_provider_; | |
| 101 BlimpRenderWidgetDelegate* delegate_; | |
| 102 | |
| 103 std::unique_ptr<DirectRenderingDeps> direct_rendering_deps_; | |
| 104 | |
| 105 base::Closure did_swap_buffers_callback_; | |
| 106 | |
| 107 // TODO(khushalsagar): Change this to the remote compositor once it moves to | |
| 108 // cc/blimp. | |
| 109 std::unique_ptr<BlimpCompositor> compositor_; | |
| 110 | |
| 111 DISALLOW_COPY_AND_ASSIGN(BlimpRenderWidget); | |
| 112 }; | |
| 113 | |
| 114 } // namespace client | |
| 115 } // namespace blimp | |
| 116 | |
| 117 #endif // BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_RENDER_WIDGET_H_ | |
| OLD | NEW |