15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (c) 2010, Google Inc. All rights reserved.
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions are
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * met:
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Redistributions of source code must retain the above copyright
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer.
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Redistributions in binary form must reproduce the above
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * in the documentation and/or other materials provided with the
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * distribution.
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef WebGLContextAttributes_h
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define WebGLContextAttributes_h
295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
30197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/ScriptWrappable.h"
3153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/canvas/CanvasContextAttributes.h"
3209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "public/platform/WebGraphicsContext3D.h"
3393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "wtf/PassRefPtr.h"
345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
35c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class Settings;
3809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
3909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class WebGLContextAttributes FINAL : public CanvasContextAttributes, public ScriptWrappable {
40c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(WebGLContextAttributes);
417242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    DEFINE_WRAPPERTYPEINFO();
4293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)public:
435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Create a new attributes object
44c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    static PassRefPtrWillBeRawPtr<WebGLContextAttributes> create();
455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
4609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    // Create a copy of this object.
47c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    PassRefPtrWillBeRawPtr<WebGLContextAttributes> clone() const;
485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Whether or not the drawing buffer has an alpha channel; default=true
505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool alpha() const;
5109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    void setAlpha(bool);
525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Whether or not the drawing buffer has a depth buffer; default=true
545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool depth() const;
5509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    void setDepth(bool);
565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
5709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    // Whether or not the drawing buffer has a stencil buffer; default=false
585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool stencil() const;
5909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    void setStencil(bool);
605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Whether or not the drawing buffer is antialiased; default=true
625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool antialias() const;
6309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    void setAntialias(bool);
645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Whether or not to treat the values in the drawing buffer as
665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // though their alpha channel has already been multiplied into the
675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // color channels; default=true
685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool premultipliedAlpha() const;
6909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    void setPremultipliedAlpha(bool);
705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Whether or not to preserve the drawing buffer after presentation to the
725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // screen; default=false
735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool preserveDrawingBuffer() const;
745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    void setPreserveDrawingBuffer(bool);
755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
7651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    // Whether or not to fail context creation if performance will be
7751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    // significantly degraded compared to a native GL context; default=false
7851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    bool failIfMajorPerformanceCaveat() const;
7951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    void setFailIfMajorPerformanceCaveat(bool);
8051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
8109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    // Set up the attributes that can be used to initialize a WebGraphicsContext3D.
8209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    // It's mostly based on WebGLContextAttributes, but would be adjusted based
8309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    // on settings.
84197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    blink::WebGraphicsContext3D::Attributes attributes(const blink::WebString&, Settings*, unsigned webGLVersion) const;
855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
8693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)protected:
875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    WebGLContextAttributes();
8809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    WebGLContextAttributes(const WebGLContextAttributes&);
895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
9093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)private:
9109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool m_alpha;
9209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool m_depth;
9309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool m_stencil;
9409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool m_antialias;
9509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool m_premultipliedAlpha;
9609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool m_preserveDrawingBuffer;
9709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    bool m_failIfMajorPerformanceCaveat;
985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)};
995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
100c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink
1015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // WebGLContextAttributes_h
103