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

Side by Side Diff: content/browser/renderer_host/image_transport_factory.cc

Issue 10689108: Aura: Have ui::Layer implement WebKit::WebExternalTextureLayerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments, remove dead code, plumb through context. Created 8 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/image_transport_factory.h" 5 #include "content/browser/renderer_host/image_transport_factory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 14 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
15 #include "content/browser/gpu/gpu_surface_tracker.h" 15 #include "content/browser/gpu/gpu_surface_tracker.h"
16 #include "content/browser/renderer_host/image_transport_client.h"
17 #include "content/common/gpu/client/gl_helper.h" 16 #include "content/common/gpu/client/gl_helper.h"
18 #include "content/common/gpu/client/gpu_channel_host.h" 17 #include "content/common/gpu/client/gpu_channel_host.h"
19 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 18 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
20 #include "content/common/gpu/gpu_process_launch_causes.h" 19 #include "content/common/gpu/gpu_process_launch_causes.h"
21 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
22 #include "gpu/ipc/command_buffer_proxy.h" 21 #include "gpu/ipc/command_buffer_proxy.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h"
24 #include "ui/compositor/compositor.h" 23 #include "ui/compositor/compositor.h"
25 #include "ui/compositor/compositor_setup.h" 24 #include "ui/compositor/compositor_setup.h"
26 #include "ui/gfx/native_widget_types.h" 25 #include "ui/gfx/native_widget_types.h"
(...skipping 21 matching lines...) Expand all
48 47
49 virtual gfx::GLSurfaceHandle CreateSharedSurfaceHandle( 48 virtual gfx::GLSurfaceHandle CreateSharedSurfaceHandle(
50 ui::Compositor* compositor) OVERRIDE { 49 ui::Compositor* compositor) OVERRIDE {
51 return gfx::GLSurfaceHandle(); 50 return gfx::GLSurfaceHandle();
52 } 51 }
53 52
54 virtual void DestroySharedSurfaceHandle( 53 virtual void DestroySharedSurfaceHandle(
55 gfx::GLSurfaceHandle surface) OVERRIDE { 54 gfx::GLSurfaceHandle surface) OVERRIDE {
56 } 55 }
57 56
58 virtual scoped_refptr<ImageTransportClient> CreateTransportClient( 57 virtual scoped_refptr<ui::Texture> CreateTransportClient(
59 const gfx::Size& size, 58 const gfx::Size& size,
60 uint64* transport_handle) OVERRIDE { 59 uint64* transport_handle,
60 ui::Compositor* compositor) OVERRIDE {
61 return NULL; 61 return NULL;
62 } 62 }
63 63
64 virtual GLHelper* GetGLHelper(ui::Compositor* compositor) OVERRIDE { 64 virtual GLHelper* GetGLHelper(ui::Compositor* compositor) OVERRIDE {
65 return NULL; 65 return NULL;
66 } 66 }
67 67
68 virtual uint32 InsertSyncPoint(ui::Compositor* compositor) OVERRIDE { 68 virtual uint32 InsertSyncPoint(ui::Compositor* compositor) OVERRIDE {
69 return 0; 69 return 0;
70 } 70 }
(...skipping 17 matching lines...) Expand all
88 88
89 class TestTransportFactory : public DefaultTransportFactory { 89 class TestTransportFactory : public DefaultTransportFactory {
90 public: 90 public:
91 TestTransportFactory() {} 91 TestTransportFactory() {}
92 92
93 virtual gfx::GLSurfaceHandle CreateSharedSurfaceHandle( 93 virtual gfx::GLSurfaceHandle CreateSharedSurfaceHandle(
94 ui::Compositor* compositor) OVERRIDE { 94 ui::Compositor* compositor) OVERRIDE {
95 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true); 95 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true);
96 } 96 }
97 97
98 virtual scoped_refptr<ImageTransportClient> CreateTransportClient( 98 virtual scoped_refptr<ui::Texture> CreateTransportClient(
99 const gfx::Size& size, 99 const gfx::Size& size,
100 uint64* transport_handle) OVERRIDE { 100 uint64* transport_handle,
101 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) 101 ui::Compositor* compositor) OVERRIDE {
102 scoped_refptr<ImageTransportClient> surface(
103 ImageTransportClient::Create(this, size));
104 if (!surface || !surface->Initialize(transport_handle)) {
105 LOG(ERROR) << "Failed to create ImageTransportClient";
106 return NULL;
107 }
108 return surface;
109 #else
110 return NULL; 102 return NULL;
111 #endif
112 } 103 }
113 104
114 private: 105 private:
115 DISALLOW_COPY_AND_ASSIGN(TestTransportFactory); 106 DISALLOW_COPY_AND_ASSIGN(TestTransportFactory);
116 }; 107 };
117 108
118 class ImageTransportClientTexture : public ImageTransportClient { 109 class ImageTransportClientTexture : public ui::Texture {
119 public: 110 public:
120 explicit ImageTransportClientTexture(const gfx::Size& size) 111 explicit ImageTransportClientTexture(
121 : ImageTransportClient(true, size) { 112 WebKit::WebGraphicsContext3D* host_context,
113 const gfx::Size& size,
114 uint64 surface_id)
115 : ui::Texture(true, size),
116 host_context_(host_context) {
117 set_texture_id(surface_id);
122 } 118 }
123 119
124 virtual bool Initialize(uint64* surface_id) OVERRIDE { 120 virtual WebKit::WebGraphicsContext3D* hostContext3D() {
125 set_texture_id(*surface_id); 121 return host_context_;
126 return true;
127 }
128
129 virtual void Update() OVERRIDE {}
130 virtual TransportDIB::Handle Handle() const OVERRIDE {
131 return TransportDIB::DefaultHandleValue();
132 } 122 }
133 123
134 protected: 124 protected:
135 virtual ~ImageTransportClientTexture() {} 125 virtual ~ImageTransportClientTexture() {}
136 126
137 private: 127 private:
128 // A weak pointer. This |ImageTransportClientTexture| will be destroyed
129 // before the |host_context_| via
130 // |ImageTransportFactoryObserver::OnLostContext()| handlers.
131 WebKit::WebGraphicsContext3D* host_context_;
132
138 DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); 133 DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture);
139 }; 134 };
140 135
141 class GpuProcessTransportFactory; 136 class GpuProcessTransportFactory;
142 137
143 class CompositorSwapClient 138 class CompositorSwapClient
144 : public base::SupportsWeakPtr<CompositorSwapClient>, 139 : public base::SupportsWeakPtr<CompositorSwapClient>,
145 public WebGraphicsContext3DSwapBuffersClient { 140 public WebGraphicsContext3DSwapBuffersClient {
146 public: 141 public:
147 CompositorSwapClient(ui::Compositor* compositor, 142 CompositorSwapClient(ui::Compositor* compositor,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 surface.parent_client_id == client_id && 235 surface.parent_client_id == client_id &&
241 surface.parent_context_id == context_id) { 236 surface.parent_context_id == context_id) {
242 data->shared_context->deleteTexture(surface.parent_texture_id[0]); 237 data->shared_context->deleteTexture(surface.parent_texture_id[0]);
243 data->shared_context->deleteTexture(surface.parent_texture_id[1]); 238 data->shared_context->deleteTexture(surface.parent_texture_id[1]);
244 data->shared_context->flush(); 239 data->shared_context->flush();
245 break; 240 break;
246 } 241 }
247 } 242 }
248 } 243 }
249 244
250 virtual scoped_refptr<ImageTransportClient> CreateTransportClient( 245 virtual scoped_refptr<ui::Texture> CreateTransportClient(
251 const gfx::Size& size, 246 const gfx::Size& size,
252 uint64* transport_handle) { 247 uint64* transport_handle,
248 ui::Compositor* compositor) {
249 PerCompositorData* data = per_compositor_data_[compositor];
250 DCHECK(data);
253 scoped_refptr<ImageTransportClientTexture> image( 251 scoped_refptr<ImageTransportClientTexture> image(
254 new ImageTransportClientTexture(size)); 252 new ImageTransportClientTexture(data->shared_context.get(),
255 image->Initialize(transport_handle); 253 size, *transport_handle));
256 return image; 254 return image;
257 } 255 }
258 256
259 virtual GLHelper* GetGLHelper(ui::Compositor* compositor) { 257 virtual GLHelper* GetGLHelper(ui::Compositor* compositor) {
260 PerCompositorData* data = per_compositor_data_[compositor]; 258 PerCompositorData* data = per_compositor_data_[compositor];
261 if (!data) 259 if (!data)
262 data = CreatePerCompositorData(compositor); 260 data = CreatePerCompositorData(compositor);
263 if (!data->gl_helper.get()) { 261 if (!data->gl_helper.get()) {
264 WebKit::WebGraphicsContext3D* context_for_thread = 262 WebKit::WebGraphicsContext3D* context_for_thread =
265 CreateContextCommon(compositor, true); 263 CreateContextCommon(compositor, true);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 void ImageTransportFactory::Terminate() { 423 void ImageTransportFactory::Terminate() {
426 ui::ContextFactory::SetInstance(NULL); 424 ui::ContextFactory::SetInstance(NULL);
427 delete g_factory; 425 delete g_factory;
428 g_factory = NULL; 426 g_factory = NULL;
429 } 427 }
430 428
431 // static 429 // static
432 ImageTransportFactory* ImageTransportFactory::GetInstance() { 430 ImageTransportFactory* ImageTransportFactory::GetInstance() {
433 return g_factory; 431 return g_factory;
434 } 432 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698