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

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

Powered by Google App Engine
This is Rietveld 408576698