Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / browser / compositor / delegated_frame_host.h
index bcbc758..ac9d90f 100644 (file)
@@ -8,6 +8,7 @@
 #include "cc/layers/delegated_frame_provider.h"
 #include "cc/layers/delegated_frame_resource_collection.h"
 #include "cc/output/copy_output_result.h"
+#include "cc/surfaces/surface_factory_client.h"
 #include "content/browser/compositor/image_transport_factory.h"
 #include "content/browser/compositor/owned_mailbox.h"
 #include "content/browser/renderer_host/delegated_frame_evictor.h"
 #include "ui/compositor/layer_owner_delegate.h"
 #include "ui/gfx/rect_conversions.h"
 
+namespace cc {
+class SurfaceFactory;
+}
+
 namespace media {
 class VideoFrame;
 }
@@ -72,6 +77,7 @@ class CONTENT_EXPORT DelegatedFrameHost
       public ImageTransportFactoryObserver,
       public DelegatedFrameEvictorClient,
       public cc::DelegatedFrameResourceCollectionClient,
+      public cc::SurfaceFactoryClient,
       public base::SupportsWeakPtr<DelegatedFrameHost> {
  public:
   DelegatedFrameHost(DelegatedFrameHostClient* client);
@@ -86,16 +92,17 @@ class CONTENT_EXPORT DelegatedFrameHost
       float frame_device_scale_factor,
       const std::vector<ui::LatencyInfo>& latency_info);
   void WasHidden();
-  void WasShown();
+  void WasShown(const ui::LatencyInfo& latency_info);
   void WasResized();
+  bool HasSavedFrame();
   gfx::Size GetRequestedRendererSize() const;
   void AddedToWindow();
   void RemovingFromWindow();
   void CopyFromCompositingSurface(
       const gfx::Rect& src_subrect,
-      const gfx::Size& dst_size,
+      const gfx::Size& output_size,
       const base::Callback<void(bool, const SkBitmap&)>& callback,
-      const SkBitmap::Config config);
+      const SkColorType color_type);
   void CopyFromCompositingSurfaceToVideoFrame(
       const gfx::Rect& src_subrect,
       const scoped_refptr<media::VideoFrame>& target,
@@ -105,6 +112,7 @@ class CONTENT_EXPORT DelegatedFrameHost
   void BeginFrameSubscription(
       scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber);
   void EndFrameSubscription();
+  bool HasFrameSubscriber() const { return frame_subscriber_; }
 
   // Exposed for tests.
   cc::DelegatedFrameProvider* FrameProviderForTesting() const {
@@ -114,6 +122,9 @@ class CONTENT_EXPORT DelegatedFrameHost
     OnCompositingDidCommit(compositor);
   }
   bool ShouldCreateResizeLockForTesting() { return ShouldCreateResizeLock(); }
+  bool ReleasedFrontLockActiveForTesting() const {
+    return !!released_front_lock_;
+  }
 
  private:
   friend class DelegatedFrameHostClient;
@@ -172,17 +183,17 @@ class CONTENT_EXPORT DelegatedFrameHost
   // of the copy.
   static void CopyFromCompositingSurfaceHasResult(
       const gfx::Size& dst_size_in_pixel,
-      const SkBitmap::Config config,
+      const SkColorType color_type,
       const base::Callback<void(bool, const SkBitmap&)>& callback,
       scoped_ptr<cc::CopyOutputResult> result);
   static void PrepareTextureCopyOutputResult(
       const gfx::Size& dst_size_in_pixel,
-      const SkBitmap::Config config,
+      const SkColorType color_type,
       const base::Callback<void(bool, const SkBitmap&)>& callback,
       scoped_ptr<cc::CopyOutputResult> result);
   static void PrepareBitmapCopyOutputResult(
       const gfx::Size& dst_size_in_pixel,
-      const SkBitmap::Config config,
+      const SkColorType color_type,
       const base::Callback<void(bool, const SkBitmap&)>& callback,
       scoped_ptr<cc::CopyOutputResult> result);
   static void CopyFromCompositingSurfaceHasResultForVideo(
@@ -211,15 +222,28 @@ class CONTENT_EXPORT DelegatedFrameHost
   // cc::DelegatedFrameProviderClient implementation.
   virtual void UnusedResourcesAreAvailable() OVERRIDE;
 
-  void DidReceiveFrameFromRenderer();
+  // cc::SurfaceFactoryClient implementation.
+  virtual void ReturnResources(
+      const cc::ReturnedResourceArray& resources) OVERRIDE;
+
+  void DidReceiveFrameFromRenderer(const gfx::Rect& damage_rect);
 
   DelegatedFrameHostClient* client_;
 
+  // True if this renders into a Surface, false if it renders into a delegated
+  // layer.
+  bool use_surfaces_;
+
   std::vector<base::Closure> on_compositing_did_commit_callbacks_;
 
   // The vsync manager we are observing for changes, if any.
   scoped_refptr<ui::CompositorVSyncManager> vsync_manager_;
 
+  // The current VSync timebase and interval. These are zero until the first
+  // call to OnUpdateVSyncParameters().
+  base::TimeTicks vsync_timebase_;
+  base::TimeDelta vsync_interval_;
+
   // With delegated renderer, this is the last output surface, used to
   // disambiguate resources with the same id coming from different output
   // surfaces.
@@ -242,6 +266,13 @@ class CONTENT_EXPORT DelegatedFrameHost
   // Provides delegated frame updates to the cc::DelegatedRendererLayer.
   scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
 
+  // State for rendering into a Surface.
+  scoped_ptr<cc::SurfaceIdAllocator> id_allocator_;
+  scoped_ptr<cc::SurfaceFactory> surface_factory_;
+  cc::SurfaceId surface_id_;
+  gfx::Size current_surface_size_;
+  cc::ReturnedResourceArray surface_returned_resources_;
+
   // This lock is the one waiting for a frame of the right size to come back
   // from the renderer/GPU process. It is set from the moment the aura window
   // got resized, to the moment we committed the renderer frame of the same