| 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 | 9 | 
| 10 #include "base/bind.h" | 10 #include "base/bind.h" | 
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" | 
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" | 
| 13 #include "base/logging.h" | 13 #include "base/logging.h" | 
|  | 14 #include "cc/context_provider.h" | 
| 14 #include "cc/input_handler.h" | 15 #include "cc/input_handler.h" | 
| 15 #include "cc/layer.h" | 16 #include "cc/layer.h" | 
| 16 #include "cc/layer_tree_host.h" | 17 #include "cc/layer_tree_host.h" | 
| 17 #include "cc/output_surface.h" | 18 #include "cc/output_surface.h" | 
| 18 #include "cc/thread_impl.h" | 19 #include "cc/thread_impl.h" | 
| 19 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 20 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 
| 20 #include "content/browser/gpu/gpu_surface_tracker.h" | 21 #include "content/browser/gpu/gpu_surface_tracker.h" | 
| 21 #include "content/browser/renderer_host/image_transport_factory_android.h" | 22 #include "content/browser/renderer_host/image_transport_factory_android.h" | 
| 22 #include "content/common/gpu/client/gl_helper.h" | 23 #include "content/common/gpu/client/gl_helper.h" | 
| 23 #include "content/common/gpu/client/gpu_channel_host.h" | 24 #include "content/common/gpu/client/gpu_channel_host.h" | 
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 319 } | 320 } | 
| 320 | 321 | 
| 321 void CompositorImpl::didCompleteSwapBuffers() { | 322 void CompositorImpl::didCompleteSwapBuffers() { | 
| 322   client_->OnSwapBuffersCompleted(); | 323   client_->OnSwapBuffersCompleted(); | 
| 323 } | 324 } | 
| 324 | 325 | 
| 325 void CompositorImpl::scheduleComposite() { | 326 void CompositorImpl::scheduleComposite() { | 
| 326   client_->ScheduleComposite(); | 327   client_->ScheduleComposite(); | 
| 327 } | 328 } | 
| 328 | 329 | 
|  | 330 class NullContextProvider : public cc::ContextProvider { | 
|  | 331   virtual bool InitializeOnMainThread() { return false; } | 
|  | 332   virtual bool BindToCurrentThread() { return false; } | 
|  | 333   virtual WebKit::WebGraphicsContext3D* Context3d() { return NULL; } | 
|  | 334   virtual class GrContext* GrContext() { return NULL; } | 
|  | 335   virtual void VerifyContexts() {} | 
|  | 336  protected: | 
|  | 337   virtual ~NullContextProvider() {} | 
|  | 338 }; | 
|  | 339 | 
|  | 340 scoped_refptr<cc::ContextProvider> | 
|  | 341 CompositorImpl::OffscreenContextProviderForMainThread() { | 
|  | 342   // There is no support for offscreen contexts, or compositor filters that | 
|  | 343   // would require them in this compositor instance. If they are needed, | 
|  | 344   // then implement a context provider that provides contexts from | 
|  | 345   // ImageTransportSurfaceAndroid. | 
|  | 346   if (!null_offscreen_context_provider_) | 
|  | 347     null_offscreen_context_provider_ = new NullContextProvider(); | 
|  | 348   return null_offscreen_context_provider_; | 
|  | 349 } | 
|  | 350 | 
|  | 351 scoped_refptr<cc::ContextProvider> | 
|  | 352 CompositorImpl::OffscreenContextProviderForCompositorThread() { | 
|  | 353   // There is no support for offscreen contexts, or compositor filters that | 
|  | 354   // would require them in this compositor instance. If they are needed, | 
|  | 355   // then implement a context provider that provides contexts from | 
|  | 356   // ImageTransportSurfaceAndroid. | 
|  | 357   if (!null_offscreen_context_provider_) | 
|  | 358     null_offscreen_context_provider_ = new NullContextProvider(); | 
|  | 359   return null_offscreen_context_provider_; | 
|  | 360 } | 
|  | 361 | 
| 329 void CompositorImpl::OnViewContextSwapBuffersPosted() { | 362 void CompositorImpl::OnViewContextSwapBuffersPosted() { | 
| 330   TRACE_EVENT0("compositor", "CompositorImpl::OnViewContextSwapBuffersPosted"); | 363   TRACE_EVENT0("compositor", "CompositorImpl::OnViewContextSwapBuffersPosted"); | 
| 331 } | 364 } | 
| 332 | 365 | 
| 333 void CompositorImpl::OnViewContextSwapBuffersComplete() { | 366 void CompositorImpl::OnViewContextSwapBuffersComplete() { | 
| 334   TRACE_EVENT0("compositor", | 367   TRACE_EVENT0("compositor", | 
| 335                "CompositorImpl::OnViewContextSwapBuffersComplete"); | 368                "CompositorImpl::OnViewContextSwapBuffersComplete"); | 
| 336   client_->OnSwapBuffersCompleted(); | 369   client_->OnSwapBuffersCompleted(); | 
| 337 } | 370 } | 
| 338 | 371 | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 385     case ANDROID_BITMAP_FORMAT_RGBA_8888: | 418     case ANDROID_BITMAP_FORMAT_RGBA_8888: | 
| 386       return GL_UNSIGNED_BYTE; | 419       return GL_UNSIGNED_BYTE; | 
| 387       break; | 420       break; | 
| 388     case ANDROID_BITMAP_FORMAT_RGB_565: | 421     case ANDROID_BITMAP_FORMAT_RGB_565: | 
| 389     default: | 422     default: | 
| 390       return GL_UNSIGNED_SHORT_5_6_5; | 423       return GL_UNSIGNED_SHORT_5_6_5; | 
| 391   } | 424   } | 
| 392 } | 425 } | 
| 393 | 426 | 
| 394 } // namespace content | 427 } // namespace content | 
| OLD | NEW | 
|---|