| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, tmp_texture_id); | 284 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, tmp_texture_id); |
| 294 // The target texture's size will exactly match the source. | 285 // The target texture's size will exactly match the source. |
| 295 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 286 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 296 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 287 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 297 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 288 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 298 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 289 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 299 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), 0, | 290 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), 0, |
| 300 GL_RGBA, GL_UNSIGNED_BYTE, nullptr); | 291 GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 301 } | 292 } |
| 302 | 293 |
| 303 // TODO(liberato,watk): Use the SurfaceTexture matrix when copying. | 294 |
| 295 |
| 296 float transform_matrix[16]; |
| 297 surface_texture_->GetTransformMatrix(transform_matrix); |
| 298 |
| 304 gpu::CopyTextureCHROMIUMResourceManager copier; | 299 gpu::CopyTextureCHROMIUMResourceManager copier; |
| 305 copier.Initialize( | 300 copier.Initialize( |
| 306 gl_decoder, | 301 gl_decoder, |
| 307 gl_decoder->GetContextGroup()->feature_info()->feature_flags()); | 302 gl_decoder->GetContextGroup()->feature_info()->feature_flags()); |
| 308 copier.DoCopyTextureWithTransform(gl_decoder, GL_TEXTURE_EXTERNAL_OES, | 303 copier.DoCopyTextureWithTransform(gl_decoder, GL_TEXTURE_EXTERNAL_OES, |
| 309 shared_state_->surface_texture_service_id(), | 304 shared_state_->surface_texture_service_id(), |
| 310 GL_TEXTURE_2D, tmp_texture_id, size.width(), | 305 GL_TEXTURE_2D, tmp_texture_id, size.width(), |
| 311 size.height(), false, false, false, | 306 size.height(), true, false, false, |
| 312 kIdentityMatrix); | 307 transform_matrix); |
| 313 | 308 |
| 314 // Create an EGLImage from the 2D texture we just copied into. By associating | 309 // Create an EGLImage from the 2D texture we just copied into. By associating |
| 315 // the EGLImage with the PictureBuffer textures they will remain valid even | 310 // the EGLImage with the PictureBuffer textures they will remain valid even |
| 316 // after we delete the 2D texture and EGLImage. | 311 // after we delete the 2D texture and EGLImage. |
| 317 const EGLImageKHR egl_image = eglCreateImageKHR( | 312 const EGLImageKHR egl_image = eglCreateImageKHR( |
| 318 gfx::GLSurfaceEGL::GetHardwareDisplay(), eglGetCurrentContext(), | 313 gfx::GLSurfaceEGL::GetHardwareDisplay(), eglGetCurrentContext(), |
| 319 EGL_GL_TEXTURE_2D_KHR, reinterpret_cast<EGLClientBuffer>(tmp_texture_id), | 314 EGL_GL_TEXTURE_2D_KHR, reinterpret_cast<EGLClientBuffer>(tmp_texture_id), |
| 320 nullptr /* attrs */); | 315 nullptr /* attrs */); |
| 321 | 316 |
| 322 glDeleteTextures(1, &tmp_texture_id); | 317 glDeleteTextures(1, &tmp_texture_id); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 surface_texture_detach_works = | 350 surface_texture_detach_works = |
| 356 !feature_info->workarounds().surface_texture_cant_detach; | 351 !feature_info->workarounds().surface_texture_cant_detach; |
| 357 } | 352 } |
| 358 } | 353 } |
| 359 } | 354 } |
| 360 | 355 |
| 361 return surface_texture_detach_works; | 356 return surface_texture_detach_works; |
| 362 } | 357 } |
| 363 | 358 |
| 364 } // namespace content | 359 } // namespace content |
| OLD | NEW |