| 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/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 content::CommandBufferProxyImpl* command_buffer_proxy = | 84 content::CommandBufferProxyImpl* command_buffer_proxy = |
| 85 command_buffer_context->GetCommandBufferProxy(); | 85 command_buffer_context->GetCommandBufferProxy(); |
| 86 DCHECK(command_buffer_proxy); | 86 DCHECK(command_buffer_proxy); |
| 87 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); | 87 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); |
| 88 | 88 |
| 89 OutputSurface::SwapBuffers(frame); | 89 OutputSurface::SwapBuffers(frame); |
| 90 } | 90 } |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 static bool g_initialized = false; | 93 static bool g_initialized = false; |
| 94 static base::Thread* g_impl_thread = NULL; | |
| 95 | 94 |
| 96 } // anonymous namespace | 95 } // anonymous namespace |
| 97 | 96 |
| 98 namespace content { | 97 namespace content { |
| 99 | 98 |
| 100 typedef std::map<int, base::android::ScopedJavaGlobalRef<jobject> > | 99 typedef std::map<int, base::android::ScopedJavaGlobalRef<jobject> > |
| 101 SurfaceMap; | 100 SurfaceMap; |
| 102 static base::LazyInstance<SurfaceMap> | 101 static base::LazyInstance<SurfaceMap> |
| 103 g_surface_map = LAZY_INSTANCE_INITIALIZER; | 102 g_surface_map = LAZY_INSTANCE_INITIALIZER; |
| 104 static base::LazyInstance<base::Lock> g_surface_map_lock; | 103 static base::LazyInstance<base::Lock> g_surface_map_lock; |
| 105 | 104 |
| 106 // static | 105 // static |
| 107 Compositor* Compositor::Create(CompositorClient* client) { | 106 Compositor* Compositor::Create(CompositorClient* client) { |
| 108 return client ? new CompositorImpl(client) : NULL; | 107 return client ? new CompositorImpl(client) : NULL; |
| 109 } | 108 } |
| 110 | 109 |
| 111 // static | 110 // static |
| 112 void Compositor::Initialize() { | 111 void Compositor::Initialize() { |
| 113 DCHECK(!CompositorImpl::IsInitialized()); | 112 DCHECK(!CompositorImpl::IsInitialized()); |
| 114 g_initialized = true; | 113 g_initialized = true; |
| 115 } | 114 } |
| 116 | 115 |
| 117 // static | 116 // static |
| 118 bool CompositorImpl::IsInitialized() { | 117 bool CompositorImpl::IsInitialized() { |
| 119 return g_initialized; | 118 return g_initialized; |
| 120 } | 119 } |
| 121 | 120 |
| 122 // static | 121 // static |
| 123 bool CompositorImpl::IsThreadingEnabled() { | |
| 124 return g_impl_thread; | |
| 125 } | |
| 126 | |
| 127 // static | |
| 128 jobject CompositorImpl::GetSurface(int surface_id) { | 122 jobject CompositorImpl::GetSurface(int surface_id) { |
| 129 base::AutoLock lock(g_surface_map_lock.Get()); | 123 base::AutoLock lock(g_surface_map_lock.Get()); |
| 130 SurfaceMap* surfaces = g_surface_map.Pointer(); | 124 SurfaceMap* surfaces = g_surface_map.Pointer(); |
| 131 SurfaceMap::iterator it = surfaces->find(surface_id); | 125 SurfaceMap::iterator it = surfaces->find(surface_id); |
| 132 jobject jsurface = it == surfaces->end() ? NULL : it->second.obj(); | 126 jobject jsurface = it == surfaces->end() ? NULL : it->second.obj(); |
| 133 | 127 |
| 134 LOG_IF(WARNING, !jsurface) << "No surface for surface id " << surface_id; | 128 LOG_IF(WARNING, !jsurface) << "No surface for surface id " << surface_id; |
| 135 return jsurface; | 129 return jsurface; |
| 136 } | 130 } |
| 137 | 131 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } else if (!host_) { | 213 } else if (!host_) { |
| 220 cc::LayerTreeSettings settings; | 214 cc::LayerTreeSettings settings; |
| 221 settings.refresh_rate = 60.0; | 215 settings.refresh_rate = 60.0; |
| 222 settings.impl_side_painting = false; | 216 settings.impl_side_painting = false; |
| 223 settings.allow_antialiasing = false; | 217 settings.allow_antialiasing = false; |
| 224 settings.calculate_top_controls_position = false; | 218 settings.calculate_top_controls_position = false; |
| 225 settings.top_controls_height = 0.f; | 219 settings.top_controls_height = 0.f; |
| 226 settings.use_memory_management = false; | 220 settings.use_memory_management = false; |
| 227 settings.highp_threshold_min = 2048; | 221 settings.highp_threshold_min = 2048; |
| 228 | 222 |
| 229 scoped_refptr<base::SingleThreadTaskRunner> impl_thread_task_runner = | 223 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings); |
| 230 g_impl_thread ? g_impl_thread->message_loop()->message_loop_proxy() | |
| 231 : NULL; | |
| 232 | |
| 233 host_ = cc::LayerTreeHost::Create( | |
| 234 this, NULL, settings, impl_thread_task_runner); | |
| 235 host_->SetRootLayer(root_layer_); | 224 host_->SetRootLayer(root_layer_); |
| 236 | 225 |
| 237 host_->SetVisible(true); | 226 host_->SetVisible(true); |
| 238 host_->SetLayerTreeHostClientReady(); | 227 host_->SetLayerTreeHostClientReady(); |
| 239 host_->SetViewportSize(size_); | 228 host_->SetViewportSize(size_); |
| 240 host_->set_has_transparent_background(has_transparent_background_); | 229 host_->set_has_transparent_background(has_transparent_background_); |
| 241 // Need to recreate the UI resources because a new LayerTreeHost has been | 230 // Need to recreate the UI resources because a new LayerTreeHost has been |
| 242 // created. | 231 // created. |
| 243 client_->DidLoseUIResources(); | 232 client_->DidLoseUIResources(); |
| 244 } | 233 } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 case ANDROID_BITMAP_FORMAT_RGBA_8888: | 480 case ANDROID_BITMAP_FORMAT_RGBA_8888: |
| 492 return GL_UNSIGNED_BYTE; | 481 return GL_UNSIGNED_BYTE; |
| 493 break; | 482 break; |
| 494 case ANDROID_BITMAP_FORMAT_RGB_565: | 483 case ANDROID_BITMAP_FORMAT_RGB_565: |
| 495 default: | 484 default: |
| 496 return GL_UNSIGNED_SHORT_5_6_5; | 485 return GL_UNSIGNED_SHORT_5_6_5; |
| 497 } | 486 } |
| 498 } | 487 } |
| 499 | 488 |
| 500 } // namespace content | 489 } // namespace content |
| OLD | NEW |