| 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 "content/common/gpu/media/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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "gpu/command_buffer/service/texture_manager.h" | 23 #include "gpu/command_buffer/service/texture_manager.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 content { |
| 32 | 32 |
| 33 namespace { | |
| 34 // clang-format off | |
| 35 const float kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, | |
| 36 0.0f, 1.0f, 0.0f, 0.0f, | |
| 37 0.0f, 0.0f, 1.0f, 0.0f, | |
| 38 0.0f, 0.0f, 0.0f, 1.0f}; | |
| 39 // clang-format on | |
| 40 } | |
| 41 | |
| 42 AndroidDeferredRenderingBackingStrategy:: | 33 AndroidDeferredRenderingBackingStrategy:: |
| 43 AndroidDeferredRenderingBackingStrategy(AVDAStateProvider* state_provider) | 34 AndroidDeferredRenderingBackingStrategy(AVDAStateProvider* state_provider) |
| 44 : state_provider_(state_provider), media_codec_(nullptr) {} | 35 : state_provider_(state_provider), media_codec_(nullptr) {} |
| 45 | 36 |
| 46 AndroidDeferredRenderingBackingStrategy:: | 37 AndroidDeferredRenderingBackingStrategy:: |
| 47 ~AndroidDeferredRenderingBackingStrategy() {} | 38 ~AndroidDeferredRenderingBackingStrategy() {} |
| 48 | 39 |
| 49 gfx::ScopedJavaSurface AndroidDeferredRenderingBackingStrategy::Initialize( | 40 gfx::ScopedJavaSurface AndroidDeferredRenderingBackingStrategy::Initialize( |
| 50 int surface_view_id) { | 41 int surface_view_id) { |
| 51 shared_state_ = new AVDASharedState(); | 42 shared_state_ = new AVDASharedState(); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, tmp_texture_id); | 280 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, tmp_texture_id); |
| 290 // The target texture's size will exactly match the source. | 281 // The target texture's size will exactly match the source. |
| 291 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 282 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 292 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 283 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 293 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 284 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 294 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 285 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 295 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), 0, | 286 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), 0, |
| 296 GL_RGBA, GL_UNSIGNED_BYTE, nullptr); | 287 GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 297 } | 288 } |
| 298 | 289 |
| 299 // TODO(liberato,watk): Use the SurfaceTexture matrix when copying. | 290 |
| 291 |
| 292 float transform_matrix[16]; |
| 293 surface_texture_->GetTransformMatrix(transform_matrix); |
| 294 |
| 300 gpu::CopyTextureCHROMIUMResourceManager copier; | 295 gpu::CopyTextureCHROMIUMResourceManager copier; |
| 301 copier.Initialize( | 296 copier.Initialize( |
| 302 gl_decoder, | 297 gl_decoder, |
| 303 gl_decoder->GetContextGroup()->feature_info()->feature_flags()); | 298 gl_decoder->GetContextGroup()->feature_info()->feature_flags()); |
| 304 copier.DoCopyTextureWithTransform(gl_decoder, GL_TEXTURE_EXTERNAL_OES, | 299 copier.DoCopyTextureWithTransform(gl_decoder, GL_TEXTURE_EXTERNAL_OES, |
| 305 shared_state_->surface_texture_service_id(), | 300 shared_state_->surface_texture_service_id(), |
| 306 GL_TEXTURE_2D, tmp_texture_id, size.width(), | 301 GL_TEXTURE_2D, tmp_texture_id, size.width(), |
| 307 size.height(), false, false, false, | 302 size.height(), true, false, false, |
| 308 kIdentityMatrix); | 303 transform_matrix); |
| 309 | 304 |
| 310 // Create an EGLImage from the 2D texture we just copied into. By associating | 305 // Create an EGLImage from the 2D texture we just copied into. By associating |
| 311 // the EGLImage with the PictureBuffer textures they will remain valid even | 306 // the EGLImage with the PictureBuffer textures they will remain valid even |
| 312 // after we delete the 2D texture and EGLImage. | 307 // after we delete the 2D texture and EGLImage. |
| 313 const EGLImageKHR egl_image = eglCreateImageKHR( | 308 const EGLImageKHR egl_image = eglCreateImageKHR( |
| 314 gfx::GLSurfaceEGL::GetHardwareDisplay(), eglGetCurrentContext(), | 309 gfx::GLSurfaceEGL::GetHardwareDisplay(), eglGetCurrentContext(), |
| 315 EGL_GL_TEXTURE_2D_KHR, reinterpret_cast<EGLClientBuffer>(tmp_texture_id), | 310 EGL_GL_TEXTURE_2D_KHR, reinterpret_cast<EGLClientBuffer>(tmp_texture_id), |
| 316 nullptr /* attrs */); | 311 nullptr /* attrs */); |
| 317 | 312 |
| 318 glDeleteTextures(1, &tmp_texture_id); | 313 glDeleteTextures(1, &tmp_texture_id); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 base::ToLowerASCII(base::android::BuildInfo::GetInstance()->model())); | 361 base::ToLowerASCII(base::android::BuildInfo::GetInstance()->model())); |
| 367 if (model.find("a114") != std::string::npos) | 362 if (model.find("a114") != std::string::npos) |
| 368 surface_texture_detach_works = false; | 363 surface_texture_detach_works = false; |
| 369 } | 364 } |
| 370 } | 365 } |
| 371 | 366 |
| 372 return surface_texture_detach_works; | 367 return surface_texture_detach_works; |
| 373 } | 368 } |
| 374 | 369 |
| 375 } // namespace content | 370 } // namespace content |
| OLD | NEW |