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 "content/common/content_export.h"
14 #include "gpu/command_buffer/common/mailbox.h"
15 #include "ui/gfx/size.h"
22 class CompositorFrame;
24 class SolidColorLayer;
26 class DelegatedFrameProvider;
27 class DelegatedFrameResourceCollection;
28 class DelegatedRendererLayer;
32 class WebPluginContainer;
38 class BrowserPluginManager;
40 class CONTENT_EXPORT BrowserPluginCompositingHelper :
41 public base::RefCounted<BrowserPluginCompositingHelper> {
43 BrowserPluginCompositingHelper(WebKit::WebPluginContainer* container,
44 BrowserPluginManager* manager,
47 void DidCommitCompositorFrame();
48 void EnableCompositing(bool);
49 void OnContainerDestroy();
50 void OnBuffersSwapped(const gfx::Size& size,
51 const std::string& mailbox_name,
54 float device_scale_factor);
55 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame,
57 uint32 output_surface_id,
59 void UpdateVisibility(bool);
61 // Friend RefCounted so that the dtor can be non-public.
62 friend class base::RefCounted<BrowserPluginCompositingHelper>;
64 enum SwapBuffersType {
65 TEXTURE_IMAGE_TRANSPORT,
67 SOFTWARE_COMPOSITOR_FRAME,
69 struct SwapBuffersInfo {
76 uint32 output_surface_id;
78 unsigned software_frame_id;
79 base::SharedMemory* shared_memory;
81 ~BrowserPluginCompositingHelper();
82 void CheckSizeAndAdjustLayerBounds(const gfx::Size& new_size,
83 float device_scale_factor,
85 void OnBuffersSwappedPrivate(const SwapBuffersInfo& mailbox,
87 float device_scale_factor);
88 void MailboxReleased(SwapBuffersInfo mailbox,
94 uint32 last_output_surface_id_;
96 bool last_mailbox_valid_;
98 bool software_ack_pending_;
99 std::vector<unsigned> unacked_software_frames_;
101 gfx::Size buffer_size_;
103 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
104 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
106 scoped_refptr<cc::SolidColorLayer> background_layer_;
107 scoped_refptr<cc::TextureLayer> texture_layer_;
108 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_;
109 scoped_ptr<WebKit::WebLayer> web_layer_;
110 WebKit::WebPluginContainer* container_;
112 scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
115 } // namespace content
117 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_COMPOSITING_HELPER_H_