Chromium Code Reviews| Index: content/browser/renderer_host/compositor_impl_android.cc |
| diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc |
| index 0b4eb580ea3a8710a5f78866a0825e3be81b0d50..eb2f37f6af21731f82acfe7994316e9f4447f542 100644 |
| --- a/content/browser/renderer_host/compositor_impl_android.cc |
| +++ b/content/browser/renderer_host/compositor_impl_android.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/android/jni_android.h" |
| #include "base/android/scoped_java_ref.h" |
| #include "base/bind.h" |
| +#include "base/callback_helpers.h" |
| #include "base/command_line.h" |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| @@ -25,6 +26,7 @@ |
| #include "cc/resources/scoped_ui_resource.h" |
| #include "cc/resources/ui_resource_bitmap.h" |
| #include "cc/trees/layer_tree_host.h" |
| +#include "content/browser/android/transient_ui_resource.h" |
| #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| #include "content/browser/gpu/gpu_surface_tracker.h" |
| #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| @@ -270,9 +272,22 @@ cc::UIResourceId CompositorImpl::GenerateUIResource( |
| const cc::UIResourceBitmap& bitmap) { |
| if (!host_) |
| return 0; |
| - scoped_ptr<cc::ScopedUIResource> ui_resource = |
| - cc::ScopedUIResource::Create(host_.get(), bitmap); |
| - cc::UIResourceId id = ui_resource->id(); |
| + scoped_ptr<cc::UIResourceClient> ui_resource; |
| + cc::UIResourceId id = 0; |
| + if (bitmap.GetFormat() == cc::UIResourceBitmap::RGBA8) { |
| + scoped_ptr<cc::ScopedUIResource> scoped = |
|
no sievers
2014/01/28 20:47:22
nit: |scoped| -> |resource|
powei
2014/01/29 13:53:17
Done.
|
| + cc::ScopedUIResource::Create(host_.get(), bitmap); |
| + id = scoped->id(); |
| + ui_resource.reset(scoped.release()); |
| + } else if (bitmap.GetFormat() == cc::UIResourceBitmap::ETC1) { |
| + scoped_ptr<TransientUIResource> transient = |
| + TransientUIResource::Create(host_.get(), bitmap); |
| + id = transient->id(); |
| + ui_resource.reset(transient.release()); |
| + } else { |
| + NOTREACHED(); |
|
no sievers
2014/01/28 20:47:22
return 0;
powei
2014/01/29 13:53:17
Done.
|
| + } |
| + |
| ui_resource_map_.set(id, ui_resource.Pass()); |
| return id; |
| } |
| @@ -283,75 +298,6 @@ void CompositorImpl::DeleteUIResource(cc::UIResourceId resource_id) { |
| ui_resource_map_.erase(it); |
| } |
| -GLuint CompositorImpl::GenerateTexture(gfx::JavaBitmap& bitmap) { |
| - unsigned int texture_id = BuildBasicTexture(); |
| - gpu::gles2::GLES2Interface* gl = |
| - ImageTransportFactoryAndroid::GetInstance()->GetContextGL(); |
| - if (texture_id == 0u) |
| - return 0u; |
| - GLenum format = GetGLFormatForBitmap(bitmap); |
| - GLenum type = GetGLTypeForBitmap(bitmap); |
| - |
| - gl->TexImage2D(GL_TEXTURE_2D, |
| - 0, |
| - format, |
| - bitmap.size().width(), |
| - bitmap.size().height(), |
| - 0, |
| - format, |
| - type, |
| - bitmap.pixels()); |
| - gl->ShallowFlushCHROMIUM(); |
| - return texture_id; |
| -} |
| - |
| -GLuint CompositorImpl::GenerateCompressedTexture(gfx::Size& size, |
| - int data_size, |
| - void* data) { |
| - unsigned int texture_id = BuildBasicTexture(); |
| - gpu::gles2::GLES2Interface* gl = |
| - ImageTransportFactoryAndroid::GetInstance()->GetContextGL(); |
| - if (texture_id == 0u) |
| - return 0u; |
| - gl->CompressedTexImage2D(GL_TEXTURE_2D, |
| - 0, |
| - GL_ETC1_RGB8_OES, |
| - size.width(), |
| - size.height(), |
| - 0, |
| - data_size, |
| - data); |
| - gl->ShallowFlushCHROMIUM(); |
| - return texture_id; |
| -} |
| - |
| -void CompositorImpl::DeleteTexture(GLuint texture_id) { |
| - gpu::gles2::GLES2Interface* gl = |
| - ImageTransportFactoryAndroid::GetInstance()->GetContextGL(); |
| - gl->DeleteTextures(1, &texture_id); |
| - gl->ShallowFlushCHROMIUM(); |
| -} |
| - |
| -bool CompositorImpl::CopyTextureToBitmap(GLuint texture_id, |
| - gfx::JavaBitmap& bitmap) { |
| - return CopyTextureToBitmap(texture_id, gfx::Rect(bitmap.size()), bitmap); |
| -} |
| - |
| -bool CompositorImpl::CopyTextureToBitmap(GLuint texture_id, |
| - const gfx::Rect& sub_rect, |
| - gfx::JavaBitmap& bitmap) { |
| - // The sub_rect should match the bitmap size. |
| - DCHECK(bitmap.size() == sub_rect.size()); |
| - if (bitmap.size() != sub_rect.size() || texture_id == 0) return false; |
| - |
| - GLHelper* helper = ImageTransportFactoryAndroid::GetInstance()->GetGLHelper(); |
| - helper->ReadbackTextureSync(texture_id, |
| - sub_rect, |
| - static_cast<unsigned char*> (bitmap.pixels()), |
| - SkBitmap::kARGB_8888_Config); |
| - return true; |
| -} |
| - |
| static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
| CreateGpuProcessViewContext( |
| const blink::WebGraphicsContext3D::Attributes attributes, |