1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_RENDERERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
6 #define MEDIA_RENDERERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "gpu/command_buffer/client/gles2_interface.h"
13 #include "gpu/command_buffer/common/mailbox.h"
14 #include "media/base/media_export.h"
15 #include "media/video/video_decode_accelerator.h"
16 #include "media/video/video_encode_accelerator.h"
17 #include "ui/gfx/gpu_memory_buffer.h"
20 class SingleThreadTaskRunner
;
31 class VideoDecodeAccelerator
;
33 // Helper interface for specifying factories needed to instantiate a hardware
36 // * The GpuVideoAcceleratorFactories may be constructed on any thread.
37 // * The GpuVideoAcceleratorFactories has an associated message loop, which may
38 // be retrieved as |GetMessageLoop()|.
39 // * All calls to the Factories after construction must be made on its message
41 class MEDIA_EXPORT GpuVideoAcceleratorFactories
42 : public base::RefCountedThreadSafe
<GpuVideoAcceleratorFactories
> {
44 // Caller owns returned pointer, but should call Destroy() on it (instead of
45 // directly deleting) for proper destruction, as per the
46 // VideoDecodeAccelerator interface.
47 virtual scoped_ptr
<VideoDecodeAccelerator
> CreateVideoDecodeAccelerator() = 0;
49 // Caller owns returned pointer, but should call Destroy() on it (instead of
50 // directly deleting) for proper destruction, as per the
51 // VideoEncodeAccelerator interface.
52 virtual scoped_ptr
<VideoEncodeAccelerator
> CreateVideoEncodeAccelerator() = 0;
54 // Allocate & delete native textures.
55 virtual bool CreateTextures(int32 count
,
56 const gfx::Size
& size
,
57 std::vector
<uint32
>* texture_ids
,
58 std::vector
<gpu::Mailbox
>* texture_mailboxes
,
59 uint32 texture_target
) = 0;
60 virtual void DeleteTexture(uint32 texture_id
) = 0;
62 virtual void WaitSyncPoint(uint32 sync_point
) = 0;
64 virtual scoped_ptr
<gfx::GpuMemoryBuffer
> AllocateGpuMemoryBuffer(
65 const gfx::Size
& size
,
66 gfx::GpuMemoryBuffer::Format format
,
67 gfx::GpuMemoryBuffer::Usage usage
) = 0;
69 virtual bool IsTextureRGSupported() = 0;
71 virtual gpu::gles2::GLES2Interface
* GetGLES2Interface() = 0;
73 // Allocate & return a shared memory segment.
74 virtual scoped_ptr
<base::SharedMemory
> CreateSharedMemory(size_t size
) = 0;
76 // Returns the task runner the video accelerator runs on.
77 virtual scoped_refptr
<base::SingleThreadTaskRunner
> GetTaskRunner() = 0;
79 // Returns the supported codec profiles of video decode accelerator.
80 virtual VideoDecodeAccelerator::SupportedProfiles
81 GetVideoDecodeAcceleratorSupportedProfiles() = 0;
83 // Returns the supported codec profiles of video encode accelerator.
84 virtual VideoEncodeAccelerator::SupportedProfiles
85 GetVideoEncodeAcceleratorSupportedProfiles() = 0;
88 friend class base::RefCountedThreadSafe
<GpuVideoAcceleratorFactories
>;
89 virtual ~GpuVideoAcceleratorFactories() {}
94 #endif // MEDIA_RENDERERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_