Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp

Issue 13474014: Folded GraphicsContext3DChromium into GraphicsContext3D (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressing feedback from @zmo Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/WebCore/WebCore.gypi ('k') | Source/WebCore/platform/graphics/GraphicsContext3D.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2009 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 are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32
33 #include "GraphicsContext3D.h"
34
35 #include "DrawingBuffer.h"
36 #include "GraphicsContext3DPrivate.h"
37 #include "ImageBuffer.h"
38 #include "ImageData.h"
39 #include "SkTypes.h"
40 #include <public/Platform.h>
41 #include <public/WebGraphicsContext3D.h>
42 #include <wtf/text/CString.h>
43 #include <wtf/text/WTFString.h>
44
45 namespace WebCore {
46
47 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle)
48 {
49 }
50
51 GraphicsContext3D::~GraphicsContext3D()
52 {
53 m_private->setContextLostCallback(nullptr);
54 m_private->setErrorMessageCallback(nullptr);
55 }
56
57 void GraphicsContext3D::setContextLostCallback(PassOwnPtr<GraphicsContext3D::Con textLostCallback> callback)
58 {
59 m_private->setContextLostCallback(callback);
60 }
61
62 void GraphicsContext3D::setErrorMessageCallback(PassOwnPtr<GraphicsContext3D::Er rorMessageCallback> callback)
63 {
64 m_private->setErrorMessageCallback(callback);
65 }
66
67 PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri butes attrs, HostWindow*, GraphicsContext3D::RenderStyle renderStyle)
68 {
69 ASSERT(renderStyle != GraphicsContext3D::RenderDirectlyToHostWindow);
70
71 WebKit::WebGraphicsContext3D::Attributes webAttributes;
72 webAttributes.alpha = attrs.alpha;
73 webAttributes.depth = attrs.depth;
74 webAttributes.stencil = attrs.stencil;
75 webAttributes.antialias = attrs.antialias;
76 webAttributes.premultipliedAlpha = attrs.premultipliedAlpha;
77 webAttributes.noExtensions = attrs.noExtensions;
78 webAttributes.shareResources = attrs.shareResources;
79 webAttributes.preferDiscreteGPU = attrs.preferDiscreteGPU;
80 webAttributes.topDocumentURL = attrs.topDocumentURL.string();
81
82 OwnPtr<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::Platform: :current()->createOffscreenGraphicsContext3D(webAttributes));
83 if (!webContext)
84 return 0;
85
86 return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webCont ext.release(), attrs.preserveDrawingBuffer);
87 }
88
89 PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const
90 {
91 return m_private->webContext();
92 }
93
94 Platform3DObject GraphicsContext3D::platformTexture() const
95 {
96 return m_private->webContext()->getPlatformTextureId();
97 }
98
99 GrContext* GraphicsContext3D::grContext()
100 {
101 return m_private->grContext();
102 }
103
104 PlatformLayer* GraphicsContext3D::platformLayer() const
105 {
106 return 0;
107 }
108
109 // Macros to assist in delegating from GraphicsContext3D to
110 // WebGraphicsContext3D.
111
112 #define DELEGATE_TO_WEBCONTEXT(name) \
113 void GraphicsContext3D::name() \
114 { \
115 m_private->webContext()->name(); \
116 }
117
118 #define DELEGATE_TO_WEBCONTEXT_R(name, rt) \
119 rt GraphicsContext3D::name() \
120 { \
121 return m_private->webContext()->name(); \
122 }
123
124 #define DELEGATE_TO_WEBCONTEXT_1(name, t1) \
125 void GraphicsContext3D::name(t1 a1) \
126 { \
127 m_private->webContext()->name(a1); \
128 }
129
130 #define DELEGATE_TO_WEBCONTEXT_1R(name, t1, rt) \
131 rt GraphicsContext3D::name(t1 a1) \
132 { \
133 return m_private->webContext()->name(a1); \
134 }
135
136 #define DELEGATE_TO_WEBCONTEXT_2(name, t1, t2) \
137 void GraphicsContext3D::name(t1 a1, t2 a2) \
138 { \
139 m_private->webContext()->name(a1, a2); \
140 }
141
142 #define DELEGATE_TO_WEBCONTEXT_2R(name, t1, t2, rt) \
143 rt GraphicsContext3D::name(t1 a1, t2 a2) \
144 { \
145 return m_private->webContext()->name(a1, a2); \
146 }
147
148 #define DELEGATE_TO_WEBCONTEXT_3(name, t1, t2, t3) \
149 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \
150 { \
151 m_private->webContext()->name(a1, a2, a3); \
152 }
153
154 #define DELEGATE_TO_WEBCONTEXT_3R(name, t1, t2, t3, rt) \
155 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \
156 { \
157 return m_private->webContext()->name(a1, a2, a3); \
158 }
159
160 #define DELEGATE_TO_WEBCONTEXT_4(name, t1, t2, t3, t4) \
161 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4) \
162 { \
163 m_private->webContext()->name(a1, a2, a3, a4); \
164 }
165
166 #define DELEGATE_TO_WEBCONTEXT_4R(name, t1, t2, t3, t4, rt) \
167 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4) \
168 { \
169 return m_private->webContext()->name(a1, a2, a3, a4); \
170 }
171
172 #define DELEGATE_TO_WEBCONTEXT_5(name, t1, t2, t3, t4, t5) \
173 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) \
174 { \
175 m_private->webContext()->name(a1, a2, a3, a4, a5); \
176 }
177
178 #define DELEGATE_TO_WEBCONTEXT_6(name, t1, t2, t3, t4, t5, t6) \
179 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
180 { \
181 m_private->webContext()->name(a1, a2, a3, a4, a5, a6); \
182 }
183
184 #define DELEGATE_TO_WEBCONTEXT_6R(name, t1, t2, t3, t4, t5, t6, rt) \
185 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
186 { \
187 return m_private->webContext()->name(a1, a2, a3, a4, a5, a6); \
188 }
189
190 #define DELEGATE_TO_WEBCONTEXT_7(name, t1, t2, t3, t4, t5, t6, t7) \
191 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
192 { \
193 m_private->webContext()->name(a1, a2, a3, a4, a5, a6, a7); \
194 }
195
196 #define DELEGATE_TO_WEBCONTEXT_7R(name, t1, t2, t3, t4, t5, t6, t7, rt) \
197 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
198 { \
199 return m_private->webContext()->name(a1, a2, a3, a4, a5, a6, a7); \
200 }
201
202 #define DELEGATE_TO_WEBCONTEXT_8(name, t1, t2, t3, t4, t5, t6, t7, t8) \
203 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) \
204 { \
205 m_private->webContext()->name(a1, a2, a3, a4, a5, a6, a7, a8); \
206 }
207
208 #define DELEGATE_TO_WEBCONTEXT_9(name, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
209 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \
210 { \
211 m_private->webContext()->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
212 }
213
214 #define DELEGATE_TO_WEBCONTEXT_9R(name, t1, t2, t3, t4, t5, t6, t7, t8, t9, rt) \
215 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a 8, t9 a9) \
216 { \
217 return m_private->webContext()->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
218 }
219
220 DELEGATE_TO_WEBCONTEXT_R(makeContextCurrent, bool)
221 DELEGATE_TO_WEBCONTEXT(prepareTexture)
222
223 bool GraphicsContext3D::isGLES2Compliant() const
224 {
225 return m_private->webContext()->isGLES2Compliant();
226 }
227
228
229
230 bool GraphicsContext3D::isResourceSafe()
231 {
232 return m_private->isResourceSafe();
233 }
234
235 DELEGATE_TO_WEBCONTEXT_1(activeTexture, GC3Denum)
236 DELEGATE_TO_WEBCONTEXT_2(attachShader, Platform3DObject, Platform3DObject)
237
238 void GraphicsContext3D::bindAttribLocation(Platform3DObject program, GC3Duint in dex, const String& name)
239 {
240 m_private->webContext()->bindAttribLocation(program, index, name.utf8().data ());
241 }
242
243 DELEGATE_TO_WEBCONTEXT_2(bindBuffer, GC3Denum, Platform3DObject)
244 DELEGATE_TO_WEBCONTEXT_2(bindFramebuffer, GC3Denum, Platform3DObject)
245 DELEGATE_TO_WEBCONTEXT_2(bindRenderbuffer, GC3Denum, Platform3DObject)
246 DELEGATE_TO_WEBCONTEXT_2(bindTexture, GC3Denum, Platform3DObject)
247 DELEGATE_TO_WEBCONTEXT_4(blendColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dcla mpf)
248 DELEGATE_TO_WEBCONTEXT_1(blendEquation, GC3Denum)
249 DELEGATE_TO_WEBCONTEXT_2(blendEquationSeparate, GC3Denum, GC3Denum)
250 DELEGATE_TO_WEBCONTEXT_2(blendFunc, GC3Denum, GC3Denum)
251 DELEGATE_TO_WEBCONTEXT_4(blendFuncSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Den um)
252
253 void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage)
254 {
255 bufferData(target, size, 0, usage);
256 }
257
258 DELEGATE_TO_WEBCONTEXT_4(bufferData, GC3Denum, GC3Dsizeiptr, const void*, GC3Den um)
259 DELEGATE_TO_WEBCONTEXT_4(bufferSubData, GC3Denum, GC3Dintptr, GC3Dsizeiptr, cons t void*)
260
261 DELEGATE_TO_WEBCONTEXT_1R(checkFramebufferStatus, GC3Denum, GC3Denum)
262 DELEGATE_TO_WEBCONTEXT_1(clear, GC3Dbitfield)
263 DELEGATE_TO_WEBCONTEXT_4(clearColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dcla mpf)
264 DELEGATE_TO_WEBCONTEXT_1(clearDepth, GC3Dclampf)
265 DELEGATE_TO_WEBCONTEXT_1(clearStencil, GC3Dint)
266 DELEGATE_TO_WEBCONTEXT_4(colorMask, GC3Dboolean, GC3Dboolean, GC3Dboolean, GC3Db oolean)
267 DELEGATE_TO_WEBCONTEXT_1(compileShader, Platform3DObject)
268
269 DELEGATE_TO_WEBCONTEXT_8(compressedTexImage2D, GC3Denum, GC3Dint, GC3Denum, GC3D int, GC3Dint, GC3Dsizei, GC3Dsizei, const void*)
270 DELEGATE_TO_WEBCONTEXT_9(compressedTexSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC 3Dint, GC3Dint, GC3Dint, GC3Denum, GC3Dsizei, const void*)
271 DELEGATE_TO_WEBCONTEXT_8(copyTexImage2D, GC3Denum, GC3Dint, GC3Denum, GC3Dint, G C3Dint, GC3Dsizei, GC3Dsizei, GC3Dint)
272 DELEGATE_TO_WEBCONTEXT_8(copyTexSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
273 DELEGATE_TO_WEBCONTEXT_1(cullFace, GC3Denum)
274 DELEGATE_TO_WEBCONTEXT_1(depthFunc, GC3Denum)
275 DELEGATE_TO_WEBCONTEXT_1(depthMask, GC3Dboolean)
276 DELEGATE_TO_WEBCONTEXT_2(depthRange, GC3Dclampf, GC3Dclampf)
277 DELEGATE_TO_WEBCONTEXT_2(detachShader, Platform3DObject, Platform3DObject)
278 DELEGATE_TO_WEBCONTEXT_1(disable, GC3Denum)
279 DELEGATE_TO_WEBCONTEXT_1(disableVertexAttribArray, GC3Duint)
280 DELEGATE_TO_WEBCONTEXT_3(drawArrays, GC3Denum, GC3Dint, GC3Dsizei)
281 DELEGATE_TO_WEBCONTEXT_4(drawElements, GC3Denum, GC3Dsizei, GC3Denum, GC3Dintptr )
282
283 DELEGATE_TO_WEBCONTEXT_1(enable, GC3Denum)
284 DELEGATE_TO_WEBCONTEXT_1(enableVertexAttribArray, GC3Duint)
285 DELEGATE_TO_WEBCONTEXT(finish)
286 DELEGATE_TO_WEBCONTEXT(flush)
287 DELEGATE_TO_WEBCONTEXT_4(framebufferRenderbuffer, GC3Denum, GC3Denum, GC3Denum, Platform3DObject)
288 DELEGATE_TO_WEBCONTEXT_5(framebufferTexture2D, GC3Denum, GC3Denum, GC3Denum, Pla tform3DObject, GC3Dint)
289 DELEGATE_TO_WEBCONTEXT_1(frontFace, GC3Denum)
290 DELEGATE_TO_WEBCONTEXT_1(generateMipmap, GC3Denum)
291
292 bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index , ActiveInfo& info)
293 {
294 WebKit::WebGraphicsContext3D::ActiveInfo webInfo;
295 if (!m_private->webContext()->getActiveAttrib(program, index, webInfo))
296 return false;
297 info.name = webInfo.name;
298 info.type = webInfo.type;
299 info.size = webInfo.size;
300 return true;
301 }
302
303 bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint inde x, ActiveInfo& info)
304 {
305 WebKit::WebGraphicsContext3D::ActiveInfo webInfo;
306 if (!m_private->webContext()->getActiveUniform(program, index, webInfo))
307 return false;
308 info.name = webInfo.name;
309 info.type = webInfo.type;
310 info.size = webInfo.size;
311 return true;
312 }
313
314
315 DELEGATE_TO_WEBCONTEXT_4(getAttachedShaders, Platform3DObject, GC3Dsizei, GC3Dsi zei*, Platform3DObject*)
316
317 GC3Dint GraphicsContext3D::getAttribLocation(Platform3DObject program, const Str ing& name)
318 {
319 return m_private->webContext()->getAttribLocation(program, name.utf8().data( ));
320 }
321
322 DELEGATE_TO_WEBCONTEXT_2(getBooleanv, GC3Denum, GC3Dboolean*)
323 DELEGATE_TO_WEBCONTEXT_3(getBufferParameteriv, GC3Denum, GC3Denum, GC3Dint*)
324
325 GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes()
326 {
327 WebKit::WebGraphicsContext3D::Attributes webAttributes = m_private->webConte xt()->getContextAttributes();
328 GraphicsContext3D::Attributes attributes;
329 attributes.alpha = webAttributes.alpha;
330 attributes.depth = webAttributes.depth;
331 attributes.stencil = webAttributes.stencil;
332 attributes.antialias = webAttributes.antialias;
333 attributes.premultipliedAlpha = webAttributes.premultipliedAlpha;
334 attributes.preserveDrawingBuffer = m_private->preserveDrawingBuffer();
335 attributes.preferDiscreteGPU = webAttributes.preferDiscreteGPU;
336 return attributes;
337 }
338
339 DELEGATE_TO_WEBCONTEXT_R(getError, GC3Denum)
340 DELEGATE_TO_WEBCONTEXT_2(getFloatv, GC3Denum, GC3Dfloat*)
341 DELEGATE_TO_WEBCONTEXT_4(getFramebufferAttachmentParameteriv, GC3Denum, GC3Denum , GC3Denum, GC3Dint*)
342 DELEGATE_TO_WEBCONTEXT_2(getIntegerv, GC3Denum, GC3Dint*)
343 DELEGATE_TO_WEBCONTEXT_3(getProgramiv, Platform3DObject, GC3Denum, GC3Dint*)
344
345 String GraphicsContext3D::getProgramInfoLog(Platform3DObject program)
346 {
347 return m_private->webContext()->getProgramInfoLog(program);
348 }
349
350
351 DELEGATE_TO_WEBCONTEXT_3(getRenderbufferParameteriv, GC3Denum, GC3Denum, GC3Dint *)
352 DELEGATE_TO_WEBCONTEXT_3(getShaderiv, Platform3DObject, GC3Denum, GC3Dint*)
353
354 String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
355 {
356 return m_private->webContext()->getShaderInfoLog(shader);
357 }
358
359
360 DELEGATE_TO_WEBCONTEXT_4(getShaderPrecisionFormat, GC3Denum, GC3Denum, GC3Dint*, GC3Dint*)
361
362 String GraphicsContext3D::getShaderSource(Platform3DObject shader)
363 {
364 return m_private->webContext()->getShaderSource(shader);
365 }
366
367 String GraphicsContext3D::getString(GC3Denum name)
368 {
369 return m_private->webContext()->getString(name);
370 }
371
372
373 DELEGATE_TO_WEBCONTEXT_3(getTexParameterfv, GC3Denum, GC3Denum, GC3Dfloat*)
374 DELEGATE_TO_WEBCONTEXT_3(getTexParameteriv, GC3Denum, GC3Denum, GC3Dint*)
375 DELEGATE_TO_WEBCONTEXT_3(getUniformfv, Platform3DObject, GC3Dint, GC3Dfloat*)
376 DELEGATE_TO_WEBCONTEXT_3(getUniformiv, Platform3DObject, GC3Dint, GC3Dint*)
377
378 GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const St ring& name)
379 {
380 return m_private->webContext()->getUniformLocation(program, name.utf8().data ());
381 }
382
383
384 DELEGATE_TO_WEBCONTEXT_3(getVertexAttribfv, GC3Duint, GC3Denum, GC3Dfloat*)
385 DELEGATE_TO_WEBCONTEXT_3(getVertexAttribiv, GC3Duint, GC3Denum, GC3Dint*)
386 DELEGATE_TO_WEBCONTEXT_2R(getVertexAttribOffset, GC3Duint, GC3Denum, GC3Dsizeipt r)
387
388 DELEGATE_TO_WEBCONTEXT_2(hint, GC3Denum, GC3Denum)
389 DELEGATE_TO_WEBCONTEXT_1R(isBuffer, Platform3DObject, GC3Dboolean)
390 DELEGATE_TO_WEBCONTEXT_1R(isEnabled, GC3Denum, GC3Dboolean)
391 DELEGATE_TO_WEBCONTEXT_1R(isFramebuffer, Platform3DObject, GC3Dboolean)
392 DELEGATE_TO_WEBCONTEXT_1R(isProgram, Platform3DObject, GC3Dboolean)
393 DELEGATE_TO_WEBCONTEXT_1R(isRenderbuffer, Platform3DObject, GC3Dboolean)
394 DELEGATE_TO_WEBCONTEXT_1R(isShader, Platform3DObject, GC3Dboolean)
395 DELEGATE_TO_WEBCONTEXT_1R(isTexture, Platform3DObject, GC3Dboolean)
396 DELEGATE_TO_WEBCONTEXT_1(lineWidth, GC3Dfloat)
397 DELEGATE_TO_WEBCONTEXT_1(linkProgram, Platform3DObject)
398 DELEGATE_TO_WEBCONTEXT_2(pixelStorei, GC3Denum, GC3Dint)
399 DELEGATE_TO_WEBCONTEXT_2(polygonOffset, GC3Dfloat, GC3Dfloat)
400
401 DELEGATE_TO_WEBCONTEXT_7(readPixels, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3 Denum, GC3Denum, void*)
402
403 DELEGATE_TO_WEBCONTEXT(releaseShaderCompiler)
404 DELEGATE_TO_WEBCONTEXT_4(renderbufferStorage, GC3Denum, GC3Denum, GC3Dsizei, GC3 Dsizei)
405 DELEGATE_TO_WEBCONTEXT_2(sampleCoverage, GC3Dclampf, GC3Dboolean)
406 DELEGATE_TO_WEBCONTEXT_4(scissor, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
407
408 void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& stri ng)
409 {
410 m_private->webContext()->shaderSource(shader, string.utf8().data());
411 }
412
413 DELEGATE_TO_WEBCONTEXT_3(stencilFunc, GC3Denum, GC3Dint, GC3Duint)
414 DELEGATE_TO_WEBCONTEXT_4(stencilFuncSeparate, GC3Denum, GC3Denum, GC3Dint, GC3Du int)
415 DELEGATE_TO_WEBCONTEXT_1(stencilMask, GC3Duint)
416 DELEGATE_TO_WEBCONTEXT_2(stencilMaskSeparate, GC3Denum, GC3Duint)
417 DELEGATE_TO_WEBCONTEXT_3(stencilOp, GC3Denum, GC3Denum, GC3Denum)
418 DELEGATE_TO_WEBCONTEXT_4(stencilOpSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Den um)
419
420 bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte rnalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
421 {
422 m_private->webContext()->texImage2D(target, level, internalformat, width, he ight, border, format, type, pixels);
423 return true;
424 }
425
426 DELEGATE_TO_WEBCONTEXT_3(texParameterf, GC3Denum, GC3Denum, GC3Dfloat)
427 DELEGATE_TO_WEBCONTEXT_3(texParameteri, GC3Denum, GC3Denum, GC3Dint)
428
429 void GraphicsContext3D::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xo ffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3D enum type, const void* pixels)
430 {
431 m_private->webContext()->texSubImage2D(target, level, xoffset, yoffset, widt h, height, format, type, pixels);
432 }
433
434 DELEGATE_TO_WEBCONTEXT_2(uniform1f, GC3Dint, GC3Dfloat)
435 DELEGATE_TO_WEBCONTEXT_3(uniform1fv, GC3Dint, GC3Dsizei, GC3Dfloat*)
436 DELEGATE_TO_WEBCONTEXT_2(uniform1i, GC3Dint, GC3Dint)
437 DELEGATE_TO_WEBCONTEXT_3(uniform1iv, GC3Dint, GC3Dsizei, GC3Dint*)
438 DELEGATE_TO_WEBCONTEXT_3(uniform2f, GC3Dint, GC3Dfloat, GC3Dfloat)
439 DELEGATE_TO_WEBCONTEXT_3(uniform2fv, GC3Dint, GC3Dsizei, GC3Dfloat*)
440 DELEGATE_TO_WEBCONTEXT_3(uniform2i, GC3Dint, GC3Dint, GC3Dint)
441 DELEGATE_TO_WEBCONTEXT_3(uniform2iv, GC3Dint, GC3Dsizei, GC3Dint*)
442 DELEGATE_TO_WEBCONTEXT_4(uniform3f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat)
443 DELEGATE_TO_WEBCONTEXT_3(uniform3fv, GC3Dint, GC3Dsizei, GC3Dfloat*)
444 DELEGATE_TO_WEBCONTEXT_4(uniform3i, GC3Dint, GC3Dint, GC3Dint, GC3Dint)
445 DELEGATE_TO_WEBCONTEXT_3(uniform3iv, GC3Dint, GC3Dsizei, GC3Dint*)
446 DELEGATE_TO_WEBCONTEXT_5(uniform4f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC 3Dfloat)
447 DELEGATE_TO_WEBCONTEXT_3(uniform4fv, GC3Dint, GC3Dsizei, GC3Dfloat*)
448 DELEGATE_TO_WEBCONTEXT_5(uniform4i, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint)
449 DELEGATE_TO_WEBCONTEXT_3(uniform4iv, GC3Dint, GC3Dsizei, GC3Dint*)
450 DELEGATE_TO_WEBCONTEXT_4(uniformMatrix2fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3D float*)
451 DELEGATE_TO_WEBCONTEXT_4(uniformMatrix3fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3D float*)
452 DELEGATE_TO_WEBCONTEXT_4(uniformMatrix4fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3D float*)
453
454 DELEGATE_TO_WEBCONTEXT_1(useProgram, Platform3DObject)
455 DELEGATE_TO_WEBCONTEXT_1(validateProgram, Platform3DObject)
456
457 DELEGATE_TO_WEBCONTEXT_2(vertexAttrib1f, GC3Duint, GC3Dfloat)
458 DELEGATE_TO_WEBCONTEXT_2(vertexAttrib1fv, GC3Duint, GC3Dfloat*)
459 DELEGATE_TO_WEBCONTEXT_3(vertexAttrib2f, GC3Duint, GC3Dfloat, GC3Dfloat)
460 DELEGATE_TO_WEBCONTEXT_2(vertexAttrib2fv, GC3Duint, GC3Dfloat*)
461 DELEGATE_TO_WEBCONTEXT_4(vertexAttrib3f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dflo at)
462 DELEGATE_TO_WEBCONTEXT_2(vertexAttrib3fv, GC3Duint, GC3Dfloat*)
463 DELEGATE_TO_WEBCONTEXT_5(vertexAttrib4f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dflo at, GC3Dfloat)
464 DELEGATE_TO_WEBCONTEXT_2(vertexAttrib4fv, GC3Duint, GC3Dfloat*)
465 DELEGATE_TO_WEBCONTEXT_6(vertexAttribPointer, GC3Duint, GC3Dint, GC3Denum, GC3Db oolean, GC3Dsizei, GC3Dintptr)
466
467 DELEGATE_TO_WEBCONTEXT_4(viewport, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
468
469 void GraphicsContext3D::reshape(int width, int height)
470 {
471 if (width == m_private->webContext()->width() && height == m_private->webCon text()->height())
472 return;
473
474 m_private->webContext()->reshape(width, height);
475 }
476
477 void GraphicsContext3D::markContextChanged()
478 {
479 m_private->markContextChanged();
480 }
481
482 bool GraphicsContext3D::layerComposited() const
483 {
484 return m_private->layerComposited();
485 }
486
487 void GraphicsContext3D::markLayerComposited()
488 {
489 m_private->markLayerComposited();
490 }
491
492 namespace {
493
494 void getDrawingParameters(DrawingBuffer* drawingBuffer, WebKit::WebGraphicsConte xt3D* graphicsContext3D,
495 Platform3DObject* frameBufferId, int* width, int* heig ht)
496 {
497 if (drawingBuffer) {
498 *frameBufferId = drawingBuffer->framebuffer();
499 *width = drawingBuffer->size().width();
500 *height = drawingBuffer->size().height();
501 } else {
502 *frameBufferId = 0;
503 *width = graphicsContext3D->width();
504 *height = graphicsContext3D->height();
505 }
506 }
507
508 } // anonymous namespace
509
510 void GraphicsContext3D::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer, DrawingBuffer* drawingBuffer)
511 {
512 Platform3DObject framebufferId;
513 int width, height;
514 getDrawingParameters(drawingBuffer, m_private->webContext(), &framebufferId, &width, &height);
515 m_private->paintFramebufferToCanvas(framebufferId, width, height, !getContex tAttributes().premultipliedAlpha, imageBuffer);
516 }
517
518 PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData(Drawin gBuffer* drawingBuffer)
519 {
520 if (getContextAttributes().premultipliedAlpha)
521 return 0;
522
523 Platform3DObject framebufferId;
524 int width, height;
525 getDrawingParameters(drawingBuffer, m_private->webContext(), &framebufferId, &width, &height);
526
527 RefPtr<ImageData> imageData = ImageData::create(IntSize(width, height));
528 unsigned char* pixels = imageData->data()->data();
529 size_t bufferSize = 4 * width * height;
530
531 m_private->webContext()->readBackFramebuffer(pixels, bufferSize, framebuffer Id, width, height);
532
533 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT
534 // If the implementation swapped the red and blue channels, un-swap them.
535 for (size_t i = 0; i < bufferSize; i += 4)
536 std::swap(pixels[i], pixels[i + 2]);
537 #endif
538
539 return imageData.release();
540 }
541
542 bool GraphicsContext3D::paintCompositedResultsToCanvas(ImageBuffer*)
543 {
544 return false;
545 }
546
547 DELEGATE_TO_WEBCONTEXT_R(createBuffer, Platform3DObject)
548 DELEGATE_TO_WEBCONTEXT_R(createFramebuffer, Platform3DObject)
549 DELEGATE_TO_WEBCONTEXT_R(createProgram, Platform3DObject)
550 DELEGATE_TO_WEBCONTEXT_R(createRenderbuffer, Platform3DObject)
551 DELEGATE_TO_WEBCONTEXT_1R(createShader, GC3Denum, Platform3DObject)
552 DELEGATE_TO_WEBCONTEXT_R(createTexture, Platform3DObject)
553
554 DELEGATE_TO_WEBCONTEXT_1(deleteBuffer, Platform3DObject)
555 DELEGATE_TO_WEBCONTEXT_1(deleteFramebuffer, Platform3DObject)
556 DELEGATE_TO_WEBCONTEXT_1(deleteProgram, Platform3DObject)
557 DELEGATE_TO_WEBCONTEXT_1(deleteRenderbuffer, Platform3DObject)
558 DELEGATE_TO_WEBCONTEXT_1(deleteShader, Platform3DObject)
559 DELEGATE_TO_WEBCONTEXT_1(deleteTexture, Platform3DObject)
560
561 DELEGATE_TO_WEBCONTEXT_1(synthesizeGLError, GC3Denum)
562
563 Extensions3D* GraphicsContext3D::getExtensions()
564 {
565 return m_private->getExtensions();
566 }
567
568
569 IntSize GraphicsContext3D::getInternalFramebufferSize() const
570 {
571 return IntSize(m_private->webContext()->width(), m_private->webContext()->he ight());
572 }
573
574 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/WebCore.gypi ('k') | Source/WebCore/platform/graphics/GraphicsContext3D.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698