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

Side by Side Diff: content/common/gpu/client/gpu_jpeg_decode_accelerator_host.cc

Issue 1645873002: Use ParamTraits for media::BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compiling errors on mac and address review comments Created 4 years, 10 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/client/gpu_jpeg_decode_accelerator_host.h" 5 #include "content/common/gpu/client/gpu_jpeg_decode_accelerator_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 void GpuJpegDecodeAcceleratorHost::Decode( 146 void GpuJpegDecodeAcceleratorHost::Decode(
147 const media::BitstreamBuffer& bitstream_buffer, 147 const media::BitstreamBuffer& bitstream_buffer,
148 const scoped_refptr<media::VideoFrame>& video_frame) { 148 const scoped_refptr<media::VideoFrame>& video_frame) {
149 DCHECK(CalledOnValidThread()); 149 DCHECK(CalledOnValidThread());
150 150
151 DCHECK( 151 DCHECK(
152 base::SharedMemory::IsHandleValid(video_frame->shared_memory_handle())); 152 base::SharedMemory::IsHandleValid(video_frame->shared_memory_handle()));
153 153
154 AcceleratedJpegDecoderMsg_Decode_Params decode_params;
155 decode_params.input_buffer = bitstream_buffer;
154 base::SharedMemoryHandle input_handle = 156 base::SharedMemoryHandle input_handle =
155 channel_->ShareToGpuProcess(bitstream_buffer.handle()); 157 channel_->ShareToGpuProcess(bitstream_buffer.handle());
156 if (!base::SharedMemory::IsHandleValid(input_handle)) { 158 if (!base::SharedMemory::IsHandleValid(input_handle)) {
157 DLOG(ERROR) << "Failed to duplicate handle of BitstreamBuffer"; 159 DLOG(ERROR) << "Failed to duplicate handle of BitstreamBuffer";
158 return; 160 return;
159 } 161 }
162 decode_params.input_buffer.set_handle(input_handle);
160 base::SharedMemoryHandle output_handle = 163 base::SharedMemoryHandle output_handle =
161 channel_->ShareToGpuProcess(video_frame->shared_memory_handle()); 164 channel_->ShareToGpuProcess(video_frame->shared_memory_handle());
162 if (!base::SharedMemory::IsHandleValid(output_handle)) { 165 if (!base::SharedMemory::IsHandleValid(output_handle)) {
163 DLOG(ERROR) << "Failed to duplicate handle of VideoFrame"; 166 DLOG(ERROR) << "Failed to duplicate handle of VideoFrame";
164 #if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) 167 #if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS))
165 if (input_handle.auto_close) { 168 if (input_handle.auto_close) {
166 // Defer closing task to the ScopedFD. 169 // Defer closing task to the ScopedFD.
167 base::ScopedFD(input_handle.fd); 170 base::ScopedFD(input_handle.fd);
168 } 171 }
169 #else 172 #else
170 // TODO(kcwu) fix the handle leak after crbug.com/493414 resolved. 173 // TODO(kcwu) fix the handle leak after crbug.com/493414 resolved.
171 #endif 174 #endif
172 return; 175 return;
173 } 176 }
174 177
175 size_t output_buffer_size = media::VideoFrame::AllocationSize( 178 size_t output_buffer_size = media::VideoFrame::AllocationSize(
176 video_frame->format(), video_frame->coded_size()); 179 video_frame->format(), video_frame->coded_size());
177 180
178 AcceleratedJpegDecoderMsg_Decode_Params decode_params;
179 decode_params.coded_size = video_frame->coded_size(); 181 decode_params.coded_size = video_frame->coded_size();
180 decode_params.input_buffer_id = bitstream_buffer.id();
181 decode_params.input_buffer_handle = input_handle;
182 decode_params.input_buffer_size = bitstream_buffer.size();
183 decode_params.output_video_frame_handle = output_handle; 182 decode_params.output_video_frame_handle = output_handle;
184 decode_params.output_buffer_size = output_buffer_size; 183 decode_params.output_buffer_size = output_buffer_size;
185 Send(new AcceleratedJpegDecoderMsg_Decode(decoder_route_id_, decode_params)); 184 Send(new AcceleratedJpegDecoderMsg_Decode(decoder_route_id_, decode_params));
186 } 185 }
187 186
188 bool GpuJpegDecodeAcceleratorHost::IsSupported() { 187 bool GpuJpegDecodeAcceleratorHost::IsSupported() {
189 return channel_->gpu_info().jpeg_decode_accelerator_supported; 188 return channel_->gpu_info().jpeg_decode_accelerator_supported;
190 } 189 }
191 190
192 void GpuJpegDecodeAcceleratorHost::Send(IPC::Message* message) { 191 void GpuJpegDecodeAcceleratorHost::Send(IPC::Message* message) {
193 DCHECK(CalledOnValidThread()); 192 DCHECK(CalledOnValidThread());
194 193
195 if (!channel_->Send(message)) { 194 if (!channel_->Send(message)) {
196 DLOG(ERROR) << "Send(" << message->type() << ") failed"; 195 DLOG(ERROR) << "Send(" << message->type() << ") failed";
197 } 196 }
198 } 197 }
199 198
200 base::WeakPtr<IPC::Listener> GpuJpegDecodeAcceleratorHost::GetReceiver() { 199 base::WeakPtr<IPC::Listener> GpuJpegDecodeAcceleratorHost::GetReceiver() {
201 return receiver_->AsWeakPtrForIO(); 200 return receiver_->AsWeakPtrForIO();
202 } 201 }
203 202
204 } // namespace content 203 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698