| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/aura/gpu_process_transport_factory.h" | 5 #include "content/browser/aura/gpu_process_transport_factory.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 int surface_id; | 48 int surface_id; |
| 49 scoped_ptr<CompositorSwapClient> swap_client; | 49 scoped_ptr<CompositorSwapClient> swap_client; |
| 50 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 51 scoped_ptr<AcceleratedSurface> accelerated_surface; | 51 scoped_ptr<AcceleratedSurface> accelerated_surface; |
| 52 #endif | 52 #endif |
| 53 scoped_refptr<ReflectorImpl> reflector; | 53 scoped_refptr<ReflectorImpl> reflector; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 class OwnedTexture : public ui::Texture, ImageTransportFactoryObserver { | 56 class OwnedTexture : public ui::Texture, ImageTransportFactoryObserver { |
| 57 public: | 57 public: |
| 58 OwnedTexture(WebKit::WebGraphicsContext3D* host_context, | 58 OwnedTexture(blink::WebGraphicsContext3D* host_context, |
| 59 const gfx::Size& size, | 59 const gfx::Size& size, |
| 60 float device_scale_factor, | 60 float device_scale_factor, |
| 61 unsigned int texture_id) | 61 unsigned int texture_id) |
| 62 : ui::Texture(true, size, device_scale_factor), | 62 : ui::Texture(true, size, device_scale_factor), |
| 63 host_context_(host_context), | 63 host_context_(host_context), |
| 64 texture_id_(texture_id) { | 64 texture_id_(texture_id) { |
| 65 ImageTransportFactory::GetInstance()->AddObserver(this); | 65 ImageTransportFactory::GetInstance()->AddObserver(this); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // ui::Texture overrides: | 68 // ui::Texture overrides: |
| 69 virtual unsigned int PrepareTexture() OVERRIDE { | 69 virtual unsigned int PrepareTexture() OVERRIDE { |
| 70 if (!host_context_ || host_context_->isContextLost()) | 70 if (!host_context_ || host_context_->isContextLost()) |
| 71 return 0u; | 71 return 0u; |
| 72 return texture_id_; | 72 return texture_id_; |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual WebKit::WebGraphicsContext3D* HostContext3D() OVERRIDE { | 75 virtual blink::WebGraphicsContext3D* HostContext3D() OVERRIDE { |
| 76 return host_context_; | 76 return host_context_; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // ImageTransportFactory overrides: | 79 // ImageTransportFactory overrides: |
| 80 virtual void OnLostResources() OVERRIDE { | 80 virtual void OnLostResources() OVERRIDE { |
| 81 DeleteTexture(); | 81 DeleteTexture(); |
| 82 host_context_ = NULL; | 82 host_context_ = NULL; |
| 83 } | 83 } |
| 84 | 84 |
| 85 protected: | 85 protected: |
| 86 virtual ~OwnedTexture() { | 86 virtual ~OwnedTexture() { |
| 87 ImageTransportFactory::GetInstance()->RemoveObserver(this); | 87 ImageTransportFactory::GetInstance()->RemoveObserver(this); |
| 88 DeleteTexture(); | 88 DeleteTexture(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 protected: | 91 protected: |
| 92 void DeleteTexture() { | 92 void DeleteTexture() { |
| 93 if (texture_id_) { | 93 if (texture_id_) { |
| 94 host_context_->deleteTexture(texture_id_); | 94 host_context_->deleteTexture(texture_id_); |
| 95 texture_id_ = 0; | 95 texture_id_ = 0; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 // The OnLostResources() callback will happen before this context | 99 // The OnLostResources() callback will happen before this context |
| 100 // pointer is destroyed. | 100 // pointer is destroyed. |
| 101 WebKit::WebGraphicsContext3D* host_context_; | 101 blink::WebGraphicsContext3D* host_context_; |
| 102 unsigned texture_id_; | 102 unsigned texture_id_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(OwnedTexture); | 104 DISALLOW_COPY_AND_ASSIGN(OwnedTexture); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 class ImageTransportClientTexture : public OwnedTexture { | 107 class ImageTransportClientTexture : public OwnedTexture { |
| 108 public: | 108 public: |
| 109 ImageTransportClientTexture( | 109 ImageTransportClientTexture( |
| 110 WebKit::WebGraphicsContext3D* host_context, | 110 blink::WebGraphicsContext3D* host_context, |
| 111 float device_scale_factor) | 111 float device_scale_factor) |
| 112 : OwnedTexture(host_context, | 112 : OwnedTexture(host_context, |
| 113 gfx::Size(0, 0), | 113 gfx::Size(0, 0), |
| 114 device_scale_factor, | 114 device_scale_factor, |
| 115 host_context->createTexture()) { | 115 host_context->createTexture()) { |
| 116 } | 116 } |
| 117 | 117 |
| 118 virtual void Consume(const std::string& mailbox_name, | 118 virtual void Consume(const std::string& mailbox_name, |
| 119 const gfx::Size& new_size) OVERRIDE { | 119 const gfx::Size& new_size) OVERRIDE { |
| 120 DCHECK(mailbox_name.size() == GL_MAILBOX_SIZE_CHROMIUM); | 120 DCHECK(mailbox_name.size() == GL_MAILBOX_SIZE_CHROMIUM); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 490 |
| 491 return data; | 491 return data; |
| 492 } | 492 } |
| 493 | 493 |
| 494 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 494 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
| 495 GpuProcessTransportFactory::CreateContextCommon( | 495 GpuProcessTransportFactory::CreateContextCommon( |
| 496 const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client, | 496 const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client, |
| 497 int surface_id) { | 497 int surface_id) { |
| 498 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) | 498 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) |
| 499 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 499 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
| 500 WebKit::WebGraphicsContext3D::Attributes attrs; | 500 blink::WebGraphicsContext3D::Attributes attrs; |
| 501 attrs.shareResources = true; | 501 attrs.shareResources = true; |
| 502 attrs.depth = false; | 502 attrs.depth = false; |
| 503 attrs.stencil = false; | 503 attrs.stencil = false; |
| 504 attrs.antialias = false; | 504 attrs.antialias = false; |
| 505 attrs.noAutomaticFlushes = true; | 505 attrs.noAutomaticFlushes = true; |
| 506 scoped_refptr<GpuChannelHost> gpu_channel_host( | 506 scoped_refptr<GpuChannelHost> gpu_channel_host( |
| 507 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( | 507 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( |
| 508 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
); | 508 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
); |
| 509 if (!gpu_channel_host) | 509 if (!gpu_channel_host) |
| 510 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 510 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 observer_list_, | 548 observer_list_, |
| 549 OnLostResources()); | 549 OnLostResources()); |
| 550 | 550 |
| 551 // Kill things that use the shared context before killing the shared context. | 551 // Kill things that use the shared context before killing the shared context. |
| 552 lost_gl_helper.reset(); | 552 lost_gl_helper.reset(); |
| 553 lost_offscreen_compositor_contexts = NULL; | 553 lost_offscreen_compositor_contexts = NULL; |
| 554 lost_shared_main_thread_contexts = NULL; | 554 lost_shared_main_thread_contexts = NULL; |
| 555 } | 555 } |
| 556 | 556 |
| 557 } // namespace content | 557 } // namespace content |
| OLD | NEW |