| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 public: | 155 public: |
| 156 ImageTransportClientTexture( | 156 ImageTransportClientTexture( |
| 157 WebKit::WebGraphicsContext3D* host_context, | 157 WebKit::WebGraphicsContext3D* host_context, |
| 158 float device_scale_factor) | 158 float device_scale_factor) |
| 159 : OwnedTexture(host_context, | 159 : OwnedTexture(host_context, |
| 160 gfx::Size(0, 0), | 160 gfx::Size(0, 0), |
| 161 device_scale_factor, | 161 device_scale_factor, |
| 162 host_context->createTexture()) { | 162 host_context->createTexture()) { |
| 163 } | 163 } |
| 164 | 164 |
| 165 virtual void Consume(const gpu::Mailbox& mailbox_name, | 165 virtual void Consume(const std::string& mailbox_name, |
| 166 const gfx::Size& new_size) OVERRIDE { | 166 const gfx::Size& new_size) OVERRIDE { |
| 167 DCHECK(mailbox_name.size() == GL_MAILBOX_SIZE_CHROMIUM); |
| 168 mailbox_name_ = mailbox_name; |
| 169 if (mailbox_name.empty()) |
| 170 return; |
| 171 |
| 167 DCHECK(host_context_ && texture_id_); | 172 DCHECK(host_context_ && texture_id_); |
| 168 mailbox_name_ = mailbox_name; | |
| 169 host_context_->bindTexture(GL_TEXTURE_2D, texture_id_); | 173 host_context_->bindTexture(GL_TEXTURE_2D, texture_id_); |
| 170 host_context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name.name); | 174 host_context_->consumeTextureCHROMIUM( |
| 175 GL_TEXTURE_2D, |
| 176 reinterpret_cast<const signed char*>(mailbox_name.c_str())); |
| 171 size_ = new_size; | 177 size_ = new_size; |
| 172 host_context_->shallowFlushCHROMIUM(); | 178 host_context_->shallowFlushCHROMIUM(); |
| 173 } | 179 } |
| 174 | 180 |
| 175 virtual gpu::Mailbox Produce() OVERRIDE { | 181 virtual std::string Produce() OVERRIDE { |
| 176 DCHECK(!mailbox_name_.IsZero()); | 182 std::string name; |
| 177 DCHECK(host_context_ && texture_id_); | 183 if (!mailbox_name_.empty()) { |
| 178 host_context_->bindTexture(GL_TEXTURE_2D, texture_id_); | 184 DCHECK(host_context_ && texture_id_); |
| 179 host_context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name_.name); | 185 host_context_->bindTexture(GL_TEXTURE_2D, texture_id_); |
| 180 gpu::Mailbox name; | 186 host_context_->produceTextureCHROMIUM( |
| 181 std::swap(mailbox_name_, name); | 187 GL_TEXTURE_2D, |
| 188 reinterpret_cast<const signed char*>(mailbox_name_.c_str())); |
| 189 mailbox_name_.swap(name); |
| 190 } |
| 182 return name; | 191 return name; |
| 183 } | 192 } |
| 184 | 193 |
| 185 protected: | 194 protected: |
| 186 virtual ~ImageTransportClientTexture() {} | 195 virtual ~ImageTransportClientTexture() {} |
| 187 | 196 |
| 188 private: | 197 private: |
| 189 gpu::Mailbox mailbox_name_; | 198 std::string mailbox_name_; |
| 190 DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); | 199 DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); |
| 191 }; | 200 }; |
| 192 | 201 |
| 193 class GpuProcessTransportFactory; | 202 class GpuProcessTransportFactory; |
| 194 | 203 |
| 195 class CompositorSwapClient | 204 class CompositorSwapClient |
| 196 : public base::SupportsWeakPtr<CompositorSwapClient>, | 205 : public base::SupportsWeakPtr<CompositorSwapClient>, |
| 197 public WebGraphicsContext3DSwapBuffersClient { | 206 public WebGraphicsContext3DSwapBuffersClient { |
| 198 public: | 207 public: |
| 199 CompositorSwapClient(ui::Compositor* compositor, | 208 CompositorSwapClient(ui::Compositor* compositor, |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 delete g_factory; | 690 delete g_factory; |
| 682 g_factory = NULL; | 691 g_factory = NULL; |
| 683 } | 692 } |
| 684 | 693 |
| 685 // static | 694 // static |
| 686 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 695 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
| 687 return g_factory; | 696 return g_factory; |
| 688 } | 697 } |
| 689 | 698 |
| 690 } // namespace content | 699 } // namespace content |
| OLD | NEW |