summaryrefslogtreecommitdiffstats
path: root/ppapi/api/dev/ppb_video_layer_dev.idl
blob: 1ec50ec6444c5158aaea28444e274bd682220649 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* Copyright (c) 2011 The Chromium Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/**
 * This file defines the <code>PPB_VideoDecoder_Dev</code> interface.
 */
label Chrome {
  M14 = 0.1
};

/**
 * Enumeration for pixel format of the video layer.
 */
[assert_size(4)]
enum PP_VideoLayerPixelFormat_Dev {
  PP_VIDEOLAYERPIXELFORMAT_RGBA = 0,
  PP_VIDEOLAYERPIXELFORMAT_YV12 = 1
};

/** TODO(hclam): Add options to customize color conversion. */

/**
 * Enumeration for operation mode of the video layer.
 * PPB_VideoLayer_Dev needs to be created with one of these enums in order to
 * determine the operation mode.
 */
[assert_size(4)]
enum PP_VideoLayerMode_Dev {
  /**
   * In this mode user needs to update content of the video layer manually by
   * calling UpdateContent().
   */
  PP_VIDEOLAYERMODE_SOFTWARE = 0,

  /**
   * In this mode content of the video layer is updated by a hardware video
   * decoder, calling UpdateContent() will always return PP_FALSE.
   */
  PP_VIDEOLAYERMODE_HARDWARE = 1
};

/**
 * PPB_VideoLayer is a mechanism to enhance rendering performance of video
 * content. Rendering is generally done by using PPB_Graphics3D or
 * PPB_Graphics2D, however for video content it is redundant to go through
 * PPB_Graphics3D or PPB_Graphics2D. PPB_VideoLayer allows video content to be
 * rendered directly.
 *
 * PPB_VideoLayer can be used in two modes:
 *
 * Software Decoding Mode
 * In this mode the video layer needs to be updated with system memory manually
 * using UpdateContent().
 *
 * Hardware Decoding Mode
 * In this mode the content of the video layer is updated by a hardware video
 * decoder.
 */
interface PPB_VideoLayer_Dev {
  /**
   * Creates a video layer.
   */
  PP_Resource Create(
      [in] PP_Instance instance,
      [in] PP_VideoLayerMode_Dev mode);

  /**
   * Returns true if the input parameter is a video layer.
   */
  PP_Bool IsVideoLayer(
      [in] PP_Resource layer);

  /**
   * Set the pixel format of this video layer. By default it is RGBA.
   *
   * This method must be called before the video layer can be displayed.
   *
   * The updated size will be effective after SwapBuffers() is called.
   */
  void SetPixelFormat(
      [in] PP_Resource layer,
      [in] PP_VideoLayerPixelFormat_Dev pixel_format);

  /**
   * Set the native size of the video layer. This method must be called before
   * the video layer can be displayed.
   *
   * The updated size will be effective after SwapBuffers() is called.
   */
  void SetNativeSize(
      [in] PP_Resource layer,
      [in] PP_Size size);

  /**
   * Set the clipping rectangle for this video layer relative to the native
   * size. Only content within this rect is displayed.
   *
   * The clip rectangle will be effective after SwapBuffers() is called.
   */
  void SetClipRect(
      [in] PP_Resource layer,
      [in] PP_Rect clip_rect);

  /**
   * Return PP_TRUE if this video layer can be displayed. If this returns
   * PP_FALSE it can mean that the size is unknown or the video layer doesn't
   * have video memory allocated or not initialized.
   */
  PP_Bool IsReady(
      [in] PP_Resource layer);

  /**
   * Update the content of a video layer from system memory. SetNativeSize()
   * must be called before making this method call.
   *
   * NOTE: This method has no effect in hardware decoding mode.
   *
   * |no_of_planes| is the number of planes in |planes|.
   * |planes| is an array of memory planes to be uploaded.
   *
   * Number of planes and format for planes is based on pixel format.
   *
   * PP_VIDEOLAYERPIXELFORMAT_RGBA:
   *
   * There will be one memory plane in RGBA format.
   *
   * planes[0] - RGBA plane, packed
   *
   * PP_VIDEOLAYERPIXELFORMAT_YV12:
   *
   * There will be three planes. In the order of Y, U and V. U and V planes
   * are 2x2 subsampled.
   *
   * planes[0] - Y plane
   * planes[1] - U plane, 2x2 subsampled
   * planes[2] - V plane, 2x2 subsampled
   *
   * Return true if successful.
   */
  PP_Bool UpdateContent(
      [in] PP_Resource layer,
      [in] uint32_t no_of_planes,
      [in, size_as=no_of_planes] mem_t[] planes);
};