• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1.  Redistributions of source code must retain the above copyright
9  *     notice, this list of conditions and the following disclaimer.
10  * 2.  Redistributions in binary form must reproduce the above copyright
11  *     notice, this list of conditions and the following disclaimer in the
12  *     documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 
28 #include "platform/graphics/Extensions3D.h"
29 
30 #include "platform/graphics/GraphicsContext3D.h"
31 #include "public/platform/WebGraphicsContext3D.h"
32 #include "wtf/text/CString.h"
33 
34 namespace WebCore {
35 
Extensions3D(GraphicsContext3D * context)36 Extensions3D::Extensions3D(GraphicsContext3D* context)
37     : m_context(context)
38 {
39 }
40 
~Extensions3D()41 Extensions3D::~Extensions3D()
42 {
43 }
44 
supports(const String & name)45 bool Extensions3D::supports(const String& name)
46 {
47     return m_context->supportsExtension(name);
48 }
49 
ensureEnabled(const String & name)50 void Extensions3D::ensureEnabled(const String& name)
51 {
52     bool result = m_context->ensureExtensionEnabled(name);
53     ASSERT_UNUSED(result, result);
54 }
55 
isEnabled(const String & name)56 bool Extensions3D::isEnabled(const String& name)
57 {
58     return m_context->isExtensionEnabled(name);
59 }
60 
getGraphicsResetStatusARB()61 int Extensions3D::getGraphicsResetStatusARB()
62 {
63     return static_cast<int>(m_context->webContext()->getGraphicsResetStatusARB());
64 }
65 
blitFramebuffer(long srcX0,long srcY0,long srcX1,long srcY1,long dstX0,long dstY0,long dstX1,long dstY1,unsigned long mask,unsigned long filter)66 void Extensions3D::blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter)
67 {
68     m_context->webContext()->blitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
69 }
70 
renderbufferStorageMultisample(unsigned long target,unsigned long samples,unsigned long internalformat,unsigned long width,unsigned long height)71 void Extensions3D::renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height)
72 {
73     m_context->webContext()->renderbufferStorageMultisampleCHROMIUM(target, samples, internalformat, width, height);
74 }
75 
mapBufferSubDataCHROMIUM(unsigned target,int offset,int size,unsigned access)76 void* Extensions3D::mapBufferSubDataCHROMIUM(unsigned target, int offset, int size, unsigned access)
77 {
78     return m_context->webContext()->mapBufferSubDataCHROMIUM(target, offset, size, access);
79 }
80 
unmapBufferSubDataCHROMIUM(const void * data)81 void Extensions3D::unmapBufferSubDataCHROMIUM(const void* data)
82 {
83     m_context->webContext()->unmapBufferSubDataCHROMIUM(data);
84 }
85 
mapTexSubImage2DCHROMIUM(unsigned target,int level,int xoffset,int yoffset,int width,int height,unsigned format,unsigned type,unsigned access)86 void* Extensions3D::mapTexSubImage2DCHROMIUM(unsigned target, int level, int xoffset, int yoffset, int width, int height, unsigned format, unsigned type, unsigned access)
87 {
88     return m_context->webContext()->mapTexSubImage2DCHROMIUM(target, level, xoffset, yoffset, width, height, format, type, access);
89 }
90 
unmapTexSubImage2DCHROMIUM(const void * data)91 void Extensions3D::unmapTexSubImage2DCHROMIUM(const void* data)
92 {
93     m_context->webContext()->unmapTexSubImage2DCHROMIUM(data);
94 }
95 
createVertexArrayOES()96 Platform3DObject Extensions3D::createVertexArrayOES()
97 {
98     return m_context->webContext()->createVertexArrayOES();
99 }
100 
deleteVertexArrayOES(Platform3DObject array)101 void Extensions3D::deleteVertexArrayOES(Platform3DObject array)
102 {
103     m_context->webContext()->deleteVertexArrayOES(array);
104 }
105 
isVertexArrayOES(Platform3DObject array)106 GC3Dboolean Extensions3D::isVertexArrayOES(Platform3DObject array)
107 {
108     return m_context->webContext()->isVertexArrayOES(array);
109 }
110 
bindVertexArrayOES(Platform3DObject array)111 void Extensions3D::bindVertexArrayOES(Platform3DObject array)
112 {
113     m_context->webContext()->bindVertexArrayOES(array);
114 }
115 
getTranslatedShaderSourceANGLE(Platform3DObject shader)116 String Extensions3D::getTranslatedShaderSourceANGLE(Platform3DObject shader)
117 {
118     return m_context->webContext()->getTranslatedShaderSourceANGLE(shader);
119 }
120 
rateLimitOffscreenContextCHROMIUM()121 void Extensions3D::rateLimitOffscreenContextCHROMIUM()
122 {
123     m_context->webContext()->rateLimitOffscreenContextCHROMIUM();
124 }
125 
paintFramebufferToCanvas(int framebuffer,int width,int height,bool premultiplyAlpha,ImageBuffer * imageBuffer)126 void Extensions3D::paintFramebufferToCanvas(int framebuffer, int width, int height, bool premultiplyAlpha, ImageBuffer* imageBuffer)
127 {
128     m_context->paintFramebufferToCanvas(framebuffer, width, height, premultiplyAlpha, imageBuffer);
129 }
130 
texImageIOSurface2DCHROMIUM(unsigned target,int width,int height,uint32_t ioSurfaceId,unsigned plane)131 void Extensions3D::texImageIOSurface2DCHROMIUM(unsigned target, int width, int height, uint32_t ioSurfaceId, unsigned plane)
132 {
133     m_context->webContext()->texImageIOSurface2DCHROMIUM(target, width, height, ioSurfaceId, plane);
134 }
135 
texStorage2DEXT(unsigned int target,int levels,unsigned int internalFormat,int width,int height)136 void Extensions3D::texStorage2DEXT(unsigned int target, int levels, unsigned int internalFormat, int width, int height)
137 {
138     m_context->webContext()->texStorage2DEXT(target, levels, internalFormat, width, height);
139 }
140 
createQueryEXT()141 Platform3DObject Extensions3D::createQueryEXT()
142 {
143     return m_context->webContext()->createQueryEXT();
144 }
145 
deleteQueryEXT(Platform3DObject query)146 void Extensions3D::deleteQueryEXT(Platform3DObject query)
147 {
148     m_context->webContext()->deleteQueryEXT(query);
149 }
150 
isQueryEXT(Platform3DObject query)151 GC3Dboolean Extensions3D::isQueryEXT(Platform3DObject query)
152 {
153     return m_context->webContext()->isQueryEXT(query);
154 }
155 
beginQueryEXT(GC3Denum target,Platform3DObject query)156 void Extensions3D::beginQueryEXT(GC3Denum target, Platform3DObject query)
157 {
158     m_context->webContext()->beginQueryEXT(target, query);
159 }
160 
endQueryEXT(GC3Denum target)161 void Extensions3D::endQueryEXT(GC3Denum target)
162 {
163     m_context->webContext()->endQueryEXT(target);
164 }
165 
getQueryivEXT(GC3Denum target,GC3Denum pname,GC3Dint * params)166 void Extensions3D::getQueryivEXT(GC3Denum target, GC3Denum pname, GC3Dint* params)
167 {
168     m_context->webContext()->getQueryivEXT(target, pname, params);
169 }
170 
getQueryObjectuivEXT(Platform3DObject query,GC3Denum pname,GC3Duint * params)171 void Extensions3D::getQueryObjectuivEXT(Platform3DObject query, GC3Denum pname, GC3Duint* params)
172 {
173     m_context->webContext()->getQueryObjectuivEXT(query, pname, params);
174 }
175 
canUseCopyTextureCHROMIUM(GC3Denum destFormat,GC3Denum destType,GC3Dint level)176 bool Extensions3D::canUseCopyTextureCHROMIUM(GC3Denum destFormat, GC3Denum destType, GC3Dint level)
177 {
178     // FIXME: restriction of (RGB || RGBA)/UNSIGNED_BYTE/(Level 0) should be lifted when
179     // WebGraphicsContext3D::copyTextureCHROMIUM(...) are fully functional.
180     if ((destFormat == GL_RGB || destFormat == GL_RGBA)
181         && destType == GL_UNSIGNED_BYTE
182         && !level)
183         return true;
184     return false;
185 }
186 
copyTextureCHROMIUM(GC3Denum target,Platform3DObject sourceId,Platform3DObject destId,GC3Dint level,GC3Denum internalFormat,GC3Denum destType)187 void Extensions3D::copyTextureCHROMIUM(GC3Denum target, Platform3DObject sourceId, Platform3DObject destId, GC3Dint level, GC3Denum internalFormat, GC3Denum destType)
188 {
189     m_context->webContext()->copyTextureCHROMIUM(target, sourceId, destId, level, internalFormat, destType);
190 }
191 
shallowFlushCHROMIUM()192 void Extensions3D::shallowFlushCHROMIUM()
193 {
194     return m_context->webContext()->shallowFlushCHROMIUM();
195 }
196 
insertEventMarkerEXT(const String & marker)197 void Extensions3D::insertEventMarkerEXT(const String& marker)
198 {
199     m_context->webContext()->insertEventMarkerEXT(marker.utf8().data());
200 }
201 
pushGroupMarkerEXT(const String & marker)202 void Extensions3D::pushGroupMarkerEXT(const String& marker)
203 {
204     m_context->webContext()->pushGroupMarkerEXT(marker.utf8().data());
205 }
206 
popGroupMarkerEXT(void)207 void Extensions3D::popGroupMarkerEXT(void)
208 {
209     m_context->webContext()->popGroupMarkerEXT();
210 }
211 
drawBuffersEXT(GC3Dsizei n,const GC3Denum * bufs)212 void Extensions3D::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs)
213 {
214     m_context->webContext()->drawBuffersEXT(n, bufs);
215 }
216 
drawArraysInstancedANGLE(GC3Denum mode,GC3Dint first,GC3Dsizei count,GC3Dsizei primcount)217 void Extensions3D::drawArraysInstancedANGLE(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
218 {
219     m_context->webContext()->drawArraysInstancedANGLE(mode, first, count, primcount);
220 }
221 
drawElementsInstancedANGLE(GC3Denum mode,GC3Dsizei count,GC3Denum type,GC3Dintptr offset,GC3Dsizei primcount)222 void Extensions3D::drawElementsInstancedANGLE(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount)
223 {
224     m_context->webContext()->drawElementsInstancedANGLE(mode, count, type, offset, primcount);
225 }
226 
vertexAttribDivisorANGLE(GC3Duint index,GC3Duint divisor)227 void Extensions3D::vertexAttribDivisorANGLE(GC3Duint index, GC3Duint divisor)
228 {
229     m_context->webContext()->vertexAttribDivisorANGLE(index, divisor);
230 }
231 
loseContextCHROMIUM(GC3Denum current,GC3Denum other)232 void Extensions3D::loseContextCHROMIUM(GC3Denum current, GC3Denum other)
233 {
234     m_context->webContext()->loseContextCHROMIUM(current, other);
235 }
236 
237 } // namespace WebCore
238