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_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
6 #define MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "gpu/command_buffer/common/mailbox.h"
13 #include "media/base/media_export.h"
14 #include "media/video/video_encode_accelerator.h"
19 class SingleThreadTaskRunner;
30 class VideoDecodeAccelerator;
32 // Helper interface for specifying factories needed to instantiate a hardware
35 // * The GpuVideoAcceleratorFactories may be constructed on any thread.
36 // * The GpuVideoAcceleratorFactories has an associated message loop, which may
37 // be retrieved as |GetMessageLoop()|.
38 // * All calls to the Factories after construction must be made on its message
40 class MEDIA_EXPORT GpuVideoAcceleratorFactories
41 : public base::RefCountedThreadSafe<GpuVideoAcceleratorFactories> {
43 // Caller owns returned pointer, but should call Destroy() on it (instead of
44 // directly deleting) for proper destruction, as per the
45 // VideoDecodeAccelerator interface.
46 virtual scoped_ptr<VideoDecodeAccelerator> CreateVideoDecodeAccelerator() = 0;
48 // Caller owns returned pointer, but should call Destroy() on it (instead of
49 // directly deleting) for proper destruction, as per the
50 // VideoEncodeAccelerator interface.
51 virtual scoped_ptr<VideoEncodeAccelerator> CreateVideoEncodeAccelerator() = 0;
53 // Allocate & delete native textures.
54 virtual bool CreateTextures(int32 count,
55 const gfx::Size& size,
56 std::vector<uint32>* texture_ids,
57 std::vector<gpu::Mailbox>* texture_mailboxes,
58 uint32 texture_target) = 0;
59 virtual void DeleteTexture(uint32 texture_id) = 0;
61 virtual void WaitSyncPoint(uint32 sync_point) = 0;
63 // Read pixels within |visible_rect| boundaries from a native texture and
64 // store into |pixels| as RGBA.
65 virtual void ReadPixels(uint32 texture_id,
66 const gfx::Rect& visible_rect,
67 const SkBitmap& pixels) = 0;
69 // Allocate & return a shared memory segment. Caller is responsible for
70 // Close()ing the returned pointer.
71 virtual base::SharedMemory* CreateSharedMemory(size_t size) = 0;
73 // Returns the task runner the video accelerator runs on.
74 virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0;
76 // Returns the supported codec profiles of video encode accelerator.
77 virtual std::vector<VideoEncodeAccelerator::SupportedProfile>
78 GetVideoEncodeAcceleratorSupportedProfiles() = 0;
81 friend class base::RefCountedThreadSafe<GpuVideoAcceleratorFactories>;
82 virtual ~GpuVideoAcceleratorFactories();
87 #endif // MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_