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" |
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/gpu_channel.h" | 15 #include "content/common/gpu/gpu_channel.h" |
16 #include "content/common/gpu/gpu_surface_lookup.h" | |
17 #include "content/common/gpu/media/avda_codec_image.h" | 16 #include "content/common/gpu/media/avda_codec_image.h" |
18 #include "content/common/gpu/media/avda_return_on_failure.h" | 17 #include "content/common/gpu/media/avda_return_on_failure.h" |
19 #include "content/common/gpu/media/avda_shared_state.h" | 18 #include "content/common/gpu/media/avda_shared_state.h" |
20 #include "gpu/command_buffer/service/context_group.h" | 19 #include "gpu/command_buffer/service/context_group.h" |
21 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 20 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
22 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 21 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
23 #include "gpu/command_buffer/service/texture_manager.h" | 22 #include "gpu/command_buffer/service/texture_manager.h" |
| 23 #include "gpu/ipc/common/gpu_surface_lookup.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 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) { |
42 shared_state_ = new AVDASharedState(); | 42 shared_state_ = new AVDASharedState(); |
43 | 43 |
44 // Create a texture for the SurfaceTexture to use. We don't attach it here | 44 // Create a texture for the SurfaceTexture to use. We don't attach it here |
45 // so that it gets attached in the compositor gl context in the common case. | 45 // so that it gets attached in the compositor gl context in the common case. |
46 GLuint service_id = 0; | 46 GLuint service_id = 0; |
47 glGenTextures(1, &service_id); | 47 glGenTextures(1, &service_id); |
48 DCHECK(service_id); | 48 DCHECK(service_id); |
49 shared_state_->set_surface_texture_service_id(service_id); | 49 shared_state_->set_surface_texture_service_id(service_id); |
50 | 50 |
51 gfx::ScopedJavaSurface surface; | 51 gfx::ScopedJavaSurface surface; |
52 if (surface_view_id != media::VideoDecodeAccelerator::Config::kNoSurfaceID) { | 52 if (surface_view_id != media::VideoDecodeAccelerator::Config::kNoSurfaceID) { |
53 surface = | 53 surface = gpu::GpuSurfaceLookup::GetInstance()->AcquireJavaSurface( |
54 GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_view_id); | 54 surface_view_id); |
55 } else { | 55 } else { |
56 if (DoesSurfaceTextureDetachWork()) { | 56 if (DoesSurfaceTextureDetachWork()) { |
57 // Create a detached SurfaceTexture. Detaching it will silently fail to | 57 // Create a detached SurfaceTexture. Detaching it will silently fail to |
58 // delete texture 0. | 58 // delete texture 0. |
59 surface_texture_ = gfx::SurfaceTexture::Create(0); | 59 surface_texture_ = gfx::SurfaceTexture::Create(0); |
60 surface_texture_->DetachFromGLContext(); | 60 surface_texture_->DetachFromGLContext(); |
61 } else { | 61 } else { |
62 // Detach doesn't work so well on all platforms. Just attach the | 62 // Detach doesn't work so well on all platforms. Just attach the |
63 // SurfaceTexture here, and probably context switch later. | 63 // SurfaceTexture here, and probably context switch later. |
64 surface_texture_ = gfx::SurfaceTexture::Create(service_id); | 64 surface_texture_ = gfx::SurfaceTexture::Create(service_id); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 base::ToLowerASCII(base::android::BuildInfo::GetInstance()->model())); | 361 base::ToLowerASCII(base::android::BuildInfo::GetInstance()->model())); |
362 if (model.find("a114") != std::string::npos) | 362 if (model.find("a114") != std::string::npos) |
363 surface_texture_detach_works = false; | 363 surface_texture_detach_works = false; |
364 } | 364 } |
365 } | 365 } |
366 | 366 |
367 return surface_texture_detach_works; | 367 return surface_texture_detach_works; |
368 } | 368 } |
369 | 369 |
370 } // namespace content | 370 } // namespace content |
OLD | NEW |