summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/canvas/htmlcanvas/canvas_context_creation_attributes_module.idl
blob: 21324b678ac17f2fd09e5f86cbaff07a3a11b18b (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
// Copyright 2014 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.

// The spec for HTMLCanvasElement.getContext() defines the context
// creation attributes as type "any". In order to eliminate custom
// bindings for getContext(), we define a dictionary that contains the
// union of all of the context types' attributes. Note that it is not
// possible to use a union type for this purpose because two dictionary
// types are not distinguishable.
//
// Fortunately, there aren't any context creation attributes which are
// defined with different default values in different context
// specifications. (The "alpha" value, in particular, has a default
// value of true for both the Canvas2D and WebGL specifications.)
//
// The PermissiveDictionaryConversion extended attribute ignores
// non-object types (like 'true' and 'false') passed to getContext() for
// the attributes instead of raising TypeError, following the behavior
// of the previous custom binding.
//
// N.B.: Web IDL doesn't support multiple inheritance of dictionaries.

enum CanvasPixelFormat {
    "uint8", // default
    "10-10-10-2",
    "12-12-12-12",
    "float16",
};

enum CanvasPowerPreference {
    "default",
    "low-power",
    "high-performance",
};

[PermissiveDictionaryConversion]
dictionary CanvasContextCreationAttributesModule {
    // This is an experimental feature, but it is not hidden behind a flag in
    // the bindings because origin trial bindings don't work in extensions.
    // The trial's runtime flag is instead checked inside
    // HTMLCanvasElement.getContext().
    [RuntimeEnabled=SurfaceEmbeddingFeatures] boolean desynchronized = false;

    // Canvas 2D attributes
    boolean alpha = true;  // Also used for WebGL.
    [RuntimeEnabled=CanvasColorManagement] CanvasColorSpace colorSpace = "srgb";
    [RuntimeEnabled=CanvasColorManagement] CanvasPixelFormat pixelFormat = "uint8";

    // WebGL attributes
    boolean depth = true;
    boolean stencil = false;
    boolean antialias = true;
    boolean premultipliedAlpha = true;
    boolean preserveDrawingBuffer = false;
    CanvasPowerPreference powerPreference = "default";
    boolean failIfMajorPerformanceCaveat = false;
    [RuntimeEnabled=WebXR] boolean xrCompatible = false;
};