summaryrefslogtreecommitdiffstats
path: root/chromium/ppapi/api/dev/ppb_graphics_2d_dev.idl
blob: 28a844416a6eb863c955aa4ce046274e393406d4 (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
/* Copyright (c) 2012 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 contains the <code>PPB_Graphics2D_Dev</code> interface. */

[generate_thunk]

label Chrome {
  M22 = 0.1,
  M32 = 0.2
};

/**
 * These options affect how the existing graphics context is displayed when a
 * plugin is resized.
 */
[assert_size(4)]
enum PP_Graphics2D_Dev_ResizeMode {
  /**
   * In this mode, the context does not change size or offset. If the backing
   * store is the same size as the plugin element, this will result in the
   * pixels on the right side of the plugin element being unavailable, revealing
   * the contents underneath it.
   */
  PP_GRAPHICS2D_DEV_RESIZEMODE_DEFAULT,
  /**
   * In this mode, the context and its offset are scaled relative to how much
   * the plugin element has been resized.
   */
  PP_GRAPHICS2D_DEV_RESIZEMODE_STRETCH
};

/* PPB_Graphics2D_Dev interface */
interface PPB_Graphics2D_Dev {
  /**
   * SetScale() sets the scale factor that will be applied when painting the
   * graphics context onto the output device. Typically, if rendering at device
   * resolution is desired, the context would be created with the width and
   * height scaled up by the view's GetDeviceScale and SetScale called with a
   * scale of 1.0 / GetDeviceScale(). For example, if the view resource passed
   * to DidChangeView has a rectangle of (w=200, h=100) and a device scale of
   * 2.0, one would call Create with a size of (w=400, h=200) and then call
   * SetScale with 0.5. One would then treat each pixel in the context as a
   * single device pixel.
   *
   * @param[in] resource A <code>Graphics2D</code> context resource.
   * @param[in] scale The scale to apply when painting.
   *
   * @return Returns <code>PP_TRUE</code> on success or <code>PP_FALSE</code> if
   * the resource is invalid or the scale factor is 0 or less.
   */
  PP_Bool SetScale(
      [in] PP_Resource resource,
      [in] float_t scale);

  /***
   * GetScale() gets the scale factor that will be applied when painting the
   * graphics context onto the output device.
   *
   * @param[in] resource A <code>Graphics2D</code> context resource.
   *
   * @return Returns the scale factor for the graphics context. If the resource
   * is not a valid <code>Graphics2D</code> context, this will return 0.0.
   */
  float_t GetScale(
      [in] PP_Resource resource);

  /***
   * Sets the offset into the plugin element at which the graphics context is
   * painted. This allows a portion of the plugin element to be painted to.
   * The new offset will only be applied after Flush() has been called.
   *
   * @param[in] resource A <code>Graphics2D</code> context resource.
   * @param[in] offset The offset at which the context should be painted.
   */
  [version=0.2]
  void SetOffset(
      [in] PP_Resource resource,
      [in] PP_Point offset);

  /***
   * Sets the resize mode for the graphics context. When a plugin element is
   * resized in the DOM, it takes time for the plugin to update the graphics
   * context in the renderer. These options affect how the existing context is
   * displayed until the backing store is updated by the plugin.
   *
   * @param[in] resource A <code>Graphics2D</code> context resource.
   * @param[in] resize_mode The resize mode to change this context to.
   */
   void SetResizeMode(
       [in] PP_Resource resource,
       [in] PP_Graphics2D_Dev_ResizeMode resize_mode);
};