OLD | NEW |
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" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 ui::Compositor* compositor) OVERRIDE { | 50 ui::Compositor* compositor) OVERRIDE { |
51 return gfx::GLSurfaceHandle(); | 51 return gfx::GLSurfaceHandle(); |
52 } | 52 } |
53 | 53 |
54 virtual void DestroySharedSurfaceHandle( | 54 virtual void DestroySharedSurfaceHandle( |
55 gfx::GLSurfaceHandle surface) OVERRIDE { | 55 gfx::GLSurfaceHandle surface) OVERRIDE { |
56 } | 56 } |
57 | 57 |
58 virtual scoped_refptr<ui::Texture> CreateTransportClient( | 58 virtual scoped_refptr<ui::Texture> CreateTransportClient( |
59 const gfx::Size& size, | 59 const gfx::Size& size, |
60 uint64 transport_handle) OVERRIDE { | 60 uint64 transport_handle, |
| 61 ui::Compositor* compositor) OVERRIDE { |
61 return NULL; | 62 return NULL; |
62 } | 63 } |
63 | 64 |
64 virtual GLHelper* GetGLHelper(ui::Compositor* compositor) OVERRIDE { | 65 virtual GLHelper* GetGLHelper(ui::Compositor* compositor) OVERRIDE { |
65 return NULL; | 66 return NULL; |
66 } | 67 } |
67 | 68 |
68 virtual uint32 InsertSyncPoint(ui::Compositor* compositor) OVERRIDE { | 69 virtual uint32 InsertSyncPoint(ui::Compositor* compositor) OVERRIDE { |
69 return 0; | 70 return 0; |
70 } | 71 } |
71 | 72 |
72 // We don't generate lost context events, so we don't need to keep track of | 73 // We don't generate lost context events, so we don't need to keep track of |
73 // observers | 74 // observers |
74 virtual void AddObserver(ImageTransportFactoryObserver* observer) OVERRIDE { | 75 virtual void AddObserver(ImageTransportFactoryObserver* observer) OVERRIDE { |
75 } | 76 } |
76 | 77 |
77 virtual void RemoveObserver( | 78 virtual void RemoveObserver( |
78 ImageTransportFactoryObserver* observer) OVERRIDE { | 79 ImageTransportFactoryObserver* observer) OVERRIDE { |
79 } | 80 } |
80 | 81 |
81 private: | 82 private: |
82 DISALLOW_COPY_AND_ASSIGN(DefaultTransportFactory); | 83 DISALLOW_COPY_AND_ASSIGN(DefaultTransportFactory); |
83 }; | 84 }; |
84 | 85 |
85 class ImageTransportClientTexture : public ui::Texture { | 86 class ImageTransportClientTexture : public ui::Texture { |
86 public: | 87 public: |
87 ImageTransportClientTexture( | 88 ImageTransportClientTexture( |
| 89 WebKit::WebGraphicsContext3D* host_context, |
88 const gfx::Size& size, | 90 const gfx::Size& size, |
89 uint64 surface_id) | 91 uint64 surface_id) |
90 : ui::Texture(true, size) { | 92 : ui::Texture(true, size), |
| 93 host_context_(host_context) { |
91 set_texture_id(surface_id); | 94 set_texture_id(surface_id); |
92 } | 95 } |
93 | 96 |
| 97 virtual WebKit::WebGraphicsContext3D* HostContext3D() { |
| 98 return host_context_; |
| 99 } |
| 100 |
94 protected: | 101 protected: |
95 virtual ~ImageTransportClientTexture() {} | 102 virtual ~ImageTransportClientTexture() {} |
96 | 103 |
97 private: | 104 private: |
| 105 // A raw pointer. This |ImageTransportClientTexture| will be destroyed |
| 106 // before the |host_context_| via |
| 107 // |ImageTransportFactoryObserver::OnLostContext()| handlers. |
| 108 WebKit::WebGraphicsContext3D* host_context_; |
| 109 |
98 DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); | 110 DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); |
99 }; | 111 }; |
100 | 112 |
101 class GpuProcessTransportFactory; | 113 class GpuProcessTransportFactory; |
102 | 114 |
103 class CompositorSwapClient | 115 class CompositorSwapClient |
104 : public base::SupportsWeakPtr<CompositorSwapClient>, | 116 : public base::SupportsWeakPtr<CompositorSwapClient>, |
105 public WebGraphicsContext3DSwapBuffersClient { | 117 public WebGraphicsContext3DSwapBuffersClient { |
106 public: | 118 public: |
107 CompositorSwapClient(ui::Compositor* compositor, | 119 CompositorSwapClient(ui::Compositor* compositor, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 data->shared_context->deleteTexture(surface.parent_texture_id[0]); | 214 data->shared_context->deleteTexture(surface.parent_texture_id[0]); |
203 data->shared_context->deleteTexture(surface.parent_texture_id[1]); | 215 data->shared_context->deleteTexture(surface.parent_texture_id[1]); |
204 data->shared_context->flush(); | 216 data->shared_context->flush(); |
205 break; | 217 break; |
206 } | 218 } |
207 } | 219 } |
208 } | 220 } |
209 | 221 |
210 virtual scoped_refptr<ui::Texture> CreateTransportClient( | 222 virtual scoped_refptr<ui::Texture> CreateTransportClient( |
211 const gfx::Size& size, | 223 const gfx::Size& size, |
212 uint64 transport_handle) { | 224 uint64 transport_handle, |
| 225 ui::Compositor* compositor) { |
| 226 PerCompositorData* data = per_compositor_data_[compositor]; |
| 227 DCHECK(data); |
213 scoped_refptr<ImageTransportClientTexture> image( | 228 scoped_refptr<ImageTransportClientTexture> image( |
214 new ImageTransportClientTexture(size, transport_handle)); | 229 new ImageTransportClientTexture(data->shared_context.get(), |
| 230 size, transport_handle)); |
215 return image; | 231 return image; |
216 } | 232 } |
217 | 233 |
218 virtual GLHelper* GetGLHelper(ui::Compositor* compositor) { | 234 virtual GLHelper* GetGLHelper(ui::Compositor* compositor) { |
219 PerCompositorData* data = per_compositor_data_[compositor]; | 235 PerCompositorData* data = per_compositor_data_[compositor]; |
220 if (!data) | 236 if (!data) |
221 data = CreatePerCompositorData(compositor); | 237 data = CreatePerCompositorData(compositor); |
222 if (!data->gl_helper.get()) { | 238 if (!data->gl_helper.get()) { |
223 WebKit::WebGraphicsContext3D* context_for_thread = | 239 WebKit::WebGraphicsContext3D* context_for_thread = |
224 CreateContextCommon(compositor, true); | 240 CreateContextCommon(compositor, true); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 void ImageTransportFactory::Terminate() { | 409 void ImageTransportFactory::Terminate() { |
394 ui::ContextFactory::SetInstance(NULL); | 410 ui::ContextFactory::SetInstance(NULL); |
395 delete g_factory; | 411 delete g_factory; |
396 g_factory = NULL; | 412 g_factory = NULL; |
397 } | 413 } |
398 | 414 |
399 // static | 415 // static |
400 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 416 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
401 return g_factory; | 417 return g_factory; |
402 } | 418 } |
OLD | NEW |