| Index: blimp/client/compositor/blimp_compositor.h
|
| diff --git a/blimp/client/compositor/blimp_compositor.h b/blimp/client/compositor/blimp_compositor.h
|
| index f9b319d102104f2e3814ce7d53794679504754e5..dff777ba2f98d00cccf8eea15f43dd151d8d202c 100644
|
| --- a/blimp/client/compositor/blimp_compositor.h
|
| +++ b/blimp/client/compositor/blimp_compositor.h
|
| @@ -5,11 +5,16 @@
|
| #ifndef BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_
|
| #define BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_
|
|
|
| +#include <vector>
|
| +
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "blimp/client/blimp_client_export.h"
|
| +#include "blimp/client/compositor/render_widget_message_processor.h"
|
| #include "cc/trees/layer_tree_host_client.h"
|
| #include "cc/trees/layer_tree_settings.h"
|
| +#include "cc/trees/remote_proto_channel.h"
|
| #include "ui/gfx/geometry/size.h"
|
| #include "ui/gfx/native_widget_types.h"
|
|
|
| @@ -24,17 +29,57 @@ class LayerTreeHost;
|
|
|
| namespace blimp {
|
|
|
| +class BlimpMessage;
|
| +
|
| // BlimpCompositor provides the basic framework and setup to host a
|
| -// LayerTreeHost (compositor). The rendering surface this compositor draws to
|
| -// is defined by the gfx::AcceleratedWidget returned by
|
| -// BlimpCompositor::GetWindow().
|
| -class BlimpCompositor : public cc::LayerTreeHostClient {
|
| +// LayerTreeHost. The class that owns the LayerTreeHost is usually called the
|
| +// compositor, but the LayerTreeHost does the compositing work. The rendering
|
| +// surface this compositor draws to is defined by the gfx::AcceleratedWidget set
|
| +// by SetAcceleratedWidget(). This class should only be accessed from the main
|
| +// thread. Any interaction with the compositing thread should happen through
|
| +// the LayerTreeHost or RemoteChannelImpl.
|
| +class BLIMP_CLIENT_EXPORT BlimpCompositor
|
| + : public cc::LayerTreeHostClient,
|
| + public cc::RemoteProtoChannel,
|
| + public RenderWidgetMessageProcessor::RenderWidgetMessageDelegate {
|
| +
|
| public:
|
| ~BlimpCompositor() override;
|
|
|
| + // Sets whether or not this compositor actually draws to the output surface.
|
| + // Setting this to false will make the compositor drop all of its resources
|
| + // and the output surface. Setting it to true again will rebuild the output
|
| + // surface from the gfx::AcceleratedWidget (see SetAcceleratedWidget).
|
| void SetVisible(bool visible);
|
| +
|
| + // Sets the size of the viewport on the compositor.
|
| + // TODO(dtrainor): Should this be set from the engine all the time?
|
| void SetSize(const gfx::Size& size);
|
|
|
| + // Lets this compositor know that it can draw to |widget|. This means that,
|
| + // if this compositor is visible, it will build an output surface and GL
|
| + // context around |widget| and will draw to it. ReleaseAcceleratedWidget()
|
| + // *must* be called before SetAcceleratedWidget() is called with the same
|
| + // gfx::AcceleratedWidget on another compositor.
|
| + void SetAcceleratedWidget(gfx::AcceleratedWidget widget);
|
| +
|
| + // Releases the internally stored gfx::AcceleratedWidget and the associated
|
| + // output surface. This must be called before calling
|
| + // SetAcceleratedWidget() with the same gfx::AcceleratedWidget on another
|
| + // compositor.
|
| + void ReleaseAcceleratedWidget();
|
| +
|
| + protected:
|
| + // |dp_to_px| is the scale factor required to move from dp (device pixels) to
|
| + // px. See https://developer.android.com/guide/practices/screens_support.html
|
| + // for more details.
|
| + explicit BlimpCompositor(float dp_to_px);
|
| +
|
| + // Populates the cc::LayerTreeSettings used by the cc::LayerTreeHost. Can be
|
| + // overridden to provide custom settings parameters.
|
| + virtual void GenerateLayerTreeSettings(cc::LayerTreeSettings* settings);
|
| +
|
| + private:
|
| // LayerTreeHostClient implementation.
|
| void WillBeginMainFrame() override;
|
| void DidBeginMainFrame() override;
|
| @@ -59,22 +104,21 @@ class BlimpCompositor : public cc::LayerTreeHostClient {
|
| scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events)
|
| override;
|
|
|
| - protected:
|
| - // |dp_to_px| is the scale factor required to move from dp (device pixels) to
|
| - // px.
|
| - explicit BlimpCompositor(float dp_to_px);
|
| + // RemoteProtoChannel implementation.
|
| + void SetProtoReceiver(ProtoReceiver* receiver) override;
|
| + void SendCompositorProto(const cc::proto::CompositorMessage& proto) override;
|
|
|
| - // Returns a widget for use in constructing this compositor's OutputSurface.
|
| - // Will only ever be called while this compositor is visible.
|
| - virtual gfx::AcceleratedWidget GetWindow() = 0;
|
| + // RenderWidgetMessageDelegate implementation.
|
| + void OnRenderWidgetInitialized() override;
|
| + void OnCompositorMessageReceived(
|
| + scoped_ptr<cc::proto::CompositorMessage> message) override;
|
|
|
| - // Populates the cc::LayerTreeSettings used by the cc::LayerTreeHost. Can be
|
| - // overridden to provide custom settings parameters.
|
| - virtual void GenerateLayerTreeSettings(cc::LayerTreeSettings* settings);
|
| + // Helper method to build the internal CC compositor instance from |message|.
|
| + void CreateLayerTreeHost(scoped_ptr<cc::proto::CompositorMessage> message);
|
|
|
| - private:
|
| // Creates (if necessary) and returns a TaskRunner for a thread meant to run
|
| // compositor rendering.
|
| + void HandlePendingOutputSurfaceRequest();
|
| scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner();
|
|
|
| gfx::Size viewport_size_;
|
| @@ -88,6 +132,28 @@ class BlimpCompositor : public cc::LayerTreeHostClient {
|
| // Lazily created thread that will run the compositor rendering tasks.
|
| scoped_ptr<base::Thread> compositor_thread_;
|
|
|
| + gfx::AcceleratedWidget window_;
|
| +
|
| + // Whether or not |host_| should be visible. This is stored in case |host_|
|
| + // is null when SetVisible() is called or if we don't have a
|
| + // gfx::AcceleratedWidget to build an output surface from.
|
| + bool host_should_be_visible_;
|
| +
|
| + // Whether there is an OutputSurface request pending from the current
|
| + // |host_|. Becomes |true| if RequestNewOutputSurface is called, and |false|
|
| + // if |host_| is deleted or we succeed in creating *and* initializing an
|
| + // OutputSurface (which is essentially the contract with cc).
|
| + bool output_surface_request_pending_;
|
| +
|
| + // To be notified of any incoming compositor protos that are specifically sent
|
| + // to |render_widget_id_|.
|
| + cc::RemoteProtoChannel::ProtoReceiver* remote_proto_channel_receiver_;
|
| +
|
| + // The bridge to the network layer that does the proto/RenderWidget id work.
|
| + // TODO(dtrainor): Move this to a higher level once we start dealing with
|
| + // multiple tabs.
|
| + RenderWidgetMessageProcessor render_widget_processor_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(BlimpCompositor);
|
| };
|
|
|
|
|