Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: wm/gpu/foreign_window_texture_factory.h

Issue 11485006: Add window manager component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Push gfx::AcceleratedWidget usage into platform specific code. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « wm/gpu/DEPS ('k') | wm/gpu/foreign_window_texture_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef WM_GPU_FOREIGN_WINDOW_TEXTURE_FACTORY_H_
6 #define WM_GPU_FOREIGN_WINDOW_TEXTURE_FACTORY_H_
7
8 #include "base/bind.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/browser/renderer_host/image_transport_factory.h"
11 #include "ui/compositor/compositor.h"
12 #include "ui/gfx/native_widget_types.h"
13
14 namespace content {
15 class GpuChannelHostFactory;
16 };
17
18 namespace wm {
19
20 // This class provides a way to get notified when textures get lost.
21 class ForeignWindowTextureFactoryObserver {
22 public:
23 virtual ~ForeignWindowTextureFactoryObserver() {}
24
25 // Notifies that the textures generated by ForeignWindowTextureFactory were
26 // lost.
27 virtual void OnLostResources() = 0;
28 };
29
30 // This class provides the interface for notifying the texture implementation
31 // that contents has changed.
32 class ForeignWindowTexture :
33 public ui::Texture,
34 public ForeignWindowTextureFactoryObserver {
35 public:
36 // ui::Texture overrides:
37 virtual unsigned int PrepareTexture() OVERRIDE;
38 virtual WebKit::WebGraphicsContext3D* HostContext3D() OVERRIDE;
39
40 // ForeignWindowTextureFactoryObserver overrides:
41 virtual void OnLostResources() OVERRIDE;
42
43 // Indicate that foreign window contents have changed.
44 void OnContentsChanged();
45
46 protected:
47 virtual ~ForeignWindowTexture();
48
49 private:
50 friend class ForeignWindowTextureFactory;
51
52 ForeignWindowTexture(content::GpuChannelHostFactory* factory,
53 WebKit::WebGraphicsContext3D* host_context,
54 bool flipped,
55 const gfx::Size& size,
56 float device_scale_factor,
57 int32 image_id);
58
59 content::GpuChannelHostFactory* factory_;
60 WebKit::WebGraphicsContext3D* host_context_;
61 int32 image_id_;
62 unsigned texture_id_;
63 bool contents_changed_;
64 };
65
66 // This class provides the interface for creating textures bound to foreign
67 // windows. The factory is a process-wide singleton.
68 class ForeignWindowTextureFactory
69 : public content::ImageTransportFactoryObserver {
70 public:
71 typedef base::Callback<void(scoped_refptr<ForeignWindowTexture>)>
72 CreateTextureCallback;
73
74 // Initialize the global texture factory.
75 static void Initialize();
76
77 // Terminates the global texture factory.
78 static void Terminate();
79
80 // Gets the factory instance.
81 static ForeignWindowTextureFactory* GetInstance();
82
83 // ImageTransportFactoryObserver overrides:
84 virtual void OnLostResources() OVERRIDE;
85
86 // Create a texture from a foreign window handle.
87 void CreateTextureForForeignWindow(
88 gfx::PluginWindowHandle window_handle,
89 bool flipped,
90 float device_scale_factor,
91 const CreateTextureCallback& callback);
92
93 void AddObserver(ForeignWindowTextureFactoryObserver* observer);
94 void RemoveObserver(ForeignWindowTextureFactoryObserver* observer);
95
96 private:
97 explicit ForeignWindowTextureFactory(
98 content::GpuChannelHostFactory* factory);
99 virtual ~ForeignWindowTextureFactory();
100
101 int GenerateImageID();
102
103 void OnImageCreated(const CreateTextureCallback& callback,
104 bool flipped,
105 float device_scale_factor,
106 int32 image_id,
107 const gfx::Size size);
108
109 static ForeignWindowTextureFactory* instance_;
110
111 content::GpuChannelHostFactory* factory_;
112
113 ObserverList<ForeignWindowTextureFactoryObserver> observer_list_;
114
115 DISALLOW_COPY_AND_ASSIGN(ForeignWindowTextureFactory);
116 };
117
118 } // namespace wm
119
120 #endif // WM_GPU_FOREIGN_WINDOW_TEXTURE_FACTORY_H_
OLDNEW
« no previous file with comments | « wm/gpu/DEPS ('k') | wm/gpu/foreign_window_texture_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698