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/public/browser/android/graphics_context.h" | 5 #include "content/browser/android/graphics_context.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "content/browser/android/draw_delegate_impl.h" | |
| 9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 8 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 10 #include "content/browser/gpu/gpu_surface_tracker.h" | 9 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 10 #include "content/browser/renderer_host/compositor_impl_android.h" | |
| 11 #include "content/common/gpu/client/gpu_channel_host.h" | 11 #include "content/common/gpu/client/gpu_channel_host.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 "content/common/gpu/gpu_process_launch_causes.h" | 13 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h" |
| 16 | 16 |
| 17 #include <android/native_window_jni.h> | 17 #include <android/native_window_jni.h> |
| 18 | 18 |
| 19 using content::BrowserGpuChannelHostFactory; | 19 using content::BrowserGpuChannelHostFactory; |
| 20 | 20 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 38 virtual ~CmdBufferGraphicsContext() { | 38 virtual ~CmdBufferGraphicsContext() { |
| 39 context_->makeContextCurrent(); | 39 context_->makeContextCurrent(); |
| 40 context_->deleteTexture(texture_id_[0]); | 40 context_->deleteTexture(texture_id_[0]); |
| 41 context_->deleteTexture(texture_id_[1]); | 41 context_->deleteTexture(texture_id_[1]); |
| 42 context_->finish(); | 42 context_->finish(); |
| 43 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); | 43 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); |
| 44 tracker->RemoveSurface(surface_id_); | 44 tracker->RemoveSurface(surface_id_); |
| 45 ANativeWindow_release(window_); | 45 ANativeWindow_release(window_); |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual WebKit::WebGraphicsContext3D* GetContext3D() { | 48 virtual WebKit::WebGraphicsContext3D* GetContext3D() OVERRIDE { |
| 49 return context_.get(); | 49 return context_.get(); |
| 50 } | 50 } |
| 51 virtual uint32 InsertSyncPoint() { | 51 virtual uint32 InsertSyncPoint() OVERRIDE { |
| 52 return context_->insertSyncPoint(); | 52 return context_->insertSyncPoint(); |
|
klobag.chromium
2012/08/22 07:01:18
Is the only reason to have this context_ is to mak
no sievers
2012/08/22 21:17:40
It also takes care of referencing the ANativeWindo
| |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual int GetSurfaceID() OVERRIDE { | |
| 56 return surface_id_; | |
| 57 } | |
| 58 | |
| 55 private: | 59 private: |
| 56 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_; | 60 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_; |
| 57 int surface_id_; | 61 int surface_id_; |
| 58 ANativeWindow* window_; | 62 ANativeWindow* window_; |
| 59 int texture_id_[2]; | 63 int texture_id_[2]; |
| 60 }; | 64 }; |
| 61 | 65 |
| 62 } // anonymous namespace | 66 } // anonymous namespace |
| 63 | 67 |
| 64 namespace content { | 68 namespace content { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 76 surface_id, | 80 surface_id, |
| 77 gfx::GLSurfaceHandle(gfx::kDummyPluginWindow, false)); | 81 gfx::GLSurfaceHandle(gfx::kDummyPluginWindow, false)); |
| 78 | 82 |
| 79 WebKit::WebGraphicsContext3D::Attributes attrs; | 83 WebKit::WebGraphicsContext3D::Attributes attrs; |
| 80 attrs.shareResources = true; | 84 attrs.shareResources = true; |
| 81 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); | 85 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); |
| 82 GURL url("chrome://gpu/GpuProcessTransportHelper::CreateContext"); | 86 GURL url("chrome://gpu/GpuProcessTransportHelper::CreateContext"); |
| 83 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; | 87 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; |
| 84 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 88 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| 85 new WebGraphicsContext3DCommandBufferImpl( | 89 new WebGraphicsContext3DCommandBufferImpl( |
| 86 surface_id, | 90 0, |
| 87 url, | 91 url, |
| 88 factory, | 92 factory, |
| 89 swap_client)); | 93 swap_client)); |
| 90 if (!context->Initialize( | 94 if (!context->Initialize( |
| 91 attrs, | 95 attrs, |
| 92 false, | 96 false, |
| 93 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) { | 97 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) { |
| 94 return NULL; | 98 return NULL; |
| 95 } | 99 } |
| 96 | 100 |
| 97 context->makeContextCurrent(); | 101 context->makeContextCurrent(); |
| 98 | 102 |
| 99 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( | 103 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( |
| 100 gfx::kNullPluginWindow, true); | 104 gfx::kNullPluginWindow, true); |
| 101 handle.parent_gpu_process_id = context->GetGPUProcessID(); | 105 handle.parent_gpu_process_id = context->GetGPUProcessID(); |
| 102 handle.parent_client_id = context->GetChannelID(); | 106 handle.parent_client_id = context->GetChannelID(); |
| 103 handle.parent_context_id = context->GetContextID(); | 107 handle.parent_context_id = context->GetContextID(); |
| 104 handle.parent_texture_id[0] = context->createTexture(); | 108 handle.parent_texture_id[0] = context->createTexture(); |
| 105 handle.parent_texture_id[1] = context->createTexture(); | 109 handle.parent_texture_id[1] = context->createTexture(); |
| 106 handle.sync_point = context->insertSyncPoint(); | 110 handle.sync_point = context->insertSyncPoint(); |
| 107 | 111 |
| 108 DrawDelegateImpl::GetInstance()->SetDrawSurface(handle); | 112 CompositorImpl::GetInstance()->SetCompositorSurface(handle); |
| 109 | 113 |
| 110 return new CmdBufferGraphicsContext( | 114 return new CmdBufferGraphicsContext( |
| 111 context.release(), surface_id, window, | 115 context.release(), surface_id, window, |
| 112 handle.parent_texture_id[0], | 116 handle.parent_texture_id[0], |
| 113 handle.parent_texture_id[1]); | 117 handle.parent_texture_id[1]); |
| 114 } | 118 } |
| 115 | 119 |
| 116 } // namespace content | 120 } // namespace content |
| OLD | NEW |