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..34282d99a2ad2c01b5a1e71228932101e7535d99 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/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,52 @@ class LayerTreeHost; |
namespace blimp { |
+class BlimpMessage; |
+ |
// BlimpCompositor provides the basic framework and setup to host a |
nyquist
2015/11/24 08:55:43
Nit: Can this class be interacted with from any th
David Trainor- moved to gerrit
2015/11/25 17:56:41
Done.
|
// LayerTreeHost (compositor). The rendering surface this compositor draws to |
nyquist
2015/11/24 20:24:47
Nit: It's a little bit confusing having "(composit
David Trainor- moved to gerrit
2015/11/25 17:56:41
Done.
|
-// is defined by the gfx::AcceleratedWidget returned by |
-// BlimpCompositor::GetWindow(). |
-class BlimpCompositor : public cc::LayerTreeHostClient { |
+// is defined by the gfx::AcceleratedWidget set by SetAcceleratedWidget(). |
+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 it's resources |
nyquist
2015/11/24 08:55:43
Nit: I think we want to refer to things the pronou
David Trainor- moved to gerrit
2015/11/25 17:56:41
Done.
|
+ // 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 pulled from the engine all the time? |
nyquist
2015/11/24 08:55:43
Nit: "pulled" for me here has the special meaning
David Trainor- moved to gerrit
2015/11/25 17:56:41
Changed it to set.
|
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 should be called before calling |
nyquist
2015/11/24 08:55:43
Nit: Should or must? I believe you use 'must' abov
David Trainor- moved to gerrit
2015/11/25 17:56:41
Done.
|
+ // 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 |
nyquist
2015/11/24 08:55:43
Optional nit: For new readers, would we want to li
David Trainor- moved to gerrit
2015/11/25 17:56:41
Done.
|
+ // px. |
+ 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 +99,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 +127,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); |
}; |