1/*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#pragma once
28
29#include "Extensions3D.h"
30
31#include "GraphicsContext3D.h"
32#include <wtf/HashSet.h>
33#include <wtf/text/StringHash.h>
34
35namespace WebCore {
36
37class Extensions3DOpenGLCommon : public Extensions3D {
38public:
39 virtual ~Extensions3DOpenGLCommon();
40
41 // Extensions3D methods.
42 bool supports(const String&) override;
43 void ensureEnabled(const String&) override;
44 bool isEnabled(const String&) override;
45 int getGraphicsResetStatusARB() override;
46
47 Platform3DObject createVertexArrayOES() override = 0;
48 void deleteVertexArrayOES(Platform3DObject) override = 0;
49 GC3Dboolean isVertexArrayOES(Platform3DObject) override = 0;
50 void bindVertexArrayOES(Platform3DObject) override = 0;
51
52 void drawBuffersEXT(GC3Dsizei, const GC3Denum*) override = 0;
53
54 String getTranslatedShaderSourceANGLE(Platform3DObject) override;
55
56 // EXT Robustness - uses getGraphicsResetStatusARB()
57 void readnPixelsEXT(int x, int y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, GC3Dsizei bufSize, void *data) override;
58 void getnUniformfvEXT(GC3Duint program, int location, GC3Dsizei bufSize, float *params) override;
59 void getnUniformivEXT(GC3Duint program, int location, GC3Dsizei bufSize, int *params) override;
60
61 bool isNVIDIA() override { return m_isNVIDIA; }
62 bool isAMD() override { return m_isAMD; }
63 bool isIntel() override { return m_isIntel; }
64 bool isImagination() override { return m_isImagination; }
65 String vendor() override { return m_vendor; }
66
67 bool requiresBuiltInFunctionEmulation() override { return m_requiresBuiltInFunctionEmulation; }
68 bool requiresRestrictedMaximumTextureSize() override { return m_requiresRestrictedMaximumTextureSize; }
69
70protected:
71 friend class Extensions3DOpenGLES;
72 Extensions3DOpenGLCommon(GraphicsContext3D*, bool useIndexedGetString);
73
74 virtual bool supportsExtension(const String&) = 0;
75 virtual String getExtensions() = 0;
76
77 virtual void initializeAvailableExtensions();
78 bool m_initializedAvailableExtensions;
79 HashSet<String> m_availableExtensions;
80
81 // Weak pointer back to GraphicsContext3D
82 GraphicsContext3D* m_context;
83
84 bool m_isNVIDIA;
85 bool m_isAMD;
86 bool m_isIntel;
87 bool m_isImagination;
88 bool m_requiresBuiltInFunctionEmulation;
89 bool m_requiresRestrictedMaximumTextureSize;
90
91 bool m_useIndexedGetString { false };
92
93 String m_vendor;
94 String m_renderer;
95};
96
97} // namespace WebCore
98