Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / media / filters / gpu_video_accelerator_factories.h
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.
4
5 #ifndef MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
6 #define MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
7
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"
12
13 namespace base {
14 class SingleThreadTaskRunner;
15 class SharedMemory;
16 }
17
18 class SkBitmap;
19
20 namespace media {
21
22 // Helper interface for specifying factories needed to instantiate a hardware
23 // video accelerator.
24 // Threading model:
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
29 //   loop.
30 class MEDIA_EXPORT GpuVideoAcceleratorFactories
31     : public base::RefCountedThreadSafe<GpuVideoAcceleratorFactories> {
32  public:
33   // Caller owns returned pointer.
34   virtual scoped_ptr<VideoDecodeAccelerator> CreateVideoDecodeAccelerator(
35       VideoCodecProfile profile,
36       VideoDecodeAccelerator::Client* client) = 0;
37
38   // Caller owns returned pointer.
39   virtual scoped_ptr<VideoEncodeAccelerator> CreateVideoEncodeAccelerator(
40       VideoEncodeAccelerator::Client* client) = 0;
41
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;
49
50   virtual void WaitSyncPoint(uint32 sync_point) = 0;
51
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;
57
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;
61
62   // Returns the task runner the video accelerator runs on.
63   virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0;
64
65  protected:
66   friend class base::RefCountedThreadSafe<GpuVideoAcceleratorFactories>;
67   virtual ~GpuVideoAcceleratorFactories();
68 };
69
70 }  // namespace media
71
72 #endif  // MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_