| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/common/gpu/media/android_deferred_rendering_backing_strategy.h
" | 5 #include "media/gpu/android_deferred_rendering_backing_strategy.h" |
| 6 | 6 |
| 7 #include <EGL/egl.h> | 7 #include <EGL/egl.h> |
| 8 #include <EGL/eglext.h> | 8 #include <EGL/eglext.h> |
| 9 | 9 |
| 10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "content/common/gpu/media/avda_codec_image.h" | |
| 16 #include "content/common/gpu/media/avda_return_on_failure.h" | |
| 17 #include "content/common/gpu/media/avda_shared_state.h" | |
| 18 #include "gpu/command_buffer/service/context_group.h" | 15 #include "gpu/command_buffer/service/context_group.h" |
| 19 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 16 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
| 20 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 17 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 21 #include "gpu/command_buffer/service/texture_manager.h" | 18 #include "gpu/command_buffer/service/texture_manager.h" |
| 22 #include "gpu/ipc/common/gpu_surface_lookup.h" | 19 #include "gpu/ipc/common/gpu_surface_lookup.h" |
| 23 #include "gpu/ipc/service/gpu_channel.h" | 20 #include "gpu/ipc/service/gpu_channel.h" |
| 21 #include "media/gpu/avda_codec_image.h" |
| 22 #include "media/gpu/avda_return_on_failure.h" |
| 23 #include "media/gpu/avda_shared_state.h" |
| 24 #include "ui/gl/android/surface_texture.h" | 24 #include "ui/gl/android/surface_texture.h" |
| 25 #include "ui/gl/egl_util.h" | 25 #include "ui/gl/egl_util.h" |
| 26 #include "ui/gl/gl_bindings.h" | 26 #include "ui/gl/gl_bindings.h" |
| 27 #include "ui/gl/gl_surface_egl.h" | 27 #include "ui/gl/gl_surface_egl.h" |
| 28 #include "ui/gl/scoped_binders.h" | 28 #include "ui/gl/scoped_binders.h" |
| 29 #include "ui/gl/scoped_make_current.h" | 29 #include "ui/gl/scoped_make_current.h" |
| 30 | 30 |
| 31 namespace content { | 31 namespace media { |
| 32 | 32 |
| 33 AndroidDeferredRenderingBackingStrategy:: | 33 AndroidDeferredRenderingBackingStrategy:: |
| 34 AndroidDeferredRenderingBackingStrategy(AVDAStateProvider* state_provider) | 34 AndroidDeferredRenderingBackingStrategy(AVDAStateProvider* state_provider) |
| 35 : state_provider_(state_provider), media_codec_(nullptr) {} | 35 : state_provider_(state_provider), media_codec_(nullptr) {} |
| 36 | 36 |
| 37 AndroidDeferredRenderingBackingStrategy:: | 37 AndroidDeferredRenderingBackingStrategy:: |
| 38 ~AndroidDeferredRenderingBackingStrategy() {} | 38 ~AndroidDeferredRenderingBackingStrategy() {} |
| 39 | 39 |
| 40 gfx::ScopedJavaSurface AndroidDeferredRenderingBackingStrategy::Initialize( | 40 gfx::ScopedJavaSurface AndroidDeferredRenderingBackingStrategy::Initialize( |
| 41 int surface_view_id) { | 41 int surface_view_id) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 continue; | 377 continue; |
| 378 gfx::ScopedTextureBinder texture_binder( | 378 gfx::ScopedTextureBinder texture_binder( |
| 379 GL_TEXTURE_EXTERNAL_OES, texture_ref->texture()->service_id()); | 379 GL_TEXTURE_EXTERNAL_OES, texture_ref->texture()->service_id()); |
| 380 glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image); | 380 glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image); |
| 381 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 381 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 382 } | 382 } |
| 383 | 383 |
| 384 EGLBoolean result = | 384 EGLBoolean result = |
| 385 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), egl_image); | 385 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), egl_image); |
| 386 if (result == EGL_FALSE) { | 386 if (result == EGL_FALSE) { |
| 387 DLOG(ERROR) << "Error destroying EGLImage: " | 387 DLOG(ERROR) << "Error destroying EGLImage: " << ui::GetLastEGLErrorString(); |
| 388 << ui::GetLastEGLErrorString(); | |
| 389 } | 388 } |
| 390 } | 389 } |
| 391 | 390 |
| 392 bool AndroidDeferredRenderingBackingStrategy::DoesSurfaceTextureDetachWork() | 391 bool AndroidDeferredRenderingBackingStrategy::DoesSurfaceTextureDetachWork() |
| 393 const { | 392 const { |
| 394 bool surface_texture_detach_works = true; | 393 bool surface_texture_detach_works = true; |
| 395 if (gpu::gles2::GLES2Decoder* gl_decoder = | 394 if (gpu::gles2::GLES2Decoder* gl_decoder = |
| 396 state_provider_->GetGlDecoder().get()) { | 395 state_provider_->GetGlDecoder().get()) { |
| 397 if (gpu::gles2::ContextGroup* group = gl_decoder->GetContextGroup()) { | 396 if (gpu::gles2::ContextGroup* group = gl_decoder->GetContextGroup()) { |
| 398 if (gpu::gles2::FeatureInfo* feature_info = group->feature_info()) { | 397 if (gpu::gles2::FeatureInfo* feature_info = group->feature_info()) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 416 } | 415 } |
| 417 } | 416 } |
| 418 | 417 |
| 419 return surface_texture_detach_works; | 418 return surface_texture_detach_works; |
| 420 } | 419 } |
| 421 | 420 |
| 422 bool AndroidDeferredRenderingBackingStrategy::ShouldCopyPictures() const { | 421 bool AndroidDeferredRenderingBackingStrategy::ShouldCopyPictures() const { |
| 423 // Mali + <= KitKat crashes when we try to do this. We don't know if it's | 422 // Mali + <= KitKat crashes when we try to do this. We don't know if it's |
| 424 // due to detaching a surface texture, but it's the same set of devices. | 423 // due to detaching a surface texture, but it's the same set of devices. |
| 425 if (!DoesSurfaceTextureDetachWork()) | 424 if (!DoesSurfaceTextureDetachWork()) |
| 426 return false; | 425 return false; |
| 427 | 426 |
| 428 // Other devices are unreliable for other reasons (e.g., EGLImage). | 427 // Other devices are unreliable for other reasons (e.g., EGLImage). |
| 429 if (gpu::gles2::GLES2Decoder* gl_decoder = | 428 if (gpu::gles2::GLES2Decoder* gl_decoder = |
| 430 state_provider_->GetGlDecoder().get()) { | 429 state_provider_->GetGlDecoder().get()) { |
| 431 if (gpu::gles2::ContextGroup* group = gl_decoder->GetContextGroup()) { | 430 if (gpu::gles2::ContextGroup* group = gl_decoder->GetContextGroup()) { |
| 432 if (gpu::gles2::FeatureInfo* feature_info = group->feature_info()) { | 431 if (gpu::gles2::FeatureInfo* feature_info = group->feature_info()) { |
| 433 return !feature_info->workarounds().avda_dont_copy_pictures; | 432 return !feature_info->workarounds().avda_dont_copy_pictures; |
| 434 } | 433 } |
| 435 } | 434 } |
| 436 } | 435 } |
| 437 | 436 |
| 438 // Assume so. | 437 // Assume so. |
| 439 return true; | 438 return true; |
| 440 } | 439 } |
| 441 | 440 |
| 442 } // namespace content | 441 } // namespace media |
| OLD | NEW |