Chromium Code Reviews| Index: blimp/client/core/render_widget/blimp_render_widget.h |
| diff --git a/blimp/client/core/render_widget/blimp_render_widget.h b/blimp/client/core/render_widget/blimp_render_widget.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6336b1a63cfd5560df21bdcddd2485b759797b7d |
| --- /dev/null |
| +++ b/blimp/client/core/render_widget/blimp_render_widget.h |
| @@ -0,0 +1,117 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_RENDER_WIDGET_H_ |
| +#define BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_RENDER_WIDGET_H_ |
| + |
| +#include "base/callback_forward.h" |
| +#include "base/macros.h" |
| +#include "blimp/client/core/compositor/blimp_compositor.h" |
| +#include "ui/gfx/native_widget_types.h" |
| + |
| +namespace cc { |
| +namespace proto { |
| +class CompositorMessage; |
| +} // namespace proto |
| +} // namespace cc |
| + |
| +namespace ui { |
| +class MotionEvent; |
| +} // namespace ui |
| + |
| +namespace blimp { |
| +namespace client { |
| +class BlimpCompositor; |
| +class BlimpRenderWidgetDelegate; |
| +class CompositorDepsProvider; |
| + |
| +// The BlimpRenderWidget is the blimp counterpart to the RenderWidget. This is |
| +// the model object that owns all the compositing and input state for a render |
| +// widget on the engine, and is our connection to the engine side renderer. |
| +class BlimpRenderWidget : public BlimpCompositorClient { |
| + public: |
| + BlimpRenderWidget(int32_t render_widget_id, |
| + CompositorDepsProvider* compositor_deps_provider, |
| + BlimpRenderWidgetDelegate* delegate); |
| + ~BlimpRenderWidget() override; |
| + |
| + int32_t GetId() const; |
| + |
| + void set_did_swap_buffers_callback(base::Closure callback) { |
| + did_swap_buffers_callback_ = callback; |
| + } |
| + |
| + // The following method is used when the compositor for the renderwidget has |
| + // an on-screen context to draw directly to the native widget. It is legal to |
| + // call this only if use_delegated_rendering is true for the |
| + // CompositorDepsProvider passed when creating the widget. |
| + virtual void SetAcceleratedWidget(gfx::AcceleratedWidget widget); |
| + |
| + virtual void SetVisible(bool visible); |
| + |
| + // Move to the BlimpRenderWidgetView. |
| + bool OnTouchEvent(const ui::MotionEvent& motion_event); |
| + |
| + virtual void OnCompositorMessageReceived( |
| + std::unique_ptr<cc::proto::CompositorMessage> message); |
| + |
| + BlimpCompositor* GetCompositorForTesting() const { return compositor_.get(); } |
| + |
| + private: |
| + friend class BlimpRenderWidgetTest; |
| + |
| + 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!
|
| + public: |
| + explicit DirectRenderingDeps(BlimpRenderWidget* render_widget); |
| + ~DirectRenderingDeps(); |
| + |
| + void SetAcceleratedWidget(gfx::AcceleratedWidget widget); |
| + void SetVisible(bool visible); |
| + |
| + void RequestOutputSurface(); |
| + |
| + private: |
| + void HandlePendingOutputSurfaceRequest(); |
| + void UpdateVisibility(bool visible); |
| + |
| + BlimpRenderWidget* render_widget_; |
| + |
| + gfx::AcceleratedWidget window_; |
| + bool visible_; |
| + |
| + // Whether there is an OutputSurface request pending from the current |
| + // compositor. Becomes |true| if RequestOutputSurface is called, and |false| |
| + // if compositor is deleted or we succeed in creating an OutputSurface. |
| + bool output_surface_request_pending_; |
| + }; |
| + |
| + // BlimpCompositorClient implementation. |
| + void DidCompleteSwapBuffers() override; |
| + void DidCommitAndDrawFrame() override; |
| + void SendWebGestureEvent( |
| + const blink::WebGestureEvent& gesture_event) override; |
| + void SendCompositorMessage( |
| + const cc::proto::CompositorMessage& message) override; |
| + void RequestOutputSurface() override; |
| + |
| + const int32_t render_widget_id_; |
| + |
| + CompositorDepsProvider* compositor_deps_provider_; |
| + BlimpRenderWidgetDelegate* delegate_; |
| + |
| + std::unique_ptr<DirectRenderingDeps> direct_rendering_deps_; |
| + |
| + base::Closure did_swap_buffers_callback_; |
| + |
| + // TODO(khushalsagar): Change this to the remote compositor once it moves to |
| + // cc/blimp. |
| + std::unique_ptr<BlimpCompositor> compositor_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BlimpRenderWidget); |
| +}; |
| + |
| +} // namespace client |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_RENDER_WIDGET_H_ |