| 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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 | 782 |
| 783 // Helper function which extracts the user-supplied texture | 783 // Helper function which extracts the user-supplied texture |
| 784 // data, applying the flipY and premultiplyAlpha parameters. | 784 // data, applying the flipY and premultiplyAlpha parameters. |
| 785 // If the data is not tightly packed according to the passed | 785 // If the data is not tightly packed according to the passed |
| 786 // unpackAlignment, the output data will be tightly packed. | 786 // unpackAlignment, the output data will be tightly packed. |
| 787 // Returns true if successful, false if any error occurred. | 787 // Returns true if successful, false if any error occurred. |
| 788 static bool extractTextureData(unsigned width, unsigned height, GC3Denum for
mat, GC3Denum type, unsigned unpackAlignment, bool flipY, bool premultiplyAlpha,
const void* pixels, Vector<uint8_t>& data); | 788 static bool extractTextureData(unsigned width, unsigned height, GC3Denum for
mat, GC3Denum type, unsigned unpackAlignment, bool flipY, bool premultiplyAlpha,
const void* pixels, Vector<uint8_t>& data); |
| 789 | 789 |
| 790 // End GraphicsContext3DImagePacking.cpp functions | 790 // End GraphicsContext3DImagePacking.cpp functions |
| 791 | 791 |
| 792 // This is the order of bytes to use when doing a readback. |
| 793 enum ReadbackOrder { |
| 794 ReadbackRGBA, |
| 795 ReadbackSkia |
| 796 }; |
| 797 |
| 798 // Helper function which does a readback from the currently-bound |
| 799 // framebuffer into a buffer of a certain size with 4-byte pixels. |
| 800 void readBackFramebuffer(unsigned char* pixels, int width, int height, Readb
ackOrder, AlphaOp); |
| 801 |
| 792 private: | 802 private: |
| 793 friend class Extensions3D; | 803 friend class Extensions3D; |
| 794 | 804 |
| 795 GraphicsContext3D(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDra
wingBuffer); | 805 GraphicsContext3D(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDra
wingBuffer); |
| 796 GraphicsContext3D(PassOwnPtr<WebKit::WebGraphicsContext3DProvider>, bool pre
serveDrawingBuffer); | 806 GraphicsContext3D(PassOwnPtr<WebKit::WebGraphicsContext3DProvider>, bool pre
serveDrawingBuffer); |
| 797 | 807 |
| 798 // Helper for packImageData/extractImageData/extractTextureData which implem
ent packing of pixel | 808 // Helper for packImageData/extractImageData/extractTextureData which implem
ent packing of pixel |
| 799 // data into the specified OpenGL destination format and type. | 809 // data into the specified OpenGL destination format and type. |
| 800 // A sourceUnpackAlignment of zero indicates that the source | 810 // A sourceUnpackAlignment of zero indicates that the source |
| 801 // data is tightly packed. Non-zero values may take a slow path. | 811 // data is tightly packed. Non-zero values may take a slow path. |
| 802 // Destination data will have no gaps between rows. | 812 // Destination data will have no gaps between rows. |
| 803 // Implemented in GraphicsContext3DImagePacking.cpp | 813 // Implemented in GraphicsContext3DImagePacking.cpp |
| 804 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); | 814 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); |
| 805 | 815 |
| 806 void paintFramebufferToCanvas(int framebuffer, int width, int height, bool p
remultiplyAlpha, ImageBuffer*); | 816 void paintFramebufferToCanvas(int framebuffer, int width, int height, bool p
remultiplyAlpha, ImageBuffer*); |
| 817 // Helper function to flip a bitmap vertically. |
| 818 void flipVertically(uint8_t* data, int width, int height); |
| 807 | 819 |
| 808 // Extensions3D support. | 820 // Extensions3D support. |
| 809 bool supportsExtension(const String& name); | 821 bool supportsExtension(const String& name); |
| 810 bool ensureExtensionEnabled(const String& name); | 822 bool ensureExtensionEnabled(const String& name); |
| 811 bool isExtensionEnabled(const String& name); | 823 bool isExtensionEnabled(const String& name); |
| 812 | 824 |
| 813 void initializeExtensions(); | 825 void initializeExtensions(); |
| 814 | 826 |
| 815 bool preserveDrawingBuffer() const { return m_preserveDrawingBuffer; } | 827 bool preserveDrawingBuffer() const { return m_preserveDrawingBuffer; } |
| 816 | 828 |
| 817 OwnPtr<WebKit::WebGraphicsContext3DProvider> m_provider; | 829 OwnPtr<WebKit::WebGraphicsContext3DProvider> m_provider; |
| 818 WebKit::WebGraphicsContext3D* m_impl; | 830 WebKit::WebGraphicsContext3D* m_impl; |
| 819 OwnPtr<WebKit::WebGraphicsContext3D> m_ownedWebContext; | 831 OwnPtr<WebKit::WebGraphicsContext3D> m_ownedWebContext; |
| 820 OwnPtr<Extensions3D> m_extensions; | 832 OwnPtr<Extensions3D> m_extensions; |
| 821 OwnPtr<GraphicsContext3DContextLostCallbackAdapter> m_contextLostCallbackAda
pter; | 833 OwnPtr<GraphicsContext3DContextLostCallbackAdapter> m_contextLostCallbackAda
pter; |
| 822 OwnPtr<GraphicsContext3DErrorMessageCallbackAdapter> m_errorMessageCallbackA
dapter; | 834 OwnPtr<GraphicsContext3DErrorMessageCallbackAdapter> m_errorMessageCallbackA
dapter; |
| 823 OwnPtr<GrMemoryAllocationChangedCallbackAdapter> m_grContextMemoryAllocation
CallbackAdapter; | 835 OwnPtr<GrMemoryAllocationChangedCallbackAdapter> m_grContextMemoryAllocation
CallbackAdapter; |
| 824 bool m_initializedAvailableExtensions; | 836 bool m_initializedAvailableExtensions; |
| 825 HashSet<String> m_enabledExtensions; | 837 HashSet<String> m_enabledExtensions; |
| 826 HashSet<String> m_requestableExtensions; | 838 HashSet<String> m_requestableExtensions; |
| 827 bool m_layerComposited; | 839 bool m_layerComposited; |
| 828 bool m_preserveDrawingBuffer; | 840 bool m_preserveDrawingBuffer; |
| 841 int m_packAlignment; |
| 829 | 842 |
| 830 enum ResourceSafety { | 843 enum ResourceSafety { |
| 831 ResourceSafetyUnknown, | 844 ResourceSafetyUnknown, |
| 832 ResourceSafe, | 845 ResourceSafe, |
| 833 ResourceUnsafe | 846 ResourceUnsafe |
| 834 }; | 847 }; |
| 835 ResourceSafety m_resourceSafety; | 848 ResourceSafety m_resourceSafety; |
| 836 | 849 |
| 837 // If the width and height of the Canvas's backing store don't | 850 // If the width and height of the Canvas's backing store don't |
| 838 // match those that we were given in the most recent call to | 851 // match those that we were given in the most recent call to |
| 839 // reshape(), then we need an intermediate bitmap to read back the | 852 // reshape(), then we need an intermediate bitmap to read back the |
| 840 // frame buffer into. This seems to happen when CSS styles are | 853 // frame buffer into. This seems to happen when CSS styles are |
| 841 // used to resize the Canvas. | 854 // used to resize the Canvas. |
| 842 SkBitmap m_resizingBitmap; | 855 SkBitmap m_resizingBitmap; |
| 843 | 856 |
| 844 GrContext* m_grContext; | 857 GrContext* m_grContext; |
| 845 SkAutoTUnref<GrContext> m_ownedGrContext; | 858 SkAutoTUnref<GrContext> m_ownedGrContext; |
| 859 |
| 860 // Used to flip a bitmap vertically. |
| 861 Vector<uint8_t> m_scanline; |
| 846 }; | 862 }; |
| 847 | 863 |
| 848 } // namespace WebCore | 864 } // namespace WebCore |
| 849 | 865 |
| 850 #endif // GraphicsContext3D_h | 866 #endif // GraphicsContext3D_h |
| OLD | NEW |