1 // Copyright (c) 2013 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.
5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_COMPOSITING_HELPER_H_
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_COMPOSITING_HELPER_H_
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "cc/layers/delegated_frame_resource_collection.h"
14 #include "content/common/content_export.h"
15 #include "gpu/command_buffer/common/mailbox.h"
16 #include "ui/gfx/size.h"
23 class CompositorFrame
;
25 class SolidColorLayer
;
27 class DelegatedFrameProvider
;
28 class DelegatedFrameResourceCollection
;
29 class DelegatedRendererLayer
;
33 class WebPluginContainer
;
39 class BrowserPluginManager
;
41 class CONTENT_EXPORT BrowserPluginCompositingHelper
:
42 public base::RefCounted
<BrowserPluginCompositingHelper
>,
43 public cc::DelegatedFrameResourceCollectionClient
{
45 BrowserPluginCompositingHelper(blink::WebPluginContainer
* container
,
46 BrowserPluginManager
* manager
,
49 void DidCommitCompositorFrame();
50 void EnableCompositing(bool);
51 void OnContainerDestroy();
52 void OnBuffersSwapped(const gfx::Size
& size
,
53 const std::string
& mailbox_name
,
56 float device_scale_factor
);
57 void OnCompositorFrameSwapped(scoped_ptr
<cc::CompositorFrame
> frame
,
59 uint32 output_surface_id
,
61 void UpdateVisibility(bool);
63 // cc::DelegatedFrameProviderClient implementation.
64 virtual void UnusedResourcesAreAvailable() OVERRIDE
;
67 // Friend RefCounted so that the dtor can be non-public.
68 friend class base::RefCounted
<BrowserPluginCompositingHelper
>;
70 enum SwapBuffersType
{
71 TEXTURE_IMAGE_TRANSPORT
,
73 SOFTWARE_COMPOSITOR_FRAME
,
75 struct SwapBuffersInfo
{
82 uint32 output_surface_id
;
84 unsigned software_frame_id
;
85 base::SharedMemory
* shared_memory
;
87 virtual ~BrowserPluginCompositingHelper();
88 void CheckSizeAndAdjustLayerBounds(const gfx::Size
& new_size
,
89 float device_scale_factor
,
91 void OnBuffersSwappedPrivate(const SwapBuffersInfo
& mailbox
,
93 float device_scale_factor
);
94 void MailboxReleased(SwapBuffersInfo mailbox
,
97 void SendReturnedDelegatedResources();
100 int host_routing_id_
;
102 uint32 last_output_surface_id_
;
104 bool last_mailbox_valid_
;
106 bool software_ack_pending_
;
107 std::vector
<unsigned> unacked_software_frames_
;
109 gfx::Size buffer_size_
;
111 scoped_refptr
<cc::DelegatedFrameResourceCollection
> resource_collection_
;
112 scoped_refptr
<cc::DelegatedFrameProvider
> frame_provider_
;
114 scoped_refptr
<cc::SolidColorLayer
> background_layer_
;
115 scoped_refptr
<cc::TextureLayer
> texture_layer_
;
116 scoped_refptr
<cc::DelegatedRendererLayer
> delegated_layer_
;
117 scoped_ptr
<blink::WebLayer
> web_layer_
;
118 blink::WebPluginContainer
* container_
;
120 scoped_refptr
<BrowserPluginManager
> browser_plugin_manager_
;
123 } // namespace content
125 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_COMPOSITING_HELPER_H_