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

Side by Side Diff: Source/core/platform/graphics/GraphicsContext3D.h

Issue 15501004: Moved image packing code out of GraphicsContext3D.cpp and into a new file (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/platform/graphics/GraphicsContext3D.cpp » ('j') | 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) 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // INVALID_VALUE if width/height is negative or overflow happens. 469 // INVALID_VALUE if width/height is negative or overflow happens.
470 // INVALID_ENUM if format/type is illegal. 470 // INVALID_ENUM if format/type is illegal.
471 static GC3Denum computeImageSizeInBytes(GC3Denum format, 471 static GC3Denum computeImageSizeInBytes(GC3Denum format,
472 GC3Denum type, 472 GC3Denum type,
473 GC3Dsizei width, 473 GC3Dsizei width,
474 GC3Dsizei height, 474 GC3Dsizei height,
475 GC3Dint alignment, 475 GC3Dint alignment,
476 unsigned int* imageSizeInBytes, 476 unsigned int* imageSizeInBytes,
477 unsigned int* paddingInBytes); 477 unsigned int* paddingInBytes);
478 478
479 // Extracts the contents of the given ImageData into the passed Vector,
480 // packing the pixel data according to the given format and type,
481 // and obeying the flipY and premultiplyAlpha flags. Returns true
482 // upon success.
483 static bool extractImageData(ImageData*,
484 GC3Denum format,
485 GC3Denum type,
486 bool flipY,
487 bool premultiplyAlpha,
488 Vector<uint8_t>& data);
489
490 // Helper function which extracts the user-supplied texture
491 // data, applying the flipY and premultiplyAlpha parameters.
492 // If the data is not tightly packed according to the passed
493 // unpackAlignment, the output data will be tightly packed.
494 // Returns true if successful, false if any error occurred.
495 static bool extractTextureData(unsigned int width, unsigned int height,
496 GC3Denum format, GC3Denum type,
497 unsigned int unpackAlignment,
498 bool flipY, bool premultiplyAlpha,
499 const void* pixels,
500 Vector<uint8_t>& data);
501
502
503 // Attempt to enumerate all possible native image formats to 479 // Attempt to enumerate all possible native image formats to
504 // reduce the amount of temporary allocations during texture 480 // reduce the amount of temporary allocations during texture
505 // uploading. This enum must be public because it is accessed 481 // uploading. This enum must be public because it is accessed
506 // by non-member functions. 482 // by non-member functions.
507 enum DataFormat { 483 enum DataFormat {
508 DataFormatRGBA8 = 0, 484 DataFormatRGBA8 = 0,
509 DataFormatRGBA16F, 485 DataFormatRGBA16F,
510 DataFormatRGBA32F, 486 DataFormatRGBA32F,
511 DataFormatRGB8, 487 DataFormatRGB8,
512 DataFormatRGB16F, 488 DataFormatRGB16F,
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 AlphaDoUnmultiply = 2 729 AlphaDoUnmultiply = 2
754 }; 730 };
755 731
756 enum ImageHtmlDomSource { 732 enum ImageHtmlDomSource {
757 HtmlDomImage = 0, 733 HtmlDomImage = 0,
758 HtmlDomCanvas = 1, 734 HtmlDomCanvas = 1,
759 HtmlDomVideo = 2, 735 HtmlDomVideo = 2,
760 HtmlDomNone = 3 736 HtmlDomNone = 3
761 }; 737 };
762 738
763 // Packs the contents of the given Image which is passed in |pixels| into th e passed Vector
764 // according to the given format and type, and obeying the flipY and AlphaOp flags.
765 // Returns true upon success.
766 static bool packImageData(Image*, const void* pixels, GC3Denum format, GC3De num type, bool flipY, AlphaOp, DataFormat sourceFormat, unsigned width, unsigned height, unsigned sourceUnpackAlignment, Vector<uint8_t>& data);
767
768 class ImageExtractor { 739 class ImageExtractor {
769 public: 740 public:
770 ImageExtractor(Image*, ImageHtmlDomSource, bool premultiplyAlpha, bool i gnoreGammaAndColorProfile); 741 ImageExtractor(Image*, ImageHtmlDomSource, bool premultiplyAlpha, bool i gnoreGammaAndColorProfile);
771 742
772 ~ImageExtractor(); 743 ~ImageExtractor();
773 744
774 bool extractSucceeded() { return m_extractSucceeded; } 745 bool extractSucceeded() { return m_extractSucceeded; }
775 const void* imagePixelData() { return m_imagePixelData; } 746 const void* imagePixelData() { return m_imagePixelData; }
776 unsigned imageWidth() { return m_imageWidth; } 747 unsigned imageWidth() { return m_imageWidth; }
777 unsigned imageHeight() { return m_imageHeight; } 748 unsigned imageHeight() { return m_imageHeight; }
(...skipping 12 matching lines...) Expand all
790 ImageHtmlDomSource m_imageHtmlDomSource; 761 ImageHtmlDomSource m_imageHtmlDomSource;
791 bool m_extractSucceeded; 762 bool m_extractSucceeded;
792 const void* m_imagePixelData; 763 const void* m_imagePixelData;
793 unsigned m_imageWidth; 764 unsigned m_imageWidth;
794 unsigned m_imageHeight; 765 unsigned m_imageHeight;
795 DataFormat m_imageSourceFormat; 766 DataFormat m_imageSourceFormat;
796 AlphaOp m_alphaOp; 767 AlphaOp m_alphaOp;
797 unsigned m_imageSourceUnpackAlignment; 768 unsigned m_imageSourceUnpackAlignment;
798 }; 769 };
799 770
771 // The Following functions are implemented in GraphicsContext3DImagePacking. cpp
772
773 // Packs the contents of the given Image which is passed in |pixels| into th e passed Vector
774 // according to the given format and type, and obeying the flipY and AlphaOp flags.
775 // Returns true upon success.
776 static bool packImageData(Image*, const void* pixels, GC3Denum format, GC3De num type, bool flipY, AlphaOp, DataFormat sourceFormat, unsigned width, unsigned height, unsigned sourceUnpackAlignment, Vector<uint8_t>& data);
777
778 // Extracts the contents of the given ImageData into the passed Vector,
779 // packing the pixel data according to the given format and type,
780 // and obeying the flipY and premultiplyAlpha flags. Returns true
781 // upon success.
782 static bool extractImageData(ImageData*, GC3Denum format, GC3Denum type, boo l flipY, bool premultiplyAlpha, Vector<uint8_t>& data);
783
784 // Helper function which extracts the user-supplied texture
785 // data, applying the flipY and premultiplyAlpha parameters.
786 // If the data is not tightly packed according to the passed
787 // unpackAlignment, the output data will be tightly packed.
788 // Returns true if successful, false if any error occurred.
789 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);
790
791 // End GraphicsContext3DImagePacking.cpp functions
792
800 private: 793 private:
801 friend class Extensions3D; 794 friend class Extensions3D;
802 795
803 GraphicsContext3D(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDra wingBuffer); 796 GraphicsContext3D(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDra wingBuffer);
804 GraphicsContext3D(PassOwnPtr<WebKit::WebGraphicsContext3DProvider>, bool pre serveDrawingBuffer); 797 GraphicsContext3D(PassOwnPtr<WebKit::WebGraphicsContext3DProvider>, bool pre serveDrawingBuffer);
805 798
806 // Helper for packImageData/extractImageData/extractTextureData which implem ent packing of pixel 799 // Helper for packImageData/extractImageData/extractTextureData which implem ent packing of pixel
807 // data into the specified OpenGL destination format and type. 800 // data into the specified OpenGL destination format and type.
808 // A sourceUnpackAlignment of zero indicates that the source 801 // A sourceUnpackAlignment of zero indicates that the source
809 // data is tightly packed. Non-zero values may take a slow path. 802 // data is tightly packed. Non-zero values may take a slow path.
810 // Destination data will have no gaps between rows. 803 // Destination data will have no gaps between rows.
804 // Implemented in GraphicsContext3DImagePacking.cpp
811 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 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);
812 806
813 void paintFramebufferToCanvas(int framebuffer, int width, int height, bool p remultiplyAlpha, ImageBuffer*); 807 void paintFramebufferToCanvas(int framebuffer, int width, int height, bool p remultiplyAlpha, ImageBuffer*);
814 808
815 // Extensions3D support. 809 // Extensions3D support.
816 bool supportsExtension(const String& name); 810 bool supportsExtension(const String& name);
817 bool ensureExtensionEnabled(const String& name); 811 bool ensureExtensionEnabled(const String& name);
818 bool isExtensionEnabled(const String& name); 812 bool isExtensionEnabled(const String& name);
819 813
820 void initializeExtensions(); 814 void initializeExtensions();
(...skipping 29 matching lines...) Expand all
850 // used to resize the Canvas. 844 // used to resize the Canvas.
851 SkBitmap m_resizingBitmap; 845 SkBitmap m_resizingBitmap;
852 846
853 GrContext* m_grContext; 847 GrContext* m_grContext;
854 SkAutoTUnref<GrContext> m_ownedGrContext; 848 SkAutoTUnref<GrContext> m_ownedGrContext;
855 }; 849 };
856 850
857 } // namespace WebCore 851 } // namespace WebCore
858 852
859 #endif // GraphicsContext3D_h 853 #endif // GraphicsContext3D_h
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/platform/graphics/GraphicsContext3D.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698