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 62b3ce5b90bcddf8dff8754c95710f0af39dfd8a..4043c27a5ebde34b049316798b53869927fc33d5 100644 |
--- a/content/browser/renderer_host/image_transport_factory.cc |
+++ b/content/browser/renderer_host/image_transport_factory.cc |
@@ -10,6 +10,7 @@ |
#include "base/bind.h" |
#include "base/command_line.h" |
#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
#include "base/observer_list.h" |
#include "base/threading/non_thread_safe.h" |
#include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
@@ -32,6 +33,8 @@ |
#include "ui/compositor/test_web_graphics_context_3d.h" |
#include "ui/gfx/native_widget_types.h" |
#include "ui/gfx/size.h" |
+#include "third_party/khronos/GLES2/gl2.h" |
apatrick_chromium
2012/11/09 19:19:04
For historical reasons, we've been using Mesa's GL
no sievers
2012/11/09 21:53:02
Youmean third_party/angle/include?
So that means
|
+#include "third_party/khronos/GLES2/gl2ext.h" |
#if defined(OS_WIN) |
#include "ui/surface/accelerated_surface_win.h" |
@@ -65,7 +68,7 @@ class DefaultTransportFactory |
virtual scoped_refptr<ui::Texture> CreateTransportClient( |
const gfx::Size& size, |
float device_scale_factor, |
- uint64 transport_handle) OVERRIDE { |
+ const std::vector<signed char>& mailbox_name) OVERRIDE { |
return NULL; |
} |
@@ -97,40 +100,6 @@ class DefaultTransportFactory |
DISALLOW_COPY_AND_ASSIGN(DefaultTransportFactory); |
}; |
-class ImageTransportClientTexture : public ui::Texture { |
- public: |
- ImageTransportClientTexture( |
- WebKit::WebGraphicsContext3D* host_context, |
- const gfx::Size& size, |
- float device_scale_factor, |
- uint64 surface_id) |
- : ui::Texture(true, size, device_scale_factor), |
- host_context_(host_context), |
- texture_id_(surface_id) { |
- } |
- |
- // ui::Texture overrides: |
- virtual unsigned int PrepareTexture() OVERRIDE { |
- return texture_id_; |
- } |
- |
- virtual WebKit::WebGraphicsContext3D* HostContext3D() OVERRIDE { |
- return host_context_; |
- } |
- |
- protected: |
- virtual ~ImageTransportClientTexture() {} |
- |
- private: |
- // A raw pointer. This |ImageTransportClientTexture| will be destroyed |
- // before the |host_context_| via |
- // |ImageTransportFactoryObserver::OnLostContext()| handlers. |
- WebKit::WebGraphicsContext3D* host_context_; |
- unsigned texture_id_; |
- |
- DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); |
-}; |
- |
class OwnedTexture : public ui::Texture, ImageTransportFactoryObserver { |
public: |
OwnedTexture(WebKit::WebGraphicsContext3D* host_context, |
@@ -163,7 +132,7 @@ class OwnedTexture : public ui::Texture, ImageTransportFactoryObserver { |
DeleteTexture(); |
} |
- private: |
+ protected: |
void DeleteTexture() { |
if (texture_id_) { |
host_context_->deleteTexture(texture_id_); |
@@ -180,6 +149,48 @@ class OwnedTexture : public ui::Texture, ImageTransportFactoryObserver { |
DISALLOW_COPY_AND_ASSIGN(OwnedTexture); |
}; |
+class ImageTransportClientTexture : public OwnedTexture { |
+ public: |
+ ImageTransportClientTexture( |
+ WebKit::WebGraphicsContext3D* host_context, |
+ const gfx::Size& size, |
+ float device_scale_factor, |
+ const std::vector<signed char>& mailbox_name) |
+ : OwnedTexture(host_context, |
+ size, |
+ device_scale_factor, |
+ host_context->createTexture()), |
+ mailbox_name_(mailbox_name) { |
+ DCHECK(mailbox_name.size() == GL_MAILBOX_SIZE_CHROMIUM); |
+ } |
+ |
+ virtual void Consume(const gfx::Size& new_size) OVERRIDE { |
+ if (host_context_) { |
piman
2012/11/09 22:02:01
I would make that a DCHECK. Bad things would happe
no sievers
2012/11/19 20:30:44
Done.
|
+ DCHECK(texture_id_); |
+ host_context_->bindTexture(GL_TEXTURE_2D, texture_id_); |
+ host_context_->consumeTextureCHROMIUM( |
+ GL_TEXTURE_2D, mailbox_name_.data()); |
piman
2012/11/09 22:02:01
As you mentioned on chat, you need a flush() here.
no sievers
2012/11/19 20:30:44
Done.
|
+ size_ = new_size; |
+ } |
+ } |
+ |
+ virtual void Produce() OVERRIDE { |
+ if (host_context_) { |
+ DCHECK(texture_id_); |
+ host_context_->bindTexture(GL_TEXTURE_2D, texture_id_); |
+ host_context_->produceTextureCHROMIUM( |
+ GL_TEXTURE_2D, mailbox_name_.data()); |
jonathan.backer
2012/11/12 16:52:15
No flush() because of sync point?
no sievers
2012/11/19 20:30:44
Yes. I *think* implying this makes sense in this c
piman
2012/11/19 22:31:54
My thoughts as well. Inserting the sync point will
|
+ } |
+ } |
+ |
+ protected: |
+ virtual ~ImageTransportClientTexture() {} |
+ |
+ private: |
+ std::vector<signed char> mailbox_name_; |
+ DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); |
+}; |
+ |
class GpuProcessTransportFactory; |
class CompositorSwapClient |
@@ -408,41 +419,24 @@ class GpuProcessTransportFactory : |
gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( |
gfx::kNullPluginWindow, true); |
handle.parent_gpu_process_id = shared_context_->GetGPUProcessID(); |
- handle.parent_client_id = shared_context_->GetChannelID(); |
- handle.parent_context_id = shared_context_->GetContextID(); |
- handle.parent_texture_id[0] = shared_context_->createTexture(); |
- handle.parent_texture_id[1] = shared_context_->createTexture(); |
- handle.sync_point = shared_context_->insertSyncPoint(); |
return handle; |
} |
virtual void DestroySharedSurfaceHandle( |
gfx::GLSurfaceHandle surface) OVERRIDE { |
- if (!shared_context_.get()) |
- return; |
- uint32 channel_id = shared_context_->GetChannelID(); |
- uint32 context_id = shared_context_->GetContextID(); |
- if (surface.parent_gpu_process_id != shared_context_->GetGPUProcessID() || |
- surface.parent_client_id != channel_id || |
- surface.parent_context_id != context_id) |
- return; |
- |
- shared_context_->deleteTexture(surface.parent_texture_id[0]); |
- shared_context_->deleteTexture(surface.parent_texture_id[1]); |
- shared_context_->flush(); |
} |
virtual scoped_refptr<ui::Texture> CreateTransportClient( |
const gfx::Size& size, |
float device_scale_factor, |
- uint64 transport_handle) { |
+ const std::vector<signed char>& mailbox_name) { |
if (!shared_context_.get()) |
return NULL; |
scoped_refptr<ImageTransportClientTexture> image( |
new ImageTransportClientTexture(shared_context_.get(), |
size, device_scale_factor, |
- transport_handle)); |
+ mailbox_name)); |
return image; |
} |