OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef GraphicsContext3D_h | 26 #ifndef GraphicsContext3D_h |
27 #define GraphicsContext3D_h | 27 #define GraphicsContext3D_h |
28 | 28 |
29 #include "platform/PlatformExport.h" | 29 #include "platform/PlatformExport.h" |
30 #include "platform/geometry/IntRect.h" | 30 #include "platform/geometry/IntRect.h" |
31 #include "platform/graphics/Extensions3D.h" | |
32 #include "platform/graphics/GraphicsTypes3D.h" | 31 #include "platform/graphics/GraphicsTypes3D.h" |
33 #include "platform/graphics/Image.h" | 32 #include "platform/graphics/Image.h" |
34 #include "platform/weborigin/KURL.h" | 33 #include "platform/weborigin/KURL.h" |
35 #include "third_party/khronos/GLES2/gl2.h" | 34 #include "third_party/khronos/GLES2/gl2.h" |
36 #include "third_party/khronos/GLES2/gl2ext.h" | 35 #include "third_party/khronos/GLES2/gl2ext.h" |
37 #include "third_party/skia/include/core/SkBitmap.h" | 36 #include "third_party/skia/include/core/SkBitmap.h" |
38 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
39 #include "wtf/HashSet.h" | 38 #include "wtf/HashSet.h" |
40 #include "wtf/ListHashSet.h" | 39 #include "wtf/ListHashSet.h" |
41 #include "wtf/Noncopyable.h" | 40 #include "wtf/Noncopyable.h" |
42 #include "wtf/OwnPtr.h" | 41 #include "wtf/OwnPtr.h" |
43 #include "wtf/PassOwnPtr.h" | 42 #include "wtf/PassOwnPtr.h" |
44 #include "wtf/RefCounted.h" | 43 #include "wtf/RefCounted.h" |
45 #include "wtf/text/WTFString.h" | 44 #include "wtf/text/WTFString.h" |
46 | 45 |
47 // FIXME: Find a better way to avoid the name confliction for NO_ERROR. | 46 // FIXME: Find a better way to avoid the name confliction for NO_ERROR. |
48 #if OS(WIN) | 47 #if OS(WIN) |
49 #undef NO_ERROR | 48 #undef NO_ERROR |
50 #endif | 49 #endif |
51 | 50 |
52 class GrContext; | 51 class GrContext; |
53 | 52 |
54 namespace blink { | 53 namespace blink { |
55 class WebGraphicsContext3D; | 54 class WebGraphicsContext3D; |
56 class WebGraphicsContext3DProvider; | 55 class WebGraphicsContext3DProvider; |
57 } | 56 } |
58 | 57 |
59 namespace WebCore { | 58 namespace WebCore { |
60 class DrawingBuffer; | 59 class DrawingBuffer; |
61 class Extensions3D; | |
62 class GraphicsContext3DContextLostCallbackAdapter; | 60 class GraphicsContext3DContextLostCallbackAdapter; |
63 class GraphicsContext3DErrorMessageCallbackAdapter; | 61 class GraphicsContext3DErrorMessageCallbackAdapter; |
64 class Image; | 62 class Image; |
65 class ImageBuffer; | 63 class ImageBuffer; |
66 class IntRect; | 64 class IntRect; |
67 class IntSize; | 65 class IntSize; |
68 | 66 |
69 struct ActiveInfo { | 67 struct ActiveInfo { |
70 String name; | 68 String name; |
71 GLenum type; | 69 GLenum type; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // Synthesizes an OpenGL error which will be returned from a | 295 // Synthesizes an OpenGL error which will be returned from a |
298 // later call to getError. This is used to emulate OpenGL ES | 296 // later call to getError. This is used to emulate OpenGL ES |
299 // 2.0 behavior on the desktop and to enforce additional error | 297 // 2.0 behavior on the desktop and to enforce additional error |
300 // checking mandated by WebGL. | 298 // checking mandated by WebGL. |
301 // | 299 // |
302 // Per the behavior of glGetError, this stores at most one | 300 // Per the behavior of glGetError, this stores at most one |
303 // instance of any given error, and returns them from calls to | 301 // instance of any given error, and returns them from calls to |
304 // getError in the order they were added. | 302 // getError in the order they were added. |
305 void synthesizeGLError(GLenum error); | 303 void synthesizeGLError(GLenum error); |
306 | 304 |
307 // Support for extensions. Returns a non-null object, though not | |
308 // all methods it contains may necessarily be supported on the | |
309 // current hardware. Must call Extensions3D::supports() to | |
310 // determine this. | |
311 Extensions3D* extensions(); | |
312 | |
313 static unsigned getClearBitsByFormat(GLenum); | 305 static unsigned getClearBitsByFormat(GLenum); |
314 | 306 |
315 enum ChannelBits { | 307 enum ChannelBits { |
316 ChannelRed = 1, | 308 ChannelRed = 1, |
317 ChannelGreen = 2, | 309 ChannelGreen = 2, |
318 ChannelBlue = 4, | 310 ChannelBlue = 4, |
319 ChannelAlpha = 8, | 311 ChannelAlpha = 8, |
320 ChannelDepth = 16, | 312 ChannelDepth = 16, |
321 ChannelStencil = 32, | 313 ChannelStencil = 32, |
322 ChannelRGB = ChannelRed | ChannelGreen | ChannelBlue, | 314 ChannelRGB = ChannelRed | ChannelGreen | ChannelBlue, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 ReadbackRGBA, | 392 ReadbackRGBA, |
401 ReadbackSkia | 393 ReadbackSkia |
402 }; | 394 }; |
403 | 395 |
404 // Helper function which does a readback from the currently-bound | 396 // Helper function which does a readback from the currently-bound |
405 // framebuffer into a buffer of a certain size with 4-byte pixels. | 397 // framebuffer into a buffer of a certain size with 4-byte pixels. |
406 void readBackFramebuffer(unsigned char* pixels, int width, int height, Readb
ackOrder, AlphaOp); | 398 void readBackFramebuffer(unsigned char* pixels, int width, int height, Readb
ackOrder, AlphaOp); |
407 | 399 |
408 void setPackAlignment(GLint param); | 400 void setPackAlignment(GLint param); |
409 | 401 |
410 // Extensions3D support. | 402 // Extension support. |
411 bool supportsExtension(const String& name); | 403 bool supportsExtension(const String& name); |
412 bool ensureExtensionEnabled(const String& name); | 404 bool ensureExtensionEnabled(const String& name); |
413 bool isExtensionEnabled(const String& name); | 405 bool isExtensionEnabled(const String& name); |
| 406 bool canUseCopyTextureCHROMIUM(GLenum destFormat, GLenum destType, GLint lev
el); |
| 407 |
| 408 void paintFramebufferToCanvas(int framebuffer, int width, int height, bool p
remultiplyAlpha, ImageBuffer*); |
414 | 409 |
415 private: | 410 private: |
416 friend class Extensions3D; | |
417 | |
418 GraphicsContext3D(PassOwnPtr<blink::WebGraphicsContext3D>, bool preserveDraw
ingBuffer); | 411 GraphicsContext3D(PassOwnPtr<blink::WebGraphicsContext3D>, bool preserveDraw
ingBuffer); |
419 GraphicsContext3D(PassOwnPtr<blink::WebGraphicsContext3DProvider>, bool pres
erveDrawingBuffer); | 412 GraphicsContext3D(PassOwnPtr<blink::WebGraphicsContext3DProvider>, bool pres
erveDrawingBuffer); |
420 GraphicsContext3D(blink::WebGraphicsContext3D* webContext); | 413 GraphicsContext3D(blink::WebGraphicsContext3D* webContext); |
421 | 414 |
422 // Helper for packImageData/extractImageData/extractTextureData which implem
ent packing of pixel | 415 // Helper for packImageData/extractImageData/extractTextureData which implem
ent packing of pixel |
423 // data into the specified OpenGL destination format and type. | 416 // data into the specified OpenGL destination format and type. |
424 // A sourceUnpackAlignment of zero indicates that the source | 417 // A sourceUnpackAlignment of zero indicates that the source |
425 // data is tightly packed. Non-zero values may take a slow path. | 418 // data is tightly packed. Non-zero values may take a slow path. |
426 // Destination data will have no gaps between rows. | 419 // Destination data will have no gaps between rows. |
427 // Implemented in GraphicsContext3DImagePacking.cpp | 420 // Implemented in GraphicsContext3DImagePacking.cpp |
428 static bool packPixels(const uint8_t* sourceData, DataFormat sourceDataForma
t, unsigned width, unsigned height, unsigned sourceUnpackAlignment, unsigned des
tinationFormat, unsigned destinationType, AlphaOp, void* destinationData, bool f
lipY); | 421 static bool packPixels(const uint8_t* sourceData, DataFormat sourceDataForma
t, unsigned width, unsigned height, unsigned sourceUnpackAlignment, unsigned des
tinationFormat, unsigned destinationType, AlphaOp, void* destinationData, bool f
lipY); |
429 | 422 |
430 void paintFramebufferToCanvas(int framebuffer, int width, int height, bool p
remultiplyAlpha, ImageBuffer*); | |
431 // Helper function to flip a bitmap vertically. | 423 // Helper function to flip a bitmap vertically. |
432 void flipVertically(uint8_t* data, int width, int height); | 424 void flipVertically(uint8_t* data, int width, int height); |
433 | 425 |
434 void initializeExtensions(); | 426 void initializeExtensions(); |
435 | 427 |
436 bool preserveDrawingBuffer() const { return m_preserveDrawingBuffer; } | 428 bool preserveDrawingBuffer() const { return m_preserveDrawingBuffer; } |
437 | 429 |
438 OwnPtr<blink::WebGraphicsContext3DProvider> m_provider; | 430 OwnPtr<blink::WebGraphicsContext3DProvider> m_provider; |
439 blink::WebGraphicsContext3D* m_impl; | 431 blink::WebGraphicsContext3D* m_impl; |
440 OwnPtr<GraphicsContext3DContextLostCallbackAdapter> m_contextLostCallbackAda
pter; | 432 OwnPtr<GraphicsContext3DContextLostCallbackAdapter> m_contextLostCallbackAda
pter; |
441 OwnPtr<GraphicsContext3DErrorMessageCallbackAdapter> m_errorMessageCallbackA
dapter; | 433 OwnPtr<GraphicsContext3DErrorMessageCallbackAdapter> m_errorMessageCallbackA
dapter; |
442 OwnPtr<blink::WebGraphicsContext3D> m_ownedWebContext; | 434 OwnPtr<blink::WebGraphicsContext3D> m_ownedWebContext; |
443 OwnPtr<Extensions3D> m_extensions; | |
444 bool m_initializedAvailableExtensions; | 435 bool m_initializedAvailableExtensions; |
445 HashSet<String> m_enabledExtensions; | 436 HashSet<String> m_enabledExtensions; |
446 HashSet<String> m_requestableExtensions; | 437 HashSet<String> m_requestableExtensions; |
447 bool m_layerComposited; | 438 bool m_layerComposited; |
448 bool m_preserveDrawingBuffer; | 439 bool m_preserveDrawingBuffer; |
449 int m_packAlignment; | 440 int m_packAlignment; |
450 | 441 |
451 // If the width and height of the Canvas's backing store don't | 442 // If the width and height of the Canvas's backing store don't |
452 // match those that we were given in the most recent call to | 443 // match those that we were given in the most recent call to |
453 // reshape(), then we need an intermediate bitmap to read back the | 444 // reshape(), then we need an intermediate bitmap to read back the |
454 // frame buffer into. This seems to happen when CSS styles are | 445 // frame buffer into. This seems to happen when CSS styles are |
455 // used to resize the Canvas. | 446 // used to resize the Canvas. |
456 SkBitmap m_resizingBitmap; | 447 SkBitmap m_resizingBitmap; |
457 | 448 |
458 GrContext* m_grContext; | 449 GrContext* m_grContext; |
459 | 450 |
460 // Used to flip a bitmap vertically. | 451 // Used to flip a bitmap vertically. |
461 Vector<uint8_t> m_scanline; | 452 Vector<uint8_t> m_scanline; |
462 }; | 453 }; |
463 | 454 |
464 } // namespace WebCore | 455 } // namespace WebCore |
465 | 456 |
466 #endif // GraphicsContext3D_h | 457 #endif // GraphicsContext3D_h |
OLD | NEW |