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

Side by Side Diff: Source/WebCore/platform/graphics/GraphicsContext3D.cpp

Issue 13474014: Folded GraphicsContext3DChromium into GraphicsContext3D (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/platform/chromium/support/GraphicsContext3DChromium.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Copyright (C) 2010 Mozilla Corporation. All rights reserved. 4 * Copyright (C) 2010 Mozilla Corporation. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 17 matching lines...) Expand all
28 #include "config.h" 28 #include "config.h"
29 29
30 #if USE(3D_GRAPHICS) 30 #if USE(3D_GRAPHICS)
31 31
32 #include "GraphicsContext3D.h" 32 #include "GraphicsContext3D.h"
33 #include "GraphicsContext3DNEON.h" 33 #include "GraphicsContext3DNEON.h"
34 34
35 #include "CheckedInt.h" 35 #include "CheckedInt.h"
36 #include "DrawingBuffer.h" 36 #include "DrawingBuffer.h"
37 #include "Extensions3D.h" 37 #include "Extensions3D.h"
38 #include "GraphicsContext3DPrivate.h"
38 #include "Image.h" 39 #include "Image.h"
40 #include "ImageBuffer.h"
39 #include "ImageData.h" 41 #include "ImageData.h"
40 #include "ImageObserver.h" 42 #include "ImageObserver.h"
43 #include "SkTypes.h"
41 44
45 #include <public/Platform.h>
46 #include <public/WebGraphicsContext3D.h>
42 #include <wtf/ArrayBufferView.h> 47 #include <wtf/ArrayBufferView.h>
43 #include <wtf/OwnArrayPtr.h> 48 #include <wtf/OwnArrayPtr.h>
44 #include <wtf/PassOwnArrayPtr.h> 49 #include <wtf/PassOwnArrayPtr.h>
50 #include <wtf/text/CString.h>
51 #include <wtf/text/WTFString.h>
45 52
46 namespace WebCore { 53 namespace WebCore {
47 54
48 namespace { 55 namespace {
49 56
50 GraphicsContext3D::DataFormat getDataFormat(GC3Denum destinationFormat, GC3Denum destinationType) 57 GraphicsContext3D::DataFormat getDataFormat(GC3Denum destinationFormat, GC3Denum destinationType)
51 { 58 {
52 GraphicsContext3D::DataFormat dstFormat = GraphicsContext3D::DataFormatRGBA8 ; 59 GraphicsContext3D::DataFormat dstFormat = GraphicsContext3D::DataFormatRGBA8 ;
53 switch (destinationType) { 60 switch (destinationType) {
54 case GraphicsContext3D::UNSIGNED_BYTE: 61 case GraphicsContext3D::UNSIGNED_BYTE:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 default: 108 default:
102 ASSERT_NOT_REACHED(); 109 ASSERT_NOT_REACHED();
103 } 110 }
104 break; 111 break;
105 default: 112 default:
106 ASSERT_NOT_REACHED(); 113 ASSERT_NOT_REACHED();
107 } 114 }
108 return dstFormat; 115 return dstFormat;
109 } 116 }
110 117
118 void getDrawingParameters(DrawingBuffer* drawingBuffer, WebKit::WebGraphicsConte xt3D* graphicsContext3D,
119 Platform3DObject* frameBufferId, int* width, int* heig ht)
120 {
121 if (drawingBuffer) {
122 *frameBufferId = drawingBuffer->framebuffer();
123 *width = drawingBuffer->size().width();
124 *height = drawingBuffer->size().height();
125 } else {
126 *frameBufferId = 0;
127 *width = graphicsContext3D->width();
128 *height = graphicsContext3D->height();
129 }
130 }
131
111 } // anonymous namespace 132 } // anonymous namespace
112 133
134 // Macros to assist in delegating from GraphicsContext3D to
135 // WebGraphicsContext3D.
136
137 #define DELEGATE_TO_WEBCONTEXT(name) \
138 void GraphicsContext3D::name() \
139 { \
140 m_private->webContext()->name(); \
141 }
142
143 #define DELEGATE_TO_WEBCONTEXT_R(name, rt) \
144 rt GraphicsContext3D::name() \
145 { \
146 return m_private->webContext()->name(); \
147 }
148
149 #define DELEGATE_TO_WEBCONTEXT_1(name, t1) \
150 void GraphicsContext3D::name(t1 a1) \
151 { \
152 m_private->webContext()->name(a1); \
153 }
154
155 #define DELEGATE_TO_WEBCONTEXT_1R(name, t1, rt) \
156 rt GraphicsContext3D::name(t1 a1) \
157 { \
158 return m_private->webContext()->name(a1); \
159 }
160
161 #define DELEGATE_TO_WEBCONTEXT_2(name, t1, t2) \
162 void GraphicsContext3D::name(t1 a1, t2 a2) \
163 { \
164 m_private->webContext()->name(a1, a2); \
165 }
166
167 #define DELEGATE_TO_WEBCONTEXT_2R(name, t1, t2, rt) \
168 rt GraphicsContext3D::name(t1 a1, t2 a2) \
169 { \
170 return m_private->webContext()->name(a1, a2); \
171 }
172
173 #define DELEGATE_TO_WEBCONTEXT_3(name, t1, t2, t3) \
174 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \
175 { \
176 m_private->webContext()->name(a1, a2, a3); \
177 }
178
179 #define DELEGATE_TO_WEBCONTEXT_3R(name, t1, t2, t3, rt) \
180 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3) \
181 { \
182 return m_private->webContext()->name(a1, a2, a3); \
183 }
184
185 #define DELEGATE_TO_WEBCONTEXT_4(name, t1, t2, t3, t4) \
186 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4) \
187 { \
188 m_private->webContext()->name(a1, a2, a3, a4); \
189 }
190
191 #define DELEGATE_TO_WEBCONTEXT_4R(name, t1, t2, t3, t4, rt) \
192 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4) \
193 { \
194 return m_private->webContext()->name(a1, a2, a3, a4); \
195 }
196
197 #define DELEGATE_TO_WEBCONTEXT_5(name, t1, t2, t3, t4, t5) \
198 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) \
199 { \
200 m_private->webContext()->name(a1, a2, a3, a4, a5); \
201 }
202
203 #define DELEGATE_TO_WEBCONTEXT_6(name, t1, t2, t3, t4, t5, t6) \
204 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
205 { \
206 m_private->webContext()->name(a1, a2, a3, a4, a5, a6); \
207 }
208
209 #define DELEGATE_TO_WEBCONTEXT_6R(name, t1, t2, t3, t4, t5, t6, rt) \
210 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
211 { \
212 return m_private->webContext()->name(a1, a2, a3, a4, a5, a6); \
213 }
214
215 #define DELEGATE_TO_WEBCONTEXT_7(name, t1, t2, t3, t4, t5, t6, t7) \
216 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
217 { \
218 m_private->webContext()->name(a1, a2, a3, a4, a5, a6, a7); \
219 }
220
221 #define DELEGATE_TO_WEBCONTEXT_7R(name, t1, t2, t3, t4, t5, t6, t7, rt) \
222 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
223 { \
224 return m_private->webContext()->name(a1, a2, a3, a4, a5, a6, a7); \
225 }
226
227 #define DELEGATE_TO_WEBCONTEXT_8(name, t1, t2, t3, t4, t5, t6, t7, t8) \
228 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) \
229 { \
230 m_private->webContext()->name(a1, a2, a3, a4, a5, a6, a7, a8); \
231 }
232
233 #define DELEGATE_TO_WEBCONTEXT_9(name, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
234 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \
235 { \
236 m_private->webContext()->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
237 }
238
239 #define DELEGATE_TO_WEBCONTEXT_9R(name, t1, t2, t3, t4, t5, t6, t7, t8, t9, rt) \
240 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a 8, t9 a9) \
241 { \
242 return m_private->webContext()->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
243 }
244
245 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle)
246 {
247 }
248
249 GraphicsContext3D::~GraphicsContext3D()
250 {
251 m_private->setContextLostCallback(nullptr);
252 m_private->setErrorMessageCallback(nullptr);
253 }
254
255 void GraphicsContext3D::setContextLostCallback(PassOwnPtr<GraphicsContext3D::Con textLostCallback> callback)
256 {
257 m_private->setContextLostCallback(callback);
258 }
259
260 void GraphicsContext3D::setErrorMessageCallback(PassOwnPtr<GraphicsContext3D::Er rorMessageCallback> callback)
261 {
262 m_private->setErrorMessageCallback(callback);
263 }
264
265 PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri butes attrs, HostWindow*, GraphicsContext3D::RenderStyle renderStyle)
266 {
267 ASSERT(renderStyle != GraphicsContext3D::RenderDirectlyToHostWindow);
268
269 WebKit::WebGraphicsContext3D::Attributes webAttributes;
270 webAttributes.alpha = attrs.alpha;
271 webAttributes.depth = attrs.depth;
272 webAttributes.stencil = attrs.stencil;
273 webAttributes.antialias = attrs.antialias;
274 webAttributes.premultipliedAlpha = attrs.premultipliedAlpha;
275 webAttributes.noExtensions = attrs.noExtensions;
276 webAttributes.shareResources = attrs.shareResources;
277 webAttributes.preferDiscreteGPU = attrs.preferDiscreteGPU;
278 webAttributes.topDocumentURL = attrs.topDocumentURL.string();
279
280 OwnPtr<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::Platform: :current()->createOffscreenGraphicsContext3D(webAttributes));
281 if (!webContext)
282 return 0;
283
284 return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webCont ext.release(), attrs.preserveDrawingBuffer);
285 }
286
287 PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const
288 {
289 return m_private->webContext();
290 }
291
292 Platform3DObject GraphicsContext3D::platformTexture() const
293 {
294 return m_private->webContext()->getPlatformTextureId();
295 }
296
297 GrContext* GraphicsContext3D::grContext()
298 {
299 return m_private->grContext();
300 }
301
302 PlatformLayer* GraphicsContext3D::platformLayer() const
303 {
304 return 0;
305 }
306
307 DELEGATE_TO_WEBCONTEXT_R(makeContextCurrent, bool)
308 DELEGATE_TO_WEBCONTEXT(prepareTexture)
309
310 bool GraphicsContext3D::isGLES2Compliant() const
311 {
312 return m_private->webContext()->isGLES2Compliant();
313 }
314
315 bool GraphicsContext3D::isResourceSafe()
316 {
317 return m_private->isResourceSafe();
318 }
319
320 DELEGATE_TO_WEBCONTEXT_1(activeTexture, GC3Denum)
321 DELEGATE_TO_WEBCONTEXT_2(attachShader, Platform3DObject, Platform3DObject)
322
323 void GraphicsContext3D::bindAttribLocation(Platform3DObject program, GC3Duint in dex, const String& name)
324 {
325 m_private->webContext()->bindAttribLocation(program, index, name.utf8().data ());
326 }
327
328 DELEGATE_TO_WEBCONTEXT_2(bindBuffer, GC3Denum, Platform3DObject)
329 DELEGATE_TO_WEBCONTEXT_2(bindFramebuffer, GC3Denum, Platform3DObject)
330 DELEGATE_TO_WEBCONTEXT_2(bindRenderbuffer, GC3Denum, Platform3DObject)
331 DELEGATE_TO_WEBCONTEXT_2(bindTexture, GC3Denum, Platform3DObject)
332 DELEGATE_TO_WEBCONTEXT_4(blendColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dcla mpf)
333 DELEGATE_TO_WEBCONTEXT_1(blendEquation, GC3Denum)
334 DELEGATE_TO_WEBCONTEXT_2(blendEquationSeparate, GC3Denum, GC3Denum)
335 DELEGATE_TO_WEBCONTEXT_2(blendFunc, GC3Denum, GC3Denum)
336 DELEGATE_TO_WEBCONTEXT_4(blendFuncSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Den um)
337
338 void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage)
339 {
340 bufferData(target, size, 0, usage);
341 }
342
343 DELEGATE_TO_WEBCONTEXT_4(bufferData, GC3Denum, GC3Dsizeiptr, const void*, GC3Den um)
344 DELEGATE_TO_WEBCONTEXT_4(bufferSubData, GC3Denum, GC3Dintptr, GC3Dsizeiptr, cons t void*)
345
346 DELEGATE_TO_WEBCONTEXT_1R(checkFramebufferStatus, GC3Denum, GC3Denum)
347 DELEGATE_TO_WEBCONTEXT_1(clear, GC3Dbitfield)
348 DELEGATE_TO_WEBCONTEXT_4(clearColor, GC3Dclampf, GC3Dclampf, GC3Dclampf, GC3Dcla mpf)
349 DELEGATE_TO_WEBCONTEXT_1(clearDepth, GC3Dclampf)
350 DELEGATE_TO_WEBCONTEXT_1(clearStencil, GC3Dint)
351 DELEGATE_TO_WEBCONTEXT_4(colorMask, GC3Dboolean, GC3Dboolean, GC3Dboolean, GC3Db oolean)
352 DELEGATE_TO_WEBCONTEXT_1(compileShader, Platform3DObject)
353
354 DELEGATE_TO_WEBCONTEXT_8(compressedTexImage2D, GC3Denum, GC3Dint, GC3Denum, GC3D int, GC3Dint, GC3Dsizei, GC3Dsizei, const void*)
355 DELEGATE_TO_WEBCONTEXT_9(compressedTexSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC 3Dint, GC3Dint, GC3Dint, GC3Denum, GC3Dsizei, const void*)
356 DELEGATE_TO_WEBCONTEXT_8(copyTexImage2D, GC3Denum, GC3Dint, GC3Denum, GC3Dint, G C3Dint, GC3Dsizei, GC3Dsizei, GC3Dint)
357 DELEGATE_TO_WEBCONTEXT_8(copyTexSubImage2D, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
358 DELEGATE_TO_WEBCONTEXT_1(cullFace, GC3Denum)
359 DELEGATE_TO_WEBCONTEXT_1(depthFunc, GC3Denum)
360 DELEGATE_TO_WEBCONTEXT_1(depthMask, GC3Dboolean)
361 DELEGATE_TO_WEBCONTEXT_2(depthRange, GC3Dclampf, GC3Dclampf)
362 DELEGATE_TO_WEBCONTEXT_2(detachShader, Platform3DObject, Platform3DObject)
363 DELEGATE_TO_WEBCONTEXT_1(disable, GC3Denum)
364 DELEGATE_TO_WEBCONTEXT_1(disableVertexAttribArray, GC3Duint)
365 DELEGATE_TO_WEBCONTEXT_3(drawArrays, GC3Denum, GC3Dint, GC3Dsizei)
366 DELEGATE_TO_WEBCONTEXT_4(drawElements, GC3Denum, GC3Dsizei, GC3Denum, GC3Dintptr )
367
368 DELEGATE_TO_WEBCONTEXT_1(enable, GC3Denum)
369 DELEGATE_TO_WEBCONTEXT_1(enableVertexAttribArray, GC3Duint)
370 DELEGATE_TO_WEBCONTEXT(finish)
371 DELEGATE_TO_WEBCONTEXT(flush)
372 DELEGATE_TO_WEBCONTEXT_4(framebufferRenderbuffer, GC3Denum, GC3Denum, GC3Denum, Platform3DObject)
373 DELEGATE_TO_WEBCONTEXT_5(framebufferTexture2D, GC3Denum, GC3Denum, GC3Denum, Pla tform3DObject, GC3Dint)
374 DELEGATE_TO_WEBCONTEXT_1(frontFace, GC3Denum)
375 DELEGATE_TO_WEBCONTEXT_1(generateMipmap, GC3Denum)
376
377 bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index , ActiveInfo& info)
378 {
379 WebKit::WebGraphicsContext3D::ActiveInfo webInfo;
380 if (!m_private->webContext()->getActiveAttrib(program, index, webInfo))
381 return false;
382 info.name = webInfo.name;
383 info.type = webInfo.type;
384 info.size = webInfo.size;
385 return true;
386 }
387
388 bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint inde x, ActiveInfo& info)
389 {
390 WebKit::WebGraphicsContext3D::ActiveInfo webInfo;
391 if (!m_private->webContext()->getActiveUniform(program, index, webInfo))
392 return false;
393 info.name = webInfo.name;
394 info.type = webInfo.type;
395 info.size = webInfo.size;
396 return true;
397 }
398
399 DELEGATE_TO_WEBCONTEXT_4(getAttachedShaders, Platform3DObject, GC3Dsizei, GC3Dsi zei*, Platform3DObject*)
400
401 GC3Dint GraphicsContext3D::getAttribLocation(Platform3DObject program, const Str ing& name)
402 {
403 return m_private->webContext()->getAttribLocation(program, name.utf8().data( ));
404 }
405
406 DELEGATE_TO_WEBCONTEXT_2(getBooleanv, GC3Denum, GC3Dboolean*)
407 DELEGATE_TO_WEBCONTEXT_3(getBufferParameteriv, GC3Denum, GC3Denum, GC3Dint*)
408
409 GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes()
410 {
411 WebKit::WebGraphicsContext3D::Attributes webAttributes = m_private->webConte xt()->getContextAttributes();
412 GraphicsContext3D::Attributes attributes;
413 attributes.alpha = webAttributes.alpha;
414 attributes.depth = webAttributes.depth;
415 attributes.stencil = webAttributes.stencil;
416 attributes.antialias = webAttributes.antialias;
417 attributes.premultipliedAlpha = webAttributes.premultipliedAlpha;
418 attributes.preserveDrawingBuffer = m_private->preserveDrawingBuffer();
419 attributes.preferDiscreteGPU = webAttributes.preferDiscreteGPU;
420 return attributes;
421 }
422
423 DELEGATE_TO_WEBCONTEXT_R(getError, GC3Denum)
424 DELEGATE_TO_WEBCONTEXT_2(getFloatv, GC3Denum, GC3Dfloat*)
425 DELEGATE_TO_WEBCONTEXT_4(getFramebufferAttachmentParameteriv, GC3Denum, GC3Denum , GC3Denum, GC3Dint*)
426 DELEGATE_TO_WEBCONTEXT_2(getIntegerv, GC3Denum, GC3Dint*)
427 DELEGATE_TO_WEBCONTEXT_3(getProgramiv, Platform3DObject, GC3Denum, GC3Dint*)
428
429 String GraphicsContext3D::getProgramInfoLog(Platform3DObject program)
430 {
431 return m_private->webContext()->getProgramInfoLog(program);
Zhenyao Mo 2013/04/08 17:41:15 This can use macro.
432 }
433
434 DELEGATE_TO_WEBCONTEXT_3(getRenderbufferParameteriv, GC3Denum, GC3Denum, GC3Dint *)
435 DELEGATE_TO_WEBCONTEXT_3(getShaderiv, Platform3DObject, GC3Denum, GC3Dint*)
436
437 String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
438 {
439 return m_private->webContext()->getShaderInfoLog(shader);
Zhenyao Mo 2013/04/08 17:41:15 This can use macro.
440 }
441
442 DELEGATE_TO_WEBCONTEXT_4(getShaderPrecisionFormat, GC3Denum, GC3Denum, GC3Dint*, GC3Dint*)
443
444 String GraphicsContext3D::getShaderSource(Platform3DObject shader)
445 {
446 return m_private->webContext()->getShaderSource(shader);
Zhenyao Mo 2013/04/08 17:41:15 This can use macro.
447 }
448
449 String GraphicsContext3D::getString(GC3Denum name)
450 {
451 return m_private->webContext()->getString(name);
Zhenyao Mo 2013/04/08 17:41:15 This can use macro.
452 }
453
454 DELEGATE_TO_WEBCONTEXT_3(getTexParameterfv, GC3Denum, GC3Denum, GC3Dfloat*)
455 DELEGATE_TO_WEBCONTEXT_3(getTexParameteriv, GC3Denum, GC3Denum, GC3Dint*)
456 DELEGATE_TO_WEBCONTEXT_3(getUniformfv, Platform3DObject, GC3Dint, GC3Dfloat*)
457 DELEGATE_TO_WEBCONTEXT_3(getUniformiv, Platform3DObject, GC3Dint, GC3Dint*)
458
459 GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const St ring& name)
460 {
461 return m_private->webContext()->getUniformLocation(program, name.utf8().data ());
462 }
463
464 DELEGATE_TO_WEBCONTEXT_3(getVertexAttribfv, GC3Duint, GC3Denum, GC3Dfloat*)
465 DELEGATE_TO_WEBCONTEXT_3(getVertexAttribiv, GC3Duint, GC3Denum, GC3Dint*)
466 DELEGATE_TO_WEBCONTEXT_2R(getVertexAttribOffset, GC3Duint, GC3Denum, GC3Dsizeipt r)
467
468 DELEGATE_TO_WEBCONTEXT_2(hint, GC3Denum, GC3Denum)
469 DELEGATE_TO_WEBCONTEXT_1R(isBuffer, Platform3DObject, GC3Dboolean)
470 DELEGATE_TO_WEBCONTEXT_1R(isEnabled, GC3Denum, GC3Dboolean)
471 DELEGATE_TO_WEBCONTEXT_1R(isFramebuffer, Platform3DObject, GC3Dboolean)
472 DELEGATE_TO_WEBCONTEXT_1R(isProgram, Platform3DObject, GC3Dboolean)
473 DELEGATE_TO_WEBCONTEXT_1R(isRenderbuffer, Platform3DObject, GC3Dboolean)
474 DELEGATE_TO_WEBCONTEXT_1R(isShader, Platform3DObject, GC3Dboolean)
475 DELEGATE_TO_WEBCONTEXT_1R(isTexture, Platform3DObject, GC3Dboolean)
476 DELEGATE_TO_WEBCONTEXT_1(lineWidth, GC3Dfloat)
477 DELEGATE_TO_WEBCONTEXT_1(linkProgram, Platform3DObject)
478 DELEGATE_TO_WEBCONTEXT_2(pixelStorei, GC3Denum, GC3Dint)
479 DELEGATE_TO_WEBCONTEXT_2(polygonOffset, GC3Dfloat, GC3Dfloat)
480
481 DELEGATE_TO_WEBCONTEXT_7(readPixels, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3 Denum, GC3Denum, void*)
482
483 DELEGATE_TO_WEBCONTEXT(releaseShaderCompiler)
484 DELEGATE_TO_WEBCONTEXT_4(renderbufferStorage, GC3Denum, GC3Denum, GC3Dsizei, GC3 Dsizei)
485 DELEGATE_TO_WEBCONTEXT_2(sampleCoverage, GC3Dclampf, GC3Dboolean)
486 DELEGATE_TO_WEBCONTEXT_4(scissor, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
487
488 void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& stri ng)
489 {
490 m_private->webContext()->shaderSource(shader, string.utf8().data());
491 }
492
493 DELEGATE_TO_WEBCONTEXT_3(stencilFunc, GC3Denum, GC3Dint, GC3Duint)
494 DELEGATE_TO_WEBCONTEXT_4(stencilFuncSeparate, GC3Denum, GC3Denum, GC3Dint, GC3Du int)
495 DELEGATE_TO_WEBCONTEXT_1(stencilMask, GC3Duint)
496 DELEGATE_TO_WEBCONTEXT_2(stencilMaskSeparate, GC3Denum, GC3Duint)
497 DELEGATE_TO_WEBCONTEXT_3(stencilOp, GC3Denum, GC3Denum, GC3Denum)
498 DELEGATE_TO_WEBCONTEXT_4(stencilOpSeparate, GC3Denum, GC3Denum, GC3Denum, GC3Den um)
499
500 bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte rnalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
501 {
502 m_private->webContext()->texImage2D(target, level, internalformat, width, he ight, border, format, type, pixels);
Zhenyao Mo 2013/04/08 17:41:15 We probably should get rid of the return bool and
Ken Russell (switch to Gerrit) 2013/04/08 19:13:04 Agree with getting rid of the no-op bool return va
503 return true;
504 }
505
506 DELEGATE_TO_WEBCONTEXT_3(texParameterf, GC3Denum, GC3Denum, GC3Dfloat)
507 DELEGATE_TO_WEBCONTEXT_3(texParameteri, GC3Denum, GC3Denum, GC3Dint)
508
509 void GraphicsContext3D::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xo ffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3D enum type, const void* pixels)
510 {
511 m_private->webContext()->texSubImage2D(target, level, xoffset, yoffset, widt h, height, format, type, pixels);
Zhenyao Mo 2013/04/08 17:41:15 this one could just use the macro.
512 }
513
514 DELEGATE_TO_WEBCONTEXT_2(uniform1f, GC3Dint, GC3Dfloat)
515 DELEGATE_TO_WEBCONTEXT_3(uniform1fv, GC3Dint, GC3Dsizei, GC3Dfloat*)
516 DELEGATE_TO_WEBCONTEXT_2(uniform1i, GC3Dint, GC3Dint)
517 DELEGATE_TO_WEBCONTEXT_3(uniform1iv, GC3Dint, GC3Dsizei, GC3Dint*)
518 DELEGATE_TO_WEBCONTEXT_3(uniform2f, GC3Dint, GC3Dfloat, GC3Dfloat)
519 DELEGATE_TO_WEBCONTEXT_3(uniform2fv, GC3Dint, GC3Dsizei, GC3Dfloat*)
520 DELEGATE_TO_WEBCONTEXT_3(uniform2i, GC3Dint, GC3Dint, GC3Dint)
521 DELEGATE_TO_WEBCONTEXT_3(uniform2iv, GC3Dint, GC3Dsizei, GC3Dint*)
522 DELEGATE_TO_WEBCONTEXT_4(uniform3f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat)
523 DELEGATE_TO_WEBCONTEXT_3(uniform3fv, GC3Dint, GC3Dsizei, GC3Dfloat*)
524 DELEGATE_TO_WEBCONTEXT_4(uniform3i, GC3Dint, GC3Dint, GC3Dint, GC3Dint)
525 DELEGATE_TO_WEBCONTEXT_3(uniform3iv, GC3Dint, GC3Dsizei, GC3Dint*)
526 DELEGATE_TO_WEBCONTEXT_5(uniform4f, GC3Dint, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC 3Dfloat)
527 DELEGATE_TO_WEBCONTEXT_3(uniform4fv, GC3Dint, GC3Dsizei, GC3Dfloat*)
528 DELEGATE_TO_WEBCONTEXT_5(uniform4i, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint)
529 DELEGATE_TO_WEBCONTEXT_3(uniform4iv, GC3Dint, GC3Dsizei, GC3Dint*)
530 DELEGATE_TO_WEBCONTEXT_4(uniformMatrix2fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3D float*)
531 DELEGATE_TO_WEBCONTEXT_4(uniformMatrix3fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3D float*)
532 DELEGATE_TO_WEBCONTEXT_4(uniformMatrix4fv, GC3Dint, GC3Dsizei, GC3Dboolean, GC3D float*)
533
534 DELEGATE_TO_WEBCONTEXT_1(useProgram, Platform3DObject)
535 DELEGATE_TO_WEBCONTEXT_1(validateProgram, Platform3DObject)
536
537 DELEGATE_TO_WEBCONTEXT_2(vertexAttrib1f, GC3Duint, GC3Dfloat)
538 DELEGATE_TO_WEBCONTEXT_2(vertexAttrib1fv, GC3Duint, GC3Dfloat*)
539 DELEGATE_TO_WEBCONTEXT_3(vertexAttrib2f, GC3Duint, GC3Dfloat, GC3Dfloat)
540 DELEGATE_TO_WEBCONTEXT_2(vertexAttrib2fv, GC3Duint, GC3Dfloat*)
541 DELEGATE_TO_WEBCONTEXT_4(vertexAttrib3f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dflo at)
542 DELEGATE_TO_WEBCONTEXT_2(vertexAttrib3fv, GC3Duint, GC3Dfloat*)
543 DELEGATE_TO_WEBCONTEXT_5(vertexAttrib4f, GC3Duint, GC3Dfloat, GC3Dfloat, GC3Dflo at, GC3Dfloat)
544 DELEGATE_TO_WEBCONTEXT_2(vertexAttrib4fv, GC3Duint, GC3Dfloat*)
545 DELEGATE_TO_WEBCONTEXT_6(vertexAttribPointer, GC3Duint, GC3Dint, GC3Denum, GC3Db oolean, GC3Dsizei, GC3Dintptr)
546
547 DELEGATE_TO_WEBCONTEXT_4(viewport, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei)
548
549 void GraphicsContext3D::reshape(int width, int height)
550 {
551 if (width == m_private->webContext()->width() && height == m_private->webCon text()->height())
552 return;
553
554 m_private->webContext()->reshape(width, height);
555 }
556
557 void GraphicsContext3D::markContextChanged()
558 {
559 m_private->markContextChanged();
560 }
561
562 bool GraphicsContext3D::layerComposited() const
563 {
564 return m_private->layerComposited();
565 }
566
567 void GraphicsContext3D::markLayerComposited()
568 {
569 m_private->markLayerComposited();
570 }
571
572 void GraphicsContext3D::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer, DrawingBuffer* drawingBuffer)
573 {
574 Platform3DObject framebufferId;
575 int width, height;
576 getDrawingParameters(drawingBuffer, m_private->webContext(), &framebufferId, &width, &height);
577 m_private->paintFramebufferToCanvas(framebufferId, width, height, !getContex tAttributes().premultipliedAlpha, imageBuffer);
578 }
579
580 PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData(Drawin gBuffer* drawingBuffer)
581 {
582 if (getContextAttributes().premultipliedAlpha)
583 return 0;
584
585 Platform3DObject framebufferId;
586 int width, height;
587 getDrawingParameters(drawingBuffer, m_private->webContext(), &framebufferId, &width, &height);
588
589 RefPtr<ImageData> imageData = ImageData::create(IntSize(width, height));
590 unsigned char* pixels = imageData->data()->data();
591 size_t bufferSize = 4 * width * height;
592
593 m_private->webContext()->readBackFramebuffer(pixels, bufferSize, framebuffer Id, width, height);
594
595 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT
596 // If the implementation swapped the red and blue channels, un-swap them.
597 for (size_t i = 0; i < bufferSize; i += 4)
598 std::swap(pixels[i], pixels[i + 2]);
599 #endif
600
601 return imageData.release();
602 }
603
604 bool GraphicsContext3D::paintCompositedResultsToCanvas(ImageBuffer*)
605 {
606 return false;
607 }
608
609 DELEGATE_TO_WEBCONTEXT_R(createBuffer, Platform3DObject)
610 DELEGATE_TO_WEBCONTEXT_R(createFramebuffer, Platform3DObject)
611 DELEGATE_TO_WEBCONTEXT_R(createProgram, Platform3DObject)
612 DELEGATE_TO_WEBCONTEXT_R(createRenderbuffer, Platform3DObject)
613 DELEGATE_TO_WEBCONTEXT_1R(createShader, GC3Denum, Platform3DObject)
614 DELEGATE_TO_WEBCONTEXT_R(createTexture, Platform3DObject)
615
616 DELEGATE_TO_WEBCONTEXT_1(deleteBuffer, Platform3DObject)
617 DELEGATE_TO_WEBCONTEXT_1(deleteFramebuffer, Platform3DObject)
618 DELEGATE_TO_WEBCONTEXT_1(deleteProgram, Platform3DObject)
619 DELEGATE_TO_WEBCONTEXT_1(deleteRenderbuffer, Platform3DObject)
620 DELEGATE_TO_WEBCONTEXT_1(deleteShader, Platform3DObject)
621 DELEGATE_TO_WEBCONTEXT_1(deleteTexture, Platform3DObject)
622
623 DELEGATE_TO_WEBCONTEXT_1(synthesizeGLError, GC3Denum)
624
625 Extensions3D* GraphicsContext3D::getExtensions()
626 {
627 return m_private->getExtensions();
628 }
629
630 IntSize GraphicsContext3D::getInternalFramebufferSize() const
631 {
632 return IntSize(m_private->webContext()->width(), m_private->webContext()->he ight());
633 }
634
113 bool GraphicsContext3D::texImage2DResourceSafe(GC3Denum target, GC3Dint level, G C3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3De num format, GC3Denum type, GC3Dint unpackAlignment) 635 bool GraphicsContext3D::texImage2DResourceSafe(GC3Denum target, GC3Dint level, G C3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3De num format, GC3Denum type, GC3Dint unpackAlignment)
114 { 636 {
115 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8); 637 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8);
116 OwnArrayPtr<unsigned char> zero; 638 OwnArrayPtr<unsigned char> zero;
117 if (!isResourceSafe() && width > 0 && height > 0) { 639 if (!isResourceSafe() && width > 0 && height > 0) {
118 unsigned int size; 640 unsigned int size;
119 GC3Denum error = computeImageSizeInBytes(format, type, width, height, un packAlignment, &size, 0); 641 GC3Denum error = computeImageSizeInBytes(format, type, width, height, un packAlignment, &size, 0);
120 if (error != GraphicsContext3D::NO_ERROR) { 642 if (error != GraphicsContext3D::NO_ERROR) {
121 synthesizeGLError(error); 643 synthesizeGLError(error);
122 return false; 644 return false;
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 case GraphicsContext3D::DEPTH_STENCIL: 1989 case GraphicsContext3D::DEPTH_STENCIL:
1468 return ChannelDepth | ChannelStencil; 1990 return ChannelDepth | ChannelStencil;
1469 default: 1991 default:
1470 return 0; 1992 return 0;
1471 } 1993 }
1472 } 1994 }
1473 1995
1474 } // namespace WebCore 1996 } // namespace WebCore
1475 1997
1476 #endif // USE(3D_GRAPHICS) 1998 #endif // USE(3D_GRAPHICS)
OLDNEW
« no previous file with comments | « Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698