Chromium Code Reviews| 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_android.h" | 5 #include "content/browser/renderer_host/image_transport_factory_android.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 8 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 9 #include "content/browser/renderer_host/compositor_impl_android.h" | 9 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 10 #include "content/common/gpu/gpu_process_launch_causes.h" | 10 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 11 #include "content/common/gpu/client/gl_helper.h" | 11 #include "content/common/gpu/client/gl_helper.h" |
| 12 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 12 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" |
| 14 #include "third_party/khronos/GLES2/gl2.h" | 14 #include "third_party/khronos/GLES2/gl2.h" |
| 15 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | 15 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 static ImageTransportFactoryAndroid* g_factory = NULL; | 21 static ImageTransportFactoryAndroid* g_factory = NULL; |
| 22 | 22 |
| 23 class DirectGLImageTransportFactory : public ImageTransportFactoryAndroid { | 23 class DirectGLImageTransportFactory : public ImageTransportFactoryAndroid { |
| 24 public: | 24 public: |
| 25 DirectGLImageTransportFactory(); | 25 DirectGLImageTransportFactory(); |
| 26 virtual ~DirectGLImageTransportFactory(); | 26 virtual ~DirectGLImageTransportFactory(); |
| 27 | 27 |
| 28 virtual uint32_t InsertSyncPoint() OVERRIDE { return 0; } | 28 virtual uint32_t InsertSyncPoint() OVERRIDE { return 0; } |
| 29 virtual void WaitSyncPoint(uint32_t sync_point) OVERRIDE {} | |
| 29 virtual uint32_t CreateTexture() OVERRIDE { | 30 virtual uint32_t CreateTexture() OVERRIDE { |
| 30 return context_->createTexture(); | 31 return context_->createTexture(); |
| 31 } | 32 } |
| 32 virtual void DeleteTexture(uint32_t id) OVERRIDE { | 33 virtual void DeleteTexture(uint32_t id) OVERRIDE { |
| 33 context_->deleteTexture(id); | 34 context_->deleteTexture(id); |
| 34 } | 35 } |
| 35 virtual void AcquireTexture( | 36 virtual void AcquireTexture( |
| 36 uint32 texture_id, const signed char* mailbox_name) OVERRIDE {} | 37 uint32 texture_id, const signed char* mailbox_name) OVERRIDE {} |
| 37 virtual void ReleaseTexture( | 38 virtual void ReleaseTexture( |
| 38 uint32 texture_id, const signed char* mailbox_name) OVERRIDE {} | 39 uint32 texture_id, const signed char* mailbox_name) OVERRIDE {} |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 60 | 61 |
| 61 DirectGLImageTransportFactory::~DirectGLImageTransportFactory() { | 62 DirectGLImageTransportFactory::~DirectGLImageTransportFactory() { |
| 62 } | 63 } |
| 63 | 64 |
| 64 class CmdBufferImageTransportFactory : public ImageTransportFactoryAndroid { | 65 class CmdBufferImageTransportFactory : public ImageTransportFactoryAndroid { |
| 65 public: | 66 public: |
| 66 CmdBufferImageTransportFactory(); | 67 CmdBufferImageTransportFactory(); |
| 67 virtual ~CmdBufferImageTransportFactory(); | 68 virtual ~CmdBufferImageTransportFactory(); |
| 68 | 69 |
| 69 virtual uint32_t InsertSyncPoint() OVERRIDE; | 70 virtual uint32_t InsertSyncPoint() OVERRIDE; |
| 71 virtual void WaitSyncPoint(uint32_t sync_point) OVERRIDE; | |
| 70 virtual uint32_t CreateTexture() OVERRIDE; | 72 virtual uint32_t CreateTexture() OVERRIDE; |
| 71 virtual void DeleteTexture(uint32_t id) OVERRIDE; | 73 virtual void DeleteTexture(uint32_t id) OVERRIDE; |
| 72 virtual void AcquireTexture( | 74 virtual void AcquireTexture( |
| 73 uint32 texture_id, const signed char* mailbox_name) OVERRIDE; | 75 uint32 texture_id, const signed char* mailbox_name) OVERRIDE; |
| 74 virtual void ReleaseTexture( | 76 virtual void ReleaseTexture( |
| 75 uint32 texture_id, const signed char* mailbox_name) OVERRIDE; | 77 uint32 texture_id, const signed char* mailbox_name) OVERRIDE; |
| 76 virtual WebKit::WebGraphicsContext3D* GetContext3D() OVERRIDE { | 78 virtual WebKit::WebGraphicsContext3D* GetContext3D() OVERRIDE { |
| 77 return context_.get(); | 79 return context_.get(); |
| 78 } | 80 } |
| 79 virtual GLHelper* GetGLHelper() OVERRIDE; | 81 virtual GLHelper* GetGLHelper() OVERRIDE; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 98 context_->Initialize( | 100 context_->Initialize( |
| 99 attrs, | 101 attrs, |
| 100 false, | 102 false, |
| 101 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE); | 103 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE); |
| 102 } | 104 } |
| 103 | 105 |
| 104 CmdBufferImageTransportFactory::~CmdBufferImageTransportFactory() { | 106 CmdBufferImageTransportFactory::~CmdBufferImageTransportFactory() { |
| 105 } | 107 } |
| 106 | 108 |
| 107 uint32_t CmdBufferImageTransportFactory::InsertSyncPoint() { | 109 uint32_t CmdBufferImageTransportFactory::InsertSyncPoint() { |
| 110 if (!context_->makeContextCurrent()) { | |
|
Sami
2013/03/05 17:44:42
Tempted to suggest something like makeHelperContex
no sievers
2013/03/05 21:58:05
I wish I could eliminate the helper context...
| |
| 111 LOG(ERROR) << "Failed to make helper context current."; | |
| 112 return 0; | |
| 113 } | |
| 108 return context_->insertSyncPoint(); | 114 return context_->insertSyncPoint(); |
| 109 } | 115 } |
| 110 | 116 |
| 117 void CmdBufferImageTransportFactory::WaitSyncPoint(uint32_t sync_point) { | |
| 118 if (!context_->makeContextCurrent()) { | |
| 119 LOG(ERROR) << "Failed to make helper context current."; | |
| 120 return; | |
| 121 } | |
| 122 context_->waitSyncPoint(sync_point); | |
| 123 } | |
| 124 | |
| 111 uint32_t CmdBufferImageTransportFactory::CreateTexture() { | 125 uint32_t CmdBufferImageTransportFactory::CreateTexture() { |
| 112 if (!context_->makeContextCurrent()) { | 126 if (!context_->makeContextCurrent()) { |
| 113 LOG(ERROR) << "Failed to make helper context current."; | 127 LOG(ERROR) << "Failed to make helper context current."; |
| 114 return false; | 128 return false; |
| 115 } | 129 } |
| 116 return context_->createTexture(); | 130 return context_->createTexture(); |
| 117 } | 131 } |
| 118 | 132 |
| 119 void CmdBufferImageTransportFactory::DeleteTexture(uint32_t id) { | 133 void CmdBufferImageTransportFactory::DeleteTexture(uint32_t id) { |
| 120 if (!context_->makeContextCurrent()) { | 134 if (!context_->makeContextCurrent()) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 return g_factory; | 180 return g_factory; |
| 167 } | 181 } |
| 168 | 182 |
| 169 ImageTransportFactoryAndroid::ImageTransportFactoryAndroid() { | 183 ImageTransportFactoryAndroid::ImageTransportFactoryAndroid() { |
| 170 } | 184 } |
| 171 | 185 |
| 172 ImageTransportFactoryAndroid::~ImageTransportFactoryAndroid() { | 186 ImageTransportFactoryAndroid::~ImageTransportFactoryAndroid() { |
| 173 } | 187 } |
| 174 | 188 |
| 175 } // namespace content | 189 } // namespace content |
| OLD | NEW |