2 * Copyright (c) 2010, Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following disclaimer
11 * in the documentation and/or other materials provided with the
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef WebGLContextAttributes_h
28 #define WebGLContextAttributes_h
30 #include "bindings/core/v8/ScriptWrappable.h"
31 #include "core/html/canvas/CanvasContextAttributes.h"
32 #include "public/platform/WebGraphicsContext3D.h"
33 #include "wtf/PassRefPtr.h"
39 class WebGLContextAttributes final : public CanvasContextAttributes, public ScriptWrappable {
40 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(WebGLContextAttributes);
41 DEFINE_WRAPPERTYPEINFO();
43 // Create a new attributes object
44 static PassRefPtrWillBeRawPtr<WebGLContextAttributes> create();
46 // Create a copy of this object.
47 PassRefPtrWillBeRawPtr<WebGLContextAttributes> clone() const;
49 // Whether or not the drawing buffer has an alpha channel; default=true
53 // Whether or not the drawing buffer has a depth buffer; default=true
57 // Whether or not the drawing buffer has a stencil buffer; default=false
59 void setStencil(bool);
61 // Whether or not the drawing buffer is antialiased; default=true
62 bool antialias() const;
63 void setAntialias(bool);
65 // Whether or not to treat the values in the drawing buffer as
66 // though their alpha channel has already been multiplied into the
67 // color channels; default=true
68 bool premultipliedAlpha() const;
69 void setPremultipliedAlpha(bool);
71 // Whether or not to preserve the drawing buffer after presentation to the
72 // screen; default=false
73 bool preserveDrawingBuffer() const;
74 void setPreserveDrawingBuffer(bool);
76 // Whether or not to fail context creation if performance will be
77 // significantly degraded compared to a native GL context; default=false
78 bool failIfMajorPerformanceCaveat() const;
79 void setFailIfMajorPerformanceCaveat(bool);
81 // Set up the attributes that can be used to initialize a WebGraphicsContext3D.
82 // It's mostly based on WebGLContextAttributes, but would be adjusted based
84 blink::WebGraphicsContext3D::Attributes attributes(const blink::WebString&, Settings*, unsigned webGLVersion) const;
87 WebGLContextAttributes();
88 WebGLContextAttributes(const WebGLContextAttributes&);
95 bool m_premultipliedAlpha;
96 bool m_preserveDrawingBuffer;
97 bool m_failIfMajorPerformanceCaveat;
102 #endif // WebGLContextAttributes_h