Chromium Code Reviews| Index: content/common/gpu/media/gpu_jpeg_decode_accelerator.h |
| diff --git a/content/common/gpu/media/gpu_jpeg_decode_accelerator.h b/content/common/gpu/media/gpu_jpeg_decode_accelerator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..99e11f1359db9f2970c6095aa62ed72670497c9f |
| --- /dev/null |
| +++ b/content/common/gpu/media/gpu_jpeg_decode_accelerator.h |
| @@ -0,0 +1,99 @@ |
| +// Copyright 2015 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. |
| + |
| +#ifndef CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ |
| +#define CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ |
| + |
| +#include <map> |
| +#include <vector> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/shared_memory.h" |
| +#include "base/synchronization/waitable_event.h" |
| +#include "ipc/ipc_listener.h" |
| +#include "ipc/ipc_sender.h" |
| +#include "media/video/jpeg_decode_accelerator.h" |
| +#include "ui/gfx/geometry/size.h" |
| + |
| +struct AcceleratedJpegDecoderMsg_Decode_Params; |
| + |
| +namespace base { |
| +class MessageLoopProxy; |
| +} |
| + |
| +namespace content { |
| +class GpuChannel; |
| + |
| +class GpuJpegDecodeAccelerator |
| + : public IPC::Listener, |
| + public IPC::Sender, |
| + public media::JpegDecodeAccelerator::Client { |
| + public: |
| + // Each of the arguments to the constructor must outlive this object. |
| + // |stub->decoder()| will be made current around any operation that touches |
| + // the underlying VDA so that it can make GL calls safely. |
| + GpuJpegDecodeAccelerator( |
| + GpuChannel* channel, |
| + int32 host_route_id, |
| + const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
| + |
| + // IPC::Listener implementation. |
| + bool OnMessageReceived(const IPC::Message& message) override; |
| + |
| + // media::JpegDecodeAccelerator::Client implementation. |
| + void VideoFrameReady(int32_t bitstream_buffer_id) override; |
| + void NotifyError(int32_t bitstream_buffer_id, |
| + media::JpegDecodeAccelerator::Error error) override; |
| + |
| + |
| + // Function to delegate sending to actual sender. |
| + bool Send(IPC::Message* message) override; |
| + |
| + bool Initialize(); |
| + |
| + private: |
| + class MessageFilter; |
| + |
| + // We only allow self-delete, from OnWillDestroyStub(), after cleanup there. |
| + ~GpuJpegDecodeAccelerator() override; |
| + |
| + // Handlers for IPC messages. |
| + void OnDecode(const AcceleratedJpegDecoderMsg_Decode_Params& params); |
| + void OnDestroy(); |
| + |
| + |
| + // Called on IO thread when |filter_| has been removed. |
| + void OnFilterRemoved(); |
| + |
| + // The lifetime of objects of this class is managed by a GpuChannel. The |
| + // GpuChannels destroy all the GpuCommandBufferStubs that they own when they |
| + // are destroyed. So a raw pointer is safe. |
| + GpuChannel* channel_; |
| + |
| + // Route ID to communicate with the host. |
| + int32 host_route_id_; |
| + |
| + // The underlying JpegDecodeAccelerator. |
| + scoped_ptr<media::JpegDecodeAccelerator> jpeg_decode_accelerator_; |
| + |
| + // The message filter to run VDA::Decode on IO thread if VDA supports it. |
|
wuchengli
2015/03/23 06:30:15
update the comment
kcwu
2015/04/14 20:02:34
Done.
|
| + scoped_refptr<MessageFilter> filter_; |
| + |
| + // Used to wait on for |filter_| to be removed, before we can safely |
| + // destroy the VDA. |
| + base::WaitableEvent filter_removed_; |
| + |
| + // GPU child message loop. |
| + scoped_refptr<base::MessageLoopProxy> child_message_loop_; |
| + |
| + // GPU IO message loop. |
| + scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| + |
| + DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ |