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

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

Issue 1845563005: Refactor content/common/gpu into gpu/ipc/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop ref to deleted content_tests_gypi_values.content_unittests_ozone_sources 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gpu_video_decode_accelerator.h" 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "content/common/gpu/gpu_channel.h"
18 #include "content/common/gpu/gpu_channel_manager.h"
19 #include "content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h" 17 #include "content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h"
20 #include "gpu/command_buffer/common/command_buffer.h" 18 #include "gpu/command_buffer/common/command_buffer.h"
19 #include "gpu/command_buffer/service/gpu_preferences.h"
20 #include "gpu/ipc/service/gpu_channel.h"
21 #include "gpu/ipc/service/gpu_channel_manager.h"
21 #include "ipc/ipc_message_macros.h" 22 #include "ipc/ipc_message_macros.h"
22 #include "ipc/ipc_message_utils.h" 23 #include "ipc/ipc_message_utils.h"
23 #include "ipc/message_filter.h" 24 #include "ipc/message_filter.h"
24 #include "media/base/limits.h" 25 #include "media/base/limits.h"
26 #include "media/gpu/ipc/common/gpu_video_accelerator_util.h"
25 #include "media/gpu/ipc/common/media_messages.h" 27 #include "media/gpu/ipc/common/media_messages.h"
26 #include "ui/gfx/geometry/size.h" 28 #include "ui/gfx/geometry/size.h"
27 #include "ui/gl/gl_context.h" 29 #include "ui/gl/gl_context.h"
28 #include "ui/gl/gl_image.h" 30 #include "ui/gl/gl_image.h"
29 31
30 namespace content { 32 namespace content {
31 33
32 namespace { 34 namespace {
33 static gfx::GLContext* GetGLContext( 35 static gfx::GLContext* GetGLContext(
34 const base::WeakPtr<GpuCommandBufferStub>& stub) { 36 const base::WeakPtr<gpu::GpuCommandBufferStub>& stub) {
35 if (!stub) { 37 if (!stub) {
36 DLOG(ERROR) << "Stub is gone; no GLContext."; 38 DLOG(ERROR) << "Stub is gone; no GLContext.";
37 return nullptr; 39 return nullptr;
38 } 40 }
39 41
40 return stub->decoder()->GetGLContext(); 42 return stub->decoder()->GetGLContext();
41 } 43 }
42 44
43 static bool MakeDecoderContextCurrent( 45 static bool MakeDecoderContextCurrent(
44 const base::WeakPtr<GpuCommandBufferStub>& stub) { 46 const base::WeakPtr<gpu::GpuCommandBufferStub>& stub) {
45 if (!stub) { 47 if (!stub) {
46 DLOG(ERROR) << "Stub is gone; won't MakeCurrent()."; 48 DLOG(ERROR) << "Stub is gone; won't MakeCurrent().";
47 return false; 49 return false;
48 } 50 }
49 51
50 if (!stub->decoder()->MakeCurrent()) { 52 if (!stub->decoder()->MakeCurrent()) {
51 DLOG(ERROR) << "Failed to MakeCurrent()"; 53 DLOG(ERROR) << "Failed to MakeCurrent()";
52 return false; 54 return false;
53 } 55 }
54 56
55 return true; 57 return true;
56 } 58 }
57 59
58 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) 60 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
59 static bool BindImage(const base::WeakPtr<GpuCommandBufferStub>& stub, 61 static bool BindImage(const base::WeakPtr<gpu::GpuCommandBufferStub>& stub,
60 uint32_t client_texture_id, 62 uint32_t client_texture_id,
61 uint32_t texture_target, 63 uint32_t texture_target,
62 const scoped_refptr<gl::GLImage>& image, 64 const scoped_refptr<gl::GLImage>& image,
63 bool can_bind_to_sampler) { 65 bool can_bind_to_sampler) {
64 if (!stub) { 66 if (!stub) {
65 DLOG(ERROR) << "Stub is gone; won't BindImage()."; 67 DLOG(ERROR) << "Stub is gone; won't BindImage().";
66 return false; 68 return false;
67 } 69 }
68 70
69 gpu::gles2::GLES2Decoder* command_decoder = stub->decoder(); 71 gpu::gles2::GLES2Decoder* command_decoder = stub->decoder();
70 gpu::gles2::TextureManager* texture_manager = 72 gpu::gles2::TextureManager* texture_manager =
71 command_decoder->GetContextGroup()->texture_manager(); 73 command_decoder->GetContextGroup()->texture_manager();
72 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id); 74 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id);
73 if (ref) { 75 if (ref) {
74 texture_manager->SetLevelImage(ref, texture_target, 0, image.get(), 76 texture_manager->SetLevelImage(ref, texture_target, 0, image.get(),
75 can_bind_to_sampler 77 can_bind_to_sampler
76 ? gpu::gles2::Texture::BOUND 78 ? gpu::gles2::Texture::BOUND
77 : gpu::gles2::Texture::UNBOUND); 79 : gpu::gles2::Texture::UNBOUND);
78 } 80 }
79 81
80 return true; 82 return true;
81 } 83 }
82 #endif 84 #endif
83 85
84 static base::WeakPtr<gpu::gles2::GLES2Decoder> GetGLES2Decoder( 86 static base::WeakPtr<gpu::gles2::GLES2Decoder> GetGLES2Decoder(
85 const base::WeakPtr<GpuCommandBufferStub>& stub) { 87 const base::WeakPtr<gpu::GpuCommandBufferStub>& stub) {
86 if (!stub) { 88 if (!stub) {
87 DLOG(ERROR) << "Stub is gone; no GLES2Decoder."; 89 DLOG(ERROR) << "Stub is gone; no GLES2Decoder.";
88 return base::WeakPtr<gpu::gles2::GLES2Decoder>(); 90 return base::WeakPtr<gpu::gles2::GLES2Decoder>();
89 } 91 }
90 92
91 return stub->decoder()->AsWeakPtr(); 93 return stub->decoder()->AsWeakPtr();
92 } 94 }
93 } // anonymous namespace 95 } // anonymous namespace
94 96
95 // DebugAutoLock works like AutoLock but only acquires the lock when 97 // DebugAutoLock works like AutoLock but only acquires the lock when
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 147
146 private: 148 private:
147 GpuVideoDecodeAccelerator* const owner_; 149 GpuVideoDecodeAccelerator* const owner_;
148 const int32_t host_route_id_; 150 const int32_t host_route_id_;
149 // The sender to which this filter was added. 151 // The sender to which this filter was added.
150 IPC::Sender* sender_; 152 IPC::Sender* sender_;
151 }; 153 };
152 154
153 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( 155 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator(
154 int32_t host_route_id, 156 int32_t host_route_id,
155 GpuCommandBufferStub* stub, 157 gpu::GpuCommandBufferStub* stub,
156 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) 158 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
157 : host_route_id_(host_route_id), 159 : host_route_id_(host_route_id),
158 stub_(stub), 160 stub_(stub),
159 texture_target_(0), 161 texture_target_(0),
160 textures_per_buffer_(0), 162 textures_per_buffer_(0),
161 filter_removed_(true, false), 163 filter_removed_(true, false),
162 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), 164 child_task_runner_(base::ThreadTaskRunnerHandle::Get()),
163 io_task_runner_(io_task_runner), 165 io_task_runner_(io_task_runner),
164 weak_factory_for_io_(this) { 166 weak_factory_for_io_(this) {
165 DCHECK(stub_); 167 DCHECK(stub_);
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; 513 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second;
512 GLenum target = texture_ref->texture()->target(); 514 GLenum target = texture_ref->texture()->target();
513 gpu::gles2::TextureManager* texture_manager = 515 gpu::gles2::TextureManager* texture_manager =
514 stub_->decoder()->GetContextGroup()->texture_manager(); 516 stub_->decoder()->GetContextGroup()->texture_manager();
515 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); 517 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0));
516 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); 518 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true);
517 uncleared_textures_.erase(it); 519 uncleared_textures_.erase(it);
518 } 520 }
519 521
520 } // namespace content 522 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698