Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Side by Side Diff: content/common/gpu/media/android_copying_backing_strategy.cc

Issue 1892013002: ReleaseOutputBuffer to surface back and front buffers where possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanerer. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_copying_backing_strategy.h" 5 #include "content/common/gpu/media/android_copying_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/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "content/common/gpu/media/avda_return_on_failure.h" 10 #include "content/common/gpu/media/avda_return_on_failure.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 state_provider_->GetGlDecoder()->RestoreTextureUnitBindings(0); 49 state_provider_->GetGlDecoder()->RestoreTextureUnitBindings(0);
50 state_provider_->GetGlDecoder()->RestoreActiveTexture(); 50 state_provider_->GetGlDecoder()->RestoreActiveTexture();
51 51
52 surface_texture_ = gfx::SurfaceTexture::Create(surface_texture_id_); 52 surface_texture_ = gfx::SurfaceTexture::Create(surface_texture_id_);
53 53
54 return gfx::ScopedJavaSurface(surface_texture_.get()); 54 return gfx::ScopedJavaSurface(surface_texture_.get());
55 } 55 }
56 56
57 void AndroidCopyingBackingStrategy::Cleanup( 57 void AndroidCopyingBackingStrategy::Cleanup(
58 bool have_context, 58 bool have_context,
59 const AndroidVideoDecodeAccelerator::OutputBufferMap&) { 59 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) {
60 DCHECK(state_provider_->ThreadChecker().CalledOnValidThread()); 60 DCHECK(state_provider_->ThreadChecker().CalledOnValidThread());
61 61
62 if (copier_) 62 if (copier_)
63 copier_->Destroy(); 63 copier_->Destroy();
64 64
65 if (surface_texture_id_ && have_context) 65 if (surface_texture_id_ && have_context)
66 glDeleteTextures(1, &surface_texture_id_); 66 glDeleteTextures(1, &surface_texture_id_);
67 } 67 }
68 68
69 scoped_refptr<gfx::SurfaceTexture> 69 scoped_refptr<gfx::SurfaceTexture>
70 AndroidCopyingBackingStrategy::GetSurfaceTexture() const { 70 AndroidCopyingBackingStrategy::GetSurfaceTexture() const {
71 return surface_texture_; 71 return surface_texture_;
72 } 72 }
73 73
74 uint32_t AndroidCopyingBackingStrategy::GetTextureTarget() const { 74 uint32_t AndroidCopyingBackingStrategy::GetTextureTarget() const {
75 return GL_TEXTURE_2D; 75 return GL_TEXTURE_2D;
76 } 76 }
77 77
78 gfx::Size AndroidCopyingBackingStrategy::GetPictureBufferSize() const { 78 gfx::Size AndroidCopyingBackingStrategy::GetPictureBufferSize() const {
79 return state_provider_->GetSize(); 79 return state_provider_->GetSize();
80 } 80 }
81 81
82 void AndroidCopyingBackingStrategy::UseCodecBufferForPictureBuffer( 82 void AndroidCopyingBackingStrategy::UseCodecBufferForPictureBuffer(
83 int32_t codec_buf_index, 83 int32_t codec_buf_index,
84 const media::PictureBuffer& picture_buffer) { 84 const media::PictureBuffer& picture_buffer,
85 const std::vector<int32_t>& pictures_out_for_display) {
85 // Make sure that the decoder is available. 86 // Make sure that the decoder is available.
86 RETURN_ON_FAILURE(state_provider_, state_provider_->GetGlDecoder().get(), 87 RETURN_ON_FAILURE(state_provider_, state_provider_->GetGlDecoder().get(),
87 "Failed to get gles2 decoder instance.", ILLEGAL_STATE); 88 "Failed to get gles2 decoder instance.", ILLEGAL_STATE);
88 89
89 // Render the codec buffer into |surface_texture_|, and switch it to be 90 // Render the codec buffer into |surface_texture_|, and switch it to be
90 // the front buffer. 91 // the front buffer.
91 // This ignores the emitted ByteBuffer and instead relies on rendering to 92 // This ignores the emitted ByteBuffer and instead relies on rendering to
92 // the codec's SurfaceTexture and then copying from that texture to the 93 // the codec's SurfaceTexture and then copying from that texture to the
93 // client's PictureBuffer's texture. This means that each picture's data 94 // client's PictureBuffer's texture. This means that each picture's data
94 // is written three times: once to the ByteBuffer, once to the 95 // is written three times: once to the ByteBuffer, once to the
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 RETURN_IF_NULL(texture_ref); 183 RETURN_IF_NULL(texture_ref);
183 gpu::gles2::TextureManager* texture_manager = 184 gpu::gles2::TextureManager* texture_manager =
184 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); 185 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager();
185 RETURN_IF_NULL(texture_manager); 186 RETURN_IF_NULL(texture_manager);
186 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA, 187 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA,
187 new_size.width(), new_size.height(), 1, 0, 188 new_size.width(), new_size.height(), 1, 0,
188 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(new_size)); 189 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(new_size));
189 } 190 }
190 191
191 } // namespace content 192 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698