Index: content/browser/renderer_host/image_transport_factory.cc |
diff --git a/content/browser/renderer_host/image_transport_factory.cc b/content/browser/renderer_host/image_transport_factory.cc |
index d51113dda34bfd241aa30032f05fe67d747fc5ad..7c6456d5cbe7cfbe377bad931c58e292f7f31193 100644 |
--- a/content/browser/renderer_host/image_transport_factory.cc |
+++ b/content/browser/renderer_host/image_transport_factory.cc |
@@ -13,7 +13,6 @@ |
#include "base/observer_list.h" |
#include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
#include "content/browser/gpu/gpu_surface_tracker.h" |
-#include "content/browser/renderer_host/image_transport_client.h" |
#include "content/common/gpu/client/gl_helper.h" |
#include "content/common/gpu/client/gpu_channel_host.h" |
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
@@ -55,9 +54,10 @@ class DefaultTransportFactory |
gfx::GLSurfaceHandle surface) OVERRIDE { |
} |
- virtual scoped_refptr<ImageTransportClient> CreateTransportClient( |
+ virtual scoped_refptr<ui::Texture> CreateTransportClient( |
const gfx::Size& size, |
- uint64* transport_handle) OVERRIDE { |
+ uint64* transport_handle, |
+ ui::Compositor* compositor) OVERRIDE { |
return NULL; |
} |
@@ -95,46 +95,41 @@ class TestTransportFactory : public DefaultTransportFactory { |
return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true); |
} |
- virtual scoped_refptr<ImageTransportClient> CreateTransportClient( |
+ virtual scoped_refptr<ui::Texture> CreateTransportClient( |
const gfx::Size& size, |
- uint64* transport_handle) OVERRIDE { |
-#if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
- scoped_refptr<ImageTransportClient> surface( |
- ImageTransportClient::Create(this, size)); |
- if (!surface || !surface->Initialize(transport_handle)) { |
- LOG(ERROR) << "Failed to create ImageTransportClient"; |
- return NULL; |
- } |
- return surface; |
-#else |
+ uint64* transport_handle, |
+ ui::Compositor* compositor) OVERRIDE { |
return NULL; |
-#endif |
} |
private: |
DISALLOW_COPY_AND_ASSIGN(TestTransportFactory); |
}; |
-class ImageTransportClientTexture : public ImageTransportClient { |
+class ImageTransportClientTexture : public ui::Texture { |
public: |
- explicit ImageTransportClientTexture(const gfx::Size& size) |
- : ImageTransportClient(true, size) { |
- } |
- |
- virtual bool Initialize(uint64* surface_id) OVERRIDE { |
- set_texture_id(*surface_id); |
- return true; |
+ explicit ImageTransportClientTexture( |
+ WebKit::WebGraphicsContext3D* host_context, |
+ const gfx::Size& size, |
+ uint64 surface_id) |
+ : ui::Texture(true, size), |
+ host_context_(host_context) { |
+ set_texture_id(surface_id); |
} |
- virtual void Update() OVERRIDE {} |
- virtual TransportDIB::Handle Handle() const OVERRIDE { |
- return TransportDIB::DefaultHandleValue(); |
+ virtual WebKit::WebGraphicsContext3D* hostContext3D() { |
+ return host_context_; |
} |
protected: |
virtual ~ImageTransportClientTexture() {} |
private: |
+ // A weak pointer. This |ImageTransportClientTexture| will be destroyed |
+ // before the |host_context_| via |
+ // |ImageTransportFactoryObserver::OnLostContext()| handlers. |
+ WebKit::WebGraphicsContext3D* host_context_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); |
}; |
@@ -247,12 +242,15 @@ class GpuProcessTransportFactory : public ui::ContextFactory, |
} |
} |
- virtual scoped_refptr<ImageTransportClient> CreateTransportClient( |
+ virtual scoped_refptr<ui::Texture> CreateTransportClient( |
const gfx::Size& size, |
- uint64* transport_handle) { |
+ uint64* transport_handle, |
+ ui::Compositor* compositor) { |
+ PerCompositorData* data = per_compositor_data_[compositor]; |
+ DCHECK(data); |
scoped_refptr<ImageTransportClientTexture> image( |
- new ImageTransportClientTexture(size)); |
- image->Initialize(transport_handle); |
+ new ImageTransportClientTexture(data->shared_context.get(), |
+ size, *transport_handle)); |
return image; |
} |