| 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 "media/gpu/android_copying_backing_strategy.h" | 5 #include "media/gpu/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 "gpu/command_buffer/service/context_group.h" | 10 #include "gpu/command_buffer/service/context_group.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 AndroidCopyingBackingStrategy::~AndroidCopyingBackingStrategy() {} | 27 AndroidCopyingBackingStrategy::~AndroidCopyingBackingStrategy() {} |
| 28 | 28 |
| 29 gfx::ScopedJavaSurface AndroidCopyingBackingStrategy::Initialize( | 29 gfx::ScopedJavaSurface AndroidCopyingBackingStrategy::Initialize( |
| 30 int surface_view_id) { | 30 int surface_view_id) { |
| 31 if (surface_view_id != media::VideoDecodeAccelerator::Config::kNoSurfaceID) { | 31 if (surface_view_id != media::VideoDecodeAccelerator::Config::kNoSurfaceID) { |
| 32 LOG(ERROR) << "The copying strategy should not be initialized with a " | 32 LOG(ERROR) << "The copying strategy should not be initialized with a " |
| 33 "surface id."; | 33 "surface id."; |
| 34 return gfx::ScopedJavaSurface(); | 34 return gfx::ScopedJavaSurface(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 // Create a texture and attach the SurfaceTexture to it. | 37 surface_texture_ = |
| 38 glGenTextures(1, &surface_texture_id_); | 38 state_provider_->CreateAttachedSurfaceTexture(&surface_texture_id_); |
| 39 glActiveTexture(GL_TEXTURE0); | |
| 40 glBindTexture(GL_TEXTURE_EXTERNAL_OES, surface_texture_id_); | |
| 41 | |
| 42 // Note that the target will be correctly sized, so nearest filtering is all | |
| 43 // that's needed. | |
| 44 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| 45 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
| 46 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 47 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 48 | |
| 49 state_provider_->GetGlDecoder()->RestoreTextureUnitBindings(0); | |
| 50 state_provider_->GetGlDecoder()->RestoreActiveTexture(); | |
| 51 | |
| 52 surface_texture_ = gfx::SurfaceTexture::Create(surface_texture_id_); | |
| 53 | |
| 54 return gfx::ScopedJavaSurface(surface_texture_.get()); | 39 return gfx::ScopedJavaSurface(surface_texture_.get()); |
| 55 } | 40 } |
| 56 | 41 |
| 57 void AndroidCopyingBackingStrategy::Cleanup( | 42 void AndroidCopyingBackingStrategy::Cleanup( |
| 58 bool have_context, | 43 bool have_context, |
| 59 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) { | 44 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) { |
| 60 DCHECK(state_provider_->ThreadChecker().CalledOnValidThread()); | 45 DCHECK(state_provider_->ThreadChecker().CalledOnValidThread()); |
| 61 | 46 |
| 62 if (copier_) | 47 if (copier_) |
| 63 copier_->Destroy(); | 48 copier_->Destroy(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 RETURN_IF_NULL(texture_ref); | 169 RETURN_IF_NULL(texture_ref); |
| 185 gpu::gles2::TextureManager* texture_manager = | 170 gpu::gles2::TextureManager* texture_manager = |
| 186 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); | 171 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); |
| 187 RETURN_IF_NULL(texture_manager); | 172 RETURN_IF_NULL(texture_manager); |
| 188 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA, | 173 texture_manager->SetLevelInfo(texture_ref, GetTextureTarget(), 0, GL_RGBA, |
| 189 new_size.width(), new_size.height(), 1, 0, | 174 new_size.width(), new_size.height(), 1, 0, |
| 190 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(new_size)); | 175 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(new_size)); |
| 191 } | 176 } |
| 192 | 177 |
| 193 } // namespace media | 178 } // namespace media |
| OLD | NEW |