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 "core/platform/graphics/Extensions3D.h" 29 30#include "core/platform/NotImplemented.h" 31#include "core/platform/graphics/GraphicsContext3D.h" 32#include "public/platform/WebGraphicsContext3D.h" 33#include "wtf/text/CString.h" 34 35namespace WebCore { 36 37Extensions3D::Extensions3D(GraphicsContext3D* context) 38 : m_context(context) 39{ 40} 41 42Extensions3D::~Extensions3D() 43{ 44} 45 46bool Extensions3D::supports(const String& name) 47{ 48 return m_context->supportsExtension(name); 49} 50 51void Extensions3D::ensureEnabled(const String& name) 52{ 53 bool result = m_context->ensureExtensionEnabled(name); 54 ASSERT_UNUSED(result, result); 55} 56 57bool Extensions3D::isEnabled(const String& name) 58{ 59 return m_context->isExtensionEnabled(name); 60} 61 62int Extensions3D::getGraphicsResetStatusARB() 63{ 64 return static_cast<int>(m_context->webContext()->getGraphicsResetStatusARB()); 65} 66 67void Extensions3D::blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) 68{ 69 m_context->webContext()->blitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 70} 71 72void Extensions3D::renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) 73{ 74 m_context->webContext()->renderbufferStorageMultisampleCHROMIUM(target, samples, internalformat, width, height); 75} 76 77void* Extensions3D::mapBufferSubDataCHROMIUM(unsigned target, int offset, int size, unsigned access) 78{ 79 return m_context->webContext()->mapBufferSubDataCHROMIUM(target, offset, size, access); 80} 81 82void Extensions3D::unmapBufferSubDataCHROMIUM(const void* data) 83{ 84 m_context->webContext()->unmapBufferSubDataCHROMIUM(data); 85} 86 87void* Extensions3D::mapTexSubImage2DCHROMIUM(unsigned target, int level, int xoffset, int yoffset, int width, int height, unsigned format, unsigned type, unsigned access) 88{ 89 return m_context->webContext()->mapTexSubImage2DCHROMIUM(target, level, xoffset, yoffset, width, height, format, type, access); 90} 91 92void Extensions3D::unmapTexSubImage2DCHROMIUM(const void* data) 93{ 94 m_context->webContext()->unmapTexSubImage2DCHROMIUM(data); 95} 96 97Platform3DObject Extensions3D::createVertexArrayOES() 98{ 99 return m_context->webContext()->createVertexArrayOES(); 100} 101 102void Extensions3D::deleteVertexArrayOES(Platform3DObject array) 103{ 104 m_context->webContext()->deleteVertexArrayOES(array); 105} 106 107GC3Dboolean Extensions3D::isVertexArrayOES(Platform3DObject array) 108{ 109 return m_context->webContext()->isVertexArrayOES(array); 110} 111 112void Extensions3D::bindVertexArrayOES(Platform3DObject array) 113{ 114 m_context->webContext()->bindVertexArrayOES(array); 115} 116 117String Extensions3D::getTranslatedShaderSourceANGLE(Platform3DObject shader) 118{ 119 return m_context->webContext()->getTranslatedShaderSourceANGLE(shader); 120} 121 122void Extensions3D::rateLimitOffscreenContextCHROMIUM() 123{ 124 m_context->webContext()->rateLimitOffscreenContextCHROMIUM(); 125} 126 127void Extensions3D::paintFramebufferToCanvas(int framebuffer, int width, int height, bool premultiplyAlpha, ImageBuffer* imageBuffer) 128{ 129 m_context->paintFramebufferToCanvas(framebuffer, width, height, premultiplyAlpha, imageBuffer); 130} 131 132void Extensions3D::texImageIOSurface2DCHROMIUM(unsigned target, int width, int height, uint32_t ioSurfaceId, unsigned plane) 133{ 134 m_context->webContext()->texImageIOSurface2DCHROMIUM(target, width, height, ioSurfaceId, plane); 135} 136 137void Extensions3D::texStorage2DEXT(unsigned int target, int levels, unsigned int internalFormat, int width, int height) 138{ 139 m_context->webContext()->texStorage2DEXT(target, levels, internalFormat, width, height); 140} 141 142Platform3DObject Extensions3D::createQueryEXT() 143{ 144 return m_context->webContext()->createQueryEXT(); 145} 146 147void Extensions3D::deleteQueryEXT(Platform3DObject query) 148{ 149 m_context->webContext()->deleteQueryEXT(query); 150} 151 152GC3Dboolean Extensions3D::isQueryEXT(Platform3DObject query) 153{ 154 return m_context->webContext()->isQueryEXT(query); 155} 156 157void Extensions3D::beginQueryEXT(GC3Denum target, Platform3DObject query) 158{ 159 m_context->webContext()->beginQueryEXT(target, query); 160} 161 162void Extensions3D::endQueryEXT(GC3Denum target) 163{ 164 m_context->webContext()->endQueryEXT(target); 165} 166 167void Extensions3D::getQueryivEXT(GC3Denum target, GC3Denum pname, GC3Dint* params) 168{ 169 m_context->webContext()->getQueryivEXT(target, pname, params); 170} 171 172void Extensions3D::getQueryObjectuivEXT(Platform3DObject query, GC3Denum pname, GC3Duint* params) 173{ 174 m_context->webContext()->getQueryObjectuivEXT(query, pname, params); 175} 176 177bool Extensions3D::canUseCopyTextureCHROMIUM(GC3Denum destFormat, GC3Denum destType, GC3Dint level) 178{ 179 // FIXME: restriction of (RGB || RGBA)/UNSIGNED_BYTE/(Level 0) should be lifted when 180 // WebGraphicsContext3D::copyTextureCHROMIUM(...) are fully functional. 181 if ((destFormat == GraphicsContext3D::RGB || destFormat == GraphicsContext3D::RGBA) 182 && destType == GraphicsContext3D::UNSIGNED_BYTE 183 && !level) 184 return true; 185 return false; 186} 187 188void Extensions3D::copyTextureCHROMIUM(GC3Denum target, Platform3DObject sourceId, Platform3DObject destId, GC3Dint level, GC3Denum internalFormat, GC3Denum destType) 189{ 190 m_context->webContext()->copyTextureCHROMIUM(target, sourceId, destId, level, internalFormat, destType); 191} 192 193void Extensions3D::shallowFlushCHROMIUM() 194{ 195 return m_context->webContext()->shallowFlushCHROMIUM(); 196} 197 198void Extensions3D::insertEventMarkerEXT(const String& marker) 199{ 200 m_context->webContext()->insertEventMarkerEXT(marker.utf8().data()); 201} 202 203void Extensions3D::pushGroupMarkerEXT(const String& marker) 204{ 205 m_context->webContext()->pushGroupMarkerEXT(marker.utf8().data()); 206} 207 208void Extensions3D::popGroupMarkerEXT(void) 209{ 210 m_context->webContext()->popGroupMarkerEXT(); 211} 212 213void Extensions3D::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs) 214{ 215 m_context->webContext()->drawBuffersEXT(n, bufs); 216} 217 218void Extensions3D::drawArraysInstancedANGLE(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) 219{ 220 m_context->webContext()->drawArraysInstancedANGLE(mode, first, count, primcount); 221} 222 223void Extensions3D::drawElementsInstancedANGLE(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) 224{ 225 m_context->webContext()->drawElementsInstancedANGLE(mode, count, type, offset, primcount); 226} 227 228void Extensions3D::vertexAttribDivisorANGLE(GC3Duint index, GC3Duint divisor) 229{ 230 m_context->webContext()->vertexAttribDivisorANGLE(index, divisor); 231} 232 233void Extensions3D::loseContextCHROMIUM(GC3Denum current, GC3Denum other) 234{ 235 m_context->webContext()->loseContextCHROMIUM(current, other); 236} 237 238} // namespace WebCore 239