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 // Return whether GPU encoding/decoding is enabled.
45 virtual bool IsGpuVideoAcceleratorEnabled() = 0;
46 // Caller owns returned pointer, but should call Destroy() on it (instead of
47 // directly deleting) for proper destruction, as per the
48 // VideoDecodeAccelerator interface.
49 virtual scoped_ptr
<VideoDecodeAccelerator
> CreateVideoDecodeAccelerator() = 0;
51 // Caller owns returned pointer, but should call Destroy() on it (instead of
52 // directly deleting) for proper destruction, as per the
53 // VideoEncodeAccelerator interface.
54 virtual scoped_ptr
<VideoEncodeAccelerator
> CreateVideoEncodeAccelerator() = 0;
56 // Allocate & delete native textures.
57 virtual bool CreateTextures(int32 count
,
58 const gfx::Size
& size
,
59 std::vector
<uint32
>* texture_ids
,
60 std::vector
<gpu::Mailbox
>* texture_mailboxes
,
61 uint32 texture_target
) = 0;
62 virtual void DeleteTexture(uint32 texture_id
) = 0;
64 virtual void WaitSyncPoint(uint32 sync_point
) = 0;
66 virtual scoped_ptr
<gfx::GpuMemoryBuffer
> AllocateGpuMemoryBuffer(
67 const gfx::Size
& size
,
68 gfx::BufferFormat format
,
69 gfx::BufferUsage usage
) = 0;
71 virtual unsigned ImageTextureTarget() = 0;
72 virtual bool IsTextureRGSupported() = 0;
74 virtual gpu::gles2::GLES2Interface
* GetGLES2Interface() = 0;
76 // Allocate & return a shared memory segment.
77 virtual scoped_ptr
<base::SharedMemory
> CreateSharedMemory(size_t size
) = 0;
79 // Returns the task runner the video accelerator runs on.
80 virtual scoped_refptr
<base::SingleThreadTaskRunner
> GetTaskRunner() = 0;
82 // Returns the supported codec profiles of video decode accelerator.
83 virtual VideoDecodeAccelerator::SupportedProfiles
84 GetVideoDecodeAcceleratorSupportedProfiles() = 0;
86 // Returns the supported codec profiles of video encode accelerator.
87 virtual VideoEncodeAccelerator::SupportedProfiles
88 GetVideoEncodeAcceleratorSupportedProfiles() = 0;
91 friend class base::RefCountedThreadSafe
<GpuVideoAcceleratorFactories
>;
92 virtual ~GpuVideoAcceleratorFactories() {}
97 #endif // MEDIA_RENDERERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_