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 std::string& mailbox_name, | 165 virtual void Consume(const gpu::Mailbox& 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; | 167 mailbox_name_ = mailbox_name; |
169 if (mailbox_name.empty()) | 168 if (mailbox_name.IsZero()) |
no sievers
2013/03/06 23:19:23
I guess you could remove that now, since it's alre
piman
2013/03/07 01:48:02
Done.
| |
170 return; | 169 return; |
171 | 170 |
172 DCHECK(host_context_ && texture_id_); | 171 DCHECK(host_context_ && texture_id_); |
173 host_context_->bindTexture(GL_TEXTURE_2D, texture_id_); | 172 host_context_->bindTexture(GL_TEXTURE_2D, texture_id_); |
174 host_context_->consumeTextureCHROMIUM( | 173 host_context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name.name); |
175 GL_TEXTURE_2D, | |
176 reinterpret_cast<const signed char*>(mailbox_name.c_str())); | |
177 size_ = new_size; | 174 size_ = new_size; |
178 host_context_->shallowFlushCHROMIUM(); | 175 host_context_->shallowFlushCHROMIUM(); |
179 } | 176 } |
180 | 177 |
181 virtual std::string Produce() OVERRIDE { | 178 virtual gpu::Mailbox Produce() OVERRIDE { |
182 std::string name; | 179 gpu::Mailbox name; |
183 if (!mailbox_name_.empty()) { | 180 if (!mailbox_name_.IsZero()) { |
no sievers
2013/03/06 23:19:23
...and I think this could be a DCHECK() now since
piman
2013/03/07 01:48:02
Done.
| |
184 DCHECK(host_context_ && texture_id_); | 181 DCHECK(host_context_ && texture_id_); |
185 host_context_->bindTexture(GL_TEXTURE_2D, texture_id_); | 182 host_context_->bindTexture(GL_TEXTURE_2D, texture_id_); |
186 host_context_->produceTextureCHROMIUM( | 183 host_context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name_.name); |
187 GL_TEXTURE_2D, | 184 std::swap(mailbox_name_, name); |
188 reinterpret_cast<const signed char*>(mailbox_name_.c_str())); | |
189 mailbox_name_.swap(name); | |
190 } | 185 } |
191 return name; | 186 return name; |
192 } | 187 } |
193 | 188 |
194 protected: | 189 protected: |
195 virtual ~ImageTransportClientTexture() {} | 190 virtual ~ImageTransportClientTexture() {} |
196 | 191 |
197 private: | 192 private: |
198 std::string mailbox_name_; | 193 gpu::Mailbox mailbox_name_; |
199 DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); | 194 DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); |
200 }; | 195 }; |
201 | 196 |
202 class GpuProcessTransportFactory; | 197 class GpuProcessTransportFactory; |
203 | 198 |
204 class CompositorSwapClient | 199 class CompositorSwapClient |
205 : public base::SupportsWeakPtr<CompositorSwapClient>, | 200 : public base::SupportsWeakPtr<CompositorSwapClient>, |
206 public WebGraphicsContext3DSwapBuffersClient { | 201 public WebGraphicsContext3DSwapBuffersClient { |
207 public: | 202 public: |
208 CompositorSwapClient(ui::Compositor* compositor, | 203 CompositorSwapClient(ui::Compositor* compositor, |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 delete g_factory; | 685 delete g_factory; |
691 g_factory = NULL; | 686 g_factory = NULL; |
692 } | 687 } |
693 | 688 |
694 // static | 689 // static |
695 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 690 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
696 return g_factory; | 691 return g_factory; |
697 } | 692 } |
698 | 693 |
699 } // namespace content | 694 } // namespace content |
OLD | NEW |