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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "content/common/gpu/gpu_channel.h" | 11 #include "content/common/gpu/gpu_channel.h" |
12 #include "content/common/gpu/media/avda_codec_image.h" | 12 #include "content/common/gpu/media/avda_codec_image.h" |
13 #include "content/common/gpu/media/avda_return_on_failure.h" | 13 #include "content/common/gpu/media/avda_return_on_failure.h" |
14 #include "content/common/gpu/media/avda_shared_state.h" | 14 #include "content/common/gpu/media/avda_shared_state.h" |
15 #include "gpu/command_buffer/service/texture_manager.h" | 15 #include "gpu/command_buffer/service/texture_manager.h" |
16 #include "ui/gl/android/surface_texture.h" | 16 #include "ui/gl/android/surface_texture.h" |
17 #include "ui/gl/gl_bindings.h" | 17 #include "ui/gl/gl_bindings.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 // TODO(liberato): This is an entirely made-up number. It depends on how | |
22 // many decoded buffers that the MediaCodec is willing to have outstanding | |
23 // at any one time. Only one is guaranteed. crbug.com/531606. | |
24 enum { kNumPictureBuffers = 3 }; | |
25 | |
26 AndroidDeferredRenderingBackingStrategy:: | 21 AndroidDeferredRenderingBackingStrategy:: |
27 AndroidDeferredRenderingBackingStrategy() | 22 AndroidDeferredRenderingBackingStrategy() |
28 : state_provider_(nullptr), media_codec_(nullptr) {} | 23 : state_provider_(nullptr), media_codec_(nullptr) {} |
29 | 24 |
30 AndroidDeferredRenderingBackingStrategy:: | 25 AndroidDeferredRenderingBackingStrategy:: |
31 ~AndroidDeferredRenderingBackingStrategy() {} | 26 ~AndroidDeferredRenderingBackingStrategy() {} |
32 | 27 |
33 void AndroidDeferredRenderingBackingStrategy::Initialize( | 28 void AndroidDeferredRenderingBackingStrategy::Initialize( |
34 AVDAStateProvider* state_provider) { | 29 AVDAStateProvider* state_provider) { |
35 state_provider_ = state_provider; | 30 state_provider_ = state_provider; |
36 shared_state_ = new AVDASharedState(); | 31 shared_state_ = new AVDASharedState(); |
37 } | 32 } |
38 | 33 |
39 void AndroidDeferredRenderingBackingStrategy::Cleanup( | 34 void AndroidDeferredRenderingBackingStrategy::Cleanup( |
40 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) { | 35 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) { |
41 for (const std::pair<int, media::PictureBuffer>& entry : buffers) { | 36 for (const std::pair<int, media::PictureBuffer>& entry : buffers) { |
42 AVDACodecImage* avImage = GetImageForPicture(entry.second); | 37 AVDACodecImage* avImage = GetImageForPicture(entry.second); |
43 if (avImage) { | 38 if (avImage) { |
44 avImage->SetMediaCodecBufferIndex(-1); | 39 avImage->SetMediaCodecBufferIndex(-1); |
45 avImage->SetMediaCodec(nullptr); | 40 avImage->SetMediaCodec(nullptr); |
46 } | 41 } |
47 } | 42 } |
48 } | 43 } |
49 | 44 |
50 uint32 AndroidDeferredRenderingBackingStrategy::GetNumPictureBuffers() const { | |
51 return kNumPictureBuffers; | |
52 } | |
53 | |
54 uint32 AndroidDeferredRenderingBackingStrategy::GetTextureTarget() const { | 45 uint32 AndroidDeferredRenderingBackingStrategy::GetTextureTarget() const { |
55 return GL_TEXTURE_EXTERNAL_OES; | 46 return GL_TEXTURE_EXTERNAL_OES; |
56 } | 47 } |
57 | 48 |
58 scoped_refptr<gfx::SurfaceTexture> | 49 scoped_refptr<gfx::SurfaceTexture> |
59 AndroidDeferredRenderingBackingStrategy::CreateSurfaceTexture() { | 50 AndroidDeferredRenderingBackingStrategy::CreateSurfaceTexture() { |
60 // AVDACodecImage will handle attaching this to a texture later. | 51 // AVDACodecImage will handle attaching this to a texture later. |
61 surface_texture_ = gfx::SurfaceTexture::Create(0); | 52 surface_texture_ = gfx::SurfaceTexture::Create(0); |
62 // Detach from our GL context so that the GLImages can attach. It will | 53 // Detach from our GL context so that the GLImages can attach. It will |
63 // silently fail to delete texture 0. | 54 // silently fail to delete texture 0. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // doesn't know about them. | 178 // doesn't know about them. |
188 media_codec_ = codec; | 179 media_codec_ = codec; |
189 for (const std::pair<int, media::PictureBuffer>& entry : buffers) { | 180 for (const std::pair<int, media::PictureBuffer>& entry : buffers) { |
190 AVDACodecImage* avImage = GetImageForPicture(entry.second); | 181 AVDACodecImage* avImage = GetImageForPicture(entry.second); |
191 avImage->SetMediaCodec(codec); | 182 avImage->SetMediaCodec(codec); |
192 avImage->SetMediaCodecBufferIndex(-1); | 183 avImage->SetMediaCodecBufferIndex(-1); |
193 } | 184 } |
194 } | 185 } |
195 | 186 |
196 } // namespace content | 187 } // namespace content |
OLD | NEW |