| 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 |
| 11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
| 12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "cc/input/input_handler.h" | 20 #include "cc/input/input_handler.h" |
| 21 #include "cc/layers/layer.h" | 21 #include "cc/layers/layer.h" |
| 22 #include "cc/output/compositor_frame.h" | 22 #include "cc/output/compositor_frame.h" |
| 23 #include "cc/output/context_provider.h" | 23 #include "cc/output/context_provider.h" |
| 24 #include "cc/output/output_surface.h" | 24 #include "cc/output/output_surface.h" |
| 25 #include "cc/resources/etc1_pixel_ref.h" |
| 25 #include "cc/resources/scoped_ui_resource.h" | 26 #include "cc/resources/scoped_ui_resource.h" |
| 26 #include "cc/resources/ui_resource_bitmap.h" | 27 #include "cc/resources/ui_resource_bitmap.h" |
| 27 #include "cc/trees/layer_tree_host.h" | 28 #include "cc/trees/layer_tree_host.h" |
| 28 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 29 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 29 #include "content/browser/gpu/gpu_surface_tracker.h" | 30 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 30 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 31 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 31 #include "content/common/gpu/client/context_provider_command_buffer.h" | 32 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 32 #include "content/common/gpu/client/gl_helper.h" | 33 #include "content/common/gpu/client/gl_helper.h" |
| 33 #include "content/common/gpu/client/gpu_channel_host.h" | 34 #include "content/common/gpu/client/gpu_channel_host.h" |
| 34 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 35 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 GL_ETC1_RGB8_OES, | 310 GL_ETC1_RGB8_OES, |
| 310 size.width(), | 311 size.width(), |
| 311 size.height(), | 312 size.height(), |
| 312 0, | 313 0, |
| 313 data_size, | 314 data_size, |
| 314 data); | 315 data); |
| 315 context->shallowFlushCHROMIUM(); | 316 context->shallowFlushCHROMIUM(); |
| 316 return texture_id; | 317 return texture_id; |
| 317 } | 318 } |
| 318 | 319 |
| 320 cc::UIResourceId CompositorImpl::GenerateCompressedUIResource(gfx::Size& size, |
| 321 int data_size, |
| 322 void* data) { |
| 323 scoped_ptr<uint8_t[]> pixels(static_cast<uint8_t*>(data)); |
| 324 skia::RefPtr<cc::ETC1PixelRef> etc1_pixel_ref = |
| 325 skia::AdoptRef(new cc::ETC1PixelRef(pixels.Pass())); |
| 326 cc::UIResourceBitmap ui_bitmap(etc1_pixel_ref, size); |
| 327 return GenerateUIResource(ui_bitmap); |
| 328 } |
| 329 |
| 319 void CompositorImpl::DeleteTexture(blink::WebGLId texture_id) { | 330 void CompositorImpl::DeleteTexture(blink::WebGLId texture_id) { |
| 320 blink::WebGraphicsContext3D* context = | 331 blink::WebGraphicsContext3D* context = |
| 321 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); | 332 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); |
| 322 if (context->isContextLost() || !context->makeContextCurrent()) | 333 if (context->isContextLost() || !context->makeContextCurrent()) |
| 323 return; | 334 return; |
| 324 context->deleteTexture(texture_id); | 335 context->deleteTexture(texture_id); |
| 325 context->shallowFlushCHROMIUM(); | 336 context->shallowFlushCHROMIUM(); |
| 326 } | 337 } |
| 327 | 338 |
| 328 bool CompositorImpl::CopyTextureToBitmap(blink::WebGLId texture_id, | 339 bool CompositorImpl::CopyTextureToBitmap(blink::WebGLId texture_id, |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 case ANDROID_BITMAP_FORMAT_RGBA_8888: | 493 case ANDROID_BITMAP_FORMAT_RGBA_8888: |
| 483 return GL_UNSIGNED_BYTE; | 494 return GL_UNSIGNED_BYTE; |
| 484 break; | 495 break; |
| 485 case ANDROID_BITMAP_FORMAT_RGB_565: | 496 case ANDROID_BITMAP_FORMAT_RGB_565: |
| 486 default: | 497 default: |
| 487 return GL_UNSIGNED_SHORT_5_6_5; | 498 return GL_UNSIGNED_SHORT_5_6_5; |
| 488 } | 499 } |
| 489 } | 500 } |
| 490 | 501 |
| 491 } // namespace content | 502 } // namespace content |
| OLD | NEW |