Get foreground tab on Android
[chromium-blink-merge.git] / content / renderer / browser_plugin / browser_plugin_compositing_helper.h
blob4e836c6f180d583f6474af3394807a8c58561ce5
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_
8 #include <string>
9 #include <vector>
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"
18 namespace base {
19 class SharedMemory;
22 namespace cc {
23 class CompositorFrame;
24 class Layer;
25 class SolidColorLayer;
26 class TextureLayer;
27 class DelegatedFrameProvider;
28 class DelegatedFrameResourceCollection;
29 class DelegatedRendererLayer;
32 namespace blink {
33 class WebPluginContainer;
34 class WebLayer;
37 namespace content {
39 class BrowserPluginManager;
41 class CONTENT_EXPORT BrowserPluginCompositingHelper :
42 public base::RefCounted<BrowserPluginCompositingHelper>,
43 public cc::DelegatedFrameResourceCollectionClient {
44 public:
45 BrowserPluginCompositingHelper(blink::WebPluginContainer* container,
46 BrowserPluginManager* manager,
47 int instance_id,
48 int host_routing_id);
49 void DidCommitCompositorFrame();
50 void EnableCompositing(bool);
51 void OnContainerDestroy();
52 void OnBuffersSwapped(const gfx::Size& size,
53 const std::string& mailbox_name,
54 int gpu_route_id,
55 int gpu_host_id,
56 float device_scale_factor);
57 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame,
58 int route_id,
59 uint32 output_surface_id,
60 int host_id);
61 void UpdateVisibility(bool);
63 // cc::DelegatedFrameProviderClient implementation.
64 virtual void UnusedResourcesAreAvailable() OVERRIDE;
66 protected:
67 // Friend RefCounted so that the dtor can be non-public.
68 friend class base::RefCounted<BrowserPluginCompositingHelper>;
69 private:
70 enum SwapBuffersType {
71 TEXTURE_IMAGE_TRANSPORT,
72 GL_COMPOSITOR_FRAME,
73 SOFTWARE_COMPOSITOR_FRAME,
75 struct SwapBuffersInfo {
76 SwapBuffersInfo();
78 gpu::Mailbox name;
79 SwapBuffersType type;
80 gfx::Size size;
81 int route_id;
82 uint32 output_surface_id;
83 int host_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,
90 cc::Layer* layer);
91 void OnBuffersSwappedPrivate(const SwapBuffersInfo& mailbox,
92 unsigned sync_point,
93 float device_scale_factor);
94 void MailboxReleased(SwapBuffersInfo mailbox,
95 unsigned sync_point,
96 bool lost_resource);
97 void SendReturnedDelegatedResources();
99 int instance_id_;
100 int host_routing_id_;
101 int last_route_id_;
102 uint32 last_output_surface_id_;
103 int last_host_id_;
104 bool last_mailbox_valid_;
105 bool ack_pending_;
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_