From 3345a6884c488ff3a535c2c9acdd33d74b37e311 Mon Sep 17 00:00:00 2001 From: Iain Merrick Date: Tue, 19 Oct 2010 14:37:37 +0100 Subject: Merge Chromium at 7.0.540.0 : Initial merge by git Not including third_party/icu as it contains huge data files that break Gerrit, and aren't actually used. Change-Id: I428a386e70f3b58cacd28677b8cfda282e891e15 --- chrome/common/gpu_video_common.cc | 231 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 chrome/common/gpu_video_common.cc (limited to 'chrome/common/gpu_video_common.cc') diff --git a/chrome/common/gpu_video_common.cc b/chrome/common/gpu_video_common.cc new file mode 100644 index 0000000..556e385 --- /dev/null +++ b/chrome/common/gpu_video_common.cc @@ -0,0 +1,231 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/gpu_video_common.h" + +namespace IPC { + +void ParamTraits::Write( + Message* m, const GpuVideoServiceInfoParam& p) { + WriteParam(m, p.video_service_route_id); + WriteParam(m, p.video_service_host_route_id); + WriteParam(m, p.service_available); +} + +bool ParamTraits::Read( + const Message* m, void** iter, GpuVideoServiceInfoParam* r) { + if (!ReadParam(m, iter, &r->video_service_route_id) || + !ReadParam(m, iter, &r->video_service_host_route_id) || + !ReadParam(m, iter, &r->service_available)) + return false; + return true; +} + +void ParamTraits::Log( + const GpuVideoServiceInfoParam& p, std::string* l) { + l->append(StringPrintf("(%d, %d, %d)", + p.video_service_route_id, + p.video_service_host_route_id, + p.service_available)); +} + +/////////////////////////////////////////////////////////////////////////////// + +void ParamTraits::Write( + Message* m, const GpuVideoDecoderInfoParam& p) { + WriteParam(m, p.context_id); + WriteParam(m, p.decoder_id); + WriteParam(m, p.decoder_route_id); + WriteParam(m, p.decoder_host_route_id); +} + +bool ParamTraits::Read( + const Message* m, void** iter, GpuVideoDecoderInfoParam* r) { + if (!ReadParam(m, iter, &r->context_id) || + !ReadParam(m, iter, &r->decoder_id) || + !ReadParam(m, iter, &r->decoder_route_id) || + !ReadParam(m, iter, &r->decoder_host_route_id)) + return false; + return true; +} + +void ParamTraits::Log( + const GpuVideoDecoderInfoParam& p, std::string* l) { + l->append(StringPrintf("(%d, %d, %d)", + p.decoder_id, + p.decoder_route_id, + p.decoder_host_route_id)); +} + +/////////////////////////////////////////////////////////////////////////////// + +void ParamTraits::Write( + Message* m, const GpuVideoDecoderInitParam& p) { + WriteParam(m, p.codec_id); + WriteParam(m, p.width); + WriteParam(m, p.height); +} + +bool ParamTraits::Read( + const Message* m, void** iter, GpuVideoDecoderInitParam* r) { + if (!ReadParam(m, iter, &r->codec_id) || + !ReadParam(m, iter, &r->width) || + !ReadParam(m, iter, &r->height)) + return false; + return true; +} + +void ParamTraits::Log( + const GpuVideoDecoderInitParam& p, std::string* l) { + l->append(StringPrintf("(%d, %d %d)", p.codec_id, p.width, p.height)); +} + +/////////////////////////////////////////////////////////////////////////////// + +void ParamTraits::Write( + Message* m, const GpuVideoDecoderInitDoneParam& p) { + WriteParam(m, p.success); + WriteParam(m, p.input_buffer_size); + WriteParam(m, p.input_buffer_handle); +} + +bool ParamTraits::Read( + const Message* m, void** iter, GpuVideoDecoderInitDoneParam* r) { + if (!ReadParam(m, iter, &r->success) || + !ReadParam(m, iter, &r->input_buffer_size) || + !ReadParam(m, iter, &r->input_buffer_handle)) + return false; + return true; +} + +void ParamTraits::Log( + const GpuVideoDecoderInitDoneParam& p, std::string* l) { + l->append(StringPrintf("(%d %d)", p.success, p.input_buffer_size)); +} + +/////////////////////////////////////////////////////////////////////////////// + +void ParamTraits::Write( + Message* m, const GpuVideoDecoderInputBufferParam& p) { + WriteParam(m, p.timestamp); + WriteParam(m, p.offset); + WriteParam(m, p.size); +} + +bool ParamTraits::Read( + const Message* m, void** iter, GpuVideoDecoderInputBufferParam* r) { + if (!ReadParam(m, iter, &r->timestamp) || + !ReadParam(m, iter, &r->offset) || + !ReadParam(m, iter, &r->size)) + return false; + return true; +} + +void ParamTraits::Log( + const GpuVideoDecoderInputBufferParam& p, std::string* l) { + l->append(StringPrintf("(%d %d %d)", + static_cast(p.timestamp), + p.offset, p.size)); +} + +/////////////////////////////////////////////////////////////////////////////// + +void ParamTraits::Write( + Message* m, const GpuVideoDecoderErrorInfoParam& p) { + WriteParam(m, p.error_id); +} + +bool ParamTraits::Read( + const Message* m, void** iter, GpuVideoDecoderErrorInfoParam* r) { + if (!ReadParam(m, iter, &r->error_id)) + return false; + return true; +} + +void ParamTraits::Log( + const GpuVideoDecoderErrorInfoParam& p, std::string* l) { + l->append(StringPrintf("(%d)", p.error_id)); +} + +/////////////////////////////////////////////////////////////////////////////// + +void ParamTraits::Write( + Message* m, const GpuVideoDecoderFormatChangeParam& p) { + WriteParam(m, p.input_buffer_size); +} + +bool ParamTraits::Read( + const Message* m, void** iter, GpuVideoDecoderFormatChangeParam* r) { + if (!ReadParam(m, iter, &r->input_buffer_size)) + return false; + return true; +} + +void ParamTraits::Log( + const GpuVideoDecoderFormatChangeParam& p, std::string* l) { + l->append(StringPrintf("%d", p.input_buffer_size)); +} + +/////////////////////////////////////////////////////////////////////////////// +// Traits for media::VideoFrame::Format +void ParamTraits::Write( + Message* m, const param_type& p) { + m->WriteInt(p); +} + +bool ParamTraits::Read( + const Message* m, void** iter, param_type* p) { + int type; + if (!m->ReadInt(iter, &type)) + return false; + *p = static_cast(type); + return true; +} + +void ParamTraits::Log( + const param_type& p, std::string* l) { + std::string s; + switch (p) { + case media::VideoFrame::RGB555: + s = "RGB555"; + break; + case media::VideoFrame::RGB565: + s = "RGB565"; + break; + case media::VideoFrame::RGB24: + s = "RGB24"; + break; + case media::VideoFrame::RGB32: + s = "RGB32"; + break; + case media::VideoFrame::RGBA: + s = "RGBA"; + break; + case media::VideoFrame::YV12: + s = "YV12"; + break; + case media::VideoFrame::YV16: + s = "YV16"; + break; + case media::VideoFrame::NV12: + s = "NV12"; + break; + case media::VideoFrame::EMPTY: + s = "EMPTY"; + break; + case media::VideoFrame::ASCII: + s = "ASCII"; + break; + case media::VideoFrame::INVALID: + s = "INVALID"; + break; + default: + NOTIMPLEMENTED(); + s = "UNKNOWN"; + break; + } + LogParam(s, l); +} + +} // namespace IPC -- cgit v1.1