| 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/compositor_impl_android.h" | 5 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 6 | 6 |
| 7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 scoped_ptr<WebKit::WebGraphicsContext3D> m_context3D; | 64 scoped_ptr<WebKit::WebGraphicsContext3D> m_context3D; |
| 65 Capabilities m_capabilities; | 65 Capabilities m_capabilities; |
| 66 WebKit::WebCompositorOutputSurfaceClient* m_client; | 66 WebKit::WebCompositorOutputSurfaceClient* m_client; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // anonymous namespace | 69 } // anonymous namespace |
| 70 | 70 |
| 71 namespace content { | 71 namespace content { |
| 72 | 72 |
| 73 // static | 73 // static |
| 74 Compositor* Compositor::Create() { | 74 Compositor* Compositor::Create(Client* client) { |
| 75 return new CompositorImpl(); | 75 return client ? new CompositorImpl(client) : NULL; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // static | 78 // static |
| 79 void Compositor::Initialize() { | 79 void Compositor::Initialize() { |
| 80 g_initialized = true; | 80 g_initialized = true; |
| 81 // Android WebView runs in single process, and depends on the renderer to | 81 // Android WebView runs in single process, and depends on the renderer to |
| 82 // perform WebKit::Platform initialization for the entire process. The | 82 // perform WebKit::Platform initialization for the entire process. The |
| 83 // renderer, however, does that lazily which in practice means it waits | 83 // renderer, however, does that lazily which in practice means it waits |
| 84 // until the first page load request. | 84 // until the first page load request. |
| 85 // The WebView-specific rendering code isn't ready yet so we only want to | 85 // The WebView-specific rendering code isn't ready yet so we only want to |
| (...skipping 11 matching lines...) Expand all Loading... |
| 97 return; | 97 return; |
| 98 } | 98 } |
| 99 WebKit::Platform::current()->compositorSupport()->initialize(NULL); | 99 WebKit::Platform::current()->compositorSupport()->initialize(NULL); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // static | 102 // static |
| 103 bool CompositorImpl::IsInitialized() { | 103 bool CompositorImpl::IsInitialized() { |
| 104 return g_initialized; | 104 return g_initialized; |
| 105 } | 105 } |
| 106 | 106 |
| 107 CompositorImpl::CompositorImpl() | 107 CompositorImpl::CompositorImpl(Compositor::Client* client) |
| 108 : window_(NULL), | 108 : window_(NULL), |
| 109 surface_id_(0) { | 109 surface_id_(0), |
| 110 client_(client) { |
| 111 DCHECK(client); |
| 110 root_layer_.reset( | 112 root_layer_.reset( |
| 111 WebKit::Platform::current()->compositorSupport()->createLayer()); | 113 WebKit::Platform::current()->compositorSupport()->createLayer()); |
| 112 } | 114 } |
| 113 | 115 |
| 114 CompositorImpl::~CompositorImpl() { | 116 CompositorImpl::~CompositorImpl() { |
| 115 } | 117 } |
| 116 | 118 |
| 117 void CompositorImpl::OnSurfaceUpdated( | 119 void CompositorImpl::Composite() { |
| 118 const SurfacePresentedCallback& callback) { | |
| 119 if (host_.get()) | 120 if (host_.get()) |
| 120 host_->composite(); | 121 host_->composite(); |
| 121 // TODO(sievers): Let RWHV do this | |
| 122 uint32 sync_point = | |
| 123 ImageTransportFactoryAndroid::GetInstance()->InsertSyncPoint(); | |
| 124 callback.Run(sync_point); | |
| 125 } | 122 } |
| 126 | 123 |
| 127 void CompositorImpl::SetRootLayer(WebKit::WebLayer* root_layer) { | 124 void CompositorImpl::SetRootLayer(WebKit::WebLayer* root_layer) { |
| 128 root_layer_->removeAllChildren(); | 125 root_layer_->removeAllChildren(); |
| 129 root_layer_->addChild(root_layer); | 126 root_layer_->addChild(root_layer); |
| 130 } | 127 } |
| 131 | 128 |
| 132 void CompositorImpl::SetWindowSurface(ANativeWindow* window) { | 129 void CompositorImpl::SetWindowSurface(ANativeWindow* window) { |
| 133 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); | 130 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); |
| 134 | 131 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 void CompositorImpl::didCommit() { | 211 void CompositorImpl::didCommit() { |
| 215 } | 212 } |
| 216 | 213 |
| 217 void CompositorImpl::didCommitAndDrawFrame() { | 214 void CompositorImpl::didCommitAndDrawFrame() { |
| 218 } | 215 } |
| 219 | 216 |
| 220 void CompositorImpl::didCompleteSwapBuffers() { | 217 void CompositorImpl::didCompleteSwapBuffers() { |
| 221 } | 218 } |
| 222 | 219 |
| 223 void CompositorImpl::scheduleComposite() { | 220 void CompositorImpl::scheduleComposite() { |
| 221 client_->ScheduleComposite(); |
| 224 } | 222 } |
| 225 | 223 |
| 226 } // namespace content | 224 } // namespace content |
| OLD | NEW |