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_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "media/video/video_decode_accelerator.h"
11 #include "media/video/video_encode_accelerator.h"
14 class SingleThreadTaskRunner;
22 // Helper interface for specifying factories needed to instantiate a hardware
25 // * The GpuVideoAcceleratorFactories may be constructed on any thread.
26 // * The GpuVideoAcceleratorFactories has an associated message loop, which may
27 // be retrieved as |GetMessageLoop()|.
28 // * All calls to the Factories after construction must be made on its message
30 class MEDIA_EXPORT GpuVideoAcceleratorFactories
31 : public base::RefCountedThreadSafe<GpuVideoAcceleratorFactories> {
33 // Caller owns returned pointer.
34 virtual scoped_ptr<VideoDecodeAccelerator> CreateVideoDecodeAccelerator(
35 VideoCodecProfile profile,
36 VideoDecodeAccelerator::Client* client) = 0;
38 // Caller owns returned pointer.
39 virtual scoped_ptr<VideoEncodeAccelerator> CreateVideoEncodeAccelerator(
40 VideoEncodeAccelerator::Client* client) = 0;
42 // Allocate & delete native textures.
43 virtual uint32 CreateTextures(int32 count,
44 const gfx::Size& size,
45 std::vector<uint32>* texture_ids,
46 std::vector<gpu::Mailbox>* texture_mailboxes,
47 uint32 texture_target) = 0;
48 virtual void DeleteTexture(uint32 texture_id) = 0;
50 virtual void WaitSyncPoint(uint32 sync_point) = 0;
52 // Read pixels within |visible_rect| boundaries from a native texture and
53 // store into |pixels| as RGBA.
54 virtual void ReadPixels(uint32 texture_id,
55 const gfx::Rect& visible_rect,
56 const SkBitmap& pixels) = 0;
58 // Allocate & return a shared memory segment. Caller is responsible for
59 // Close()ing the returned pointer.
60 virtual base::SharedMemory* CreateSharedMemory(size_t size) = 0;
62 // Returns the task runner the video accelerator runs on.
63 virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0;
66 friend class base::RefCountedThreadSafe<GpuVideoAcceleratorFactories>;
67 virtual ~GpuVideoAcceleratorFactories();
72 #endif // MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_