Bug 1209812 (part 4) - Add comments to SurfaceFormat. r=jrmuizel,Bas.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 22 Oct 2015 23:04:40 -0700
changeset 305318 3b546c86c824d971b8a888a9772bd4c241958880
parent 305317 c566d5a42e84a116835b574bc69b72f4a2ab64ea
child 305319 c11218a05463e65878b122132344d04be680cfef
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, Bas
bugs1209812
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1209812 (part 4) - Add comments to SurfaceFormat. r=jrmuizel,Bas.
gfx/2d/Types.h
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -25,24 +25,38 @@ enum class SurfaceType : int8_t {
   SKIA, /* Surface wrapping a Skia bitmap */
   DUAL_DT, /* Snapshot of a dual drawtarget */
   D2D1_1_IMAGE, /* A D2D 1.1 ID2D1Image SourceSurface */
   RECORDING, /* Surface used for recording */
   TILED /* Surface from a tiled DrawTarget */
 };
 
 enum class SurfaceFormat : int8_t {
-  B8G8R8A8,
-  B8G8R8X8,
-  R8G8B8A8,
-  R8G8B8X8,
-  R5G6B5_UINT16,
+  // The following values are named to reflect layout of colors in memory, from
+  // lowest byte to highest byte. The 32-bit value layout depends on machine
+  // endianness.
+  //               in-memory            32-bit LE value   32-bit BE value
+  B8G8R8A8,     // [BB, GG, RR, AA]     0xAARRGGBB        0xBBGGRRAA
+  B8G8R8X8,     // [BB, GG, RR, 00]     0x00RRGGBB        0xBBGGRR00
+  R8G8B8A8,     // [RR, GG, BB, AA]     0xAABBGGRR        0xRRGGBBAA
+  R8G8B8X8,     // [RR, GG, BB, 00]     0x00BBGGRR        0xRRGGBB00
+
+  // The _UINT16 suffix here indicates that the name reflects the layout when
+  // viewed as a uint16_t value. In memory these values are stored using native
+  // endianness.
+  R5G6B5_UINT16,                    // 0bRRRRRGGGGGGBBBBB
+
+  // This one is a single-byte, so endianness isn't an issue.
   A8,
+
+  // These ones are their own special cases.
   YUV,
   NV12,
+
+  // This represents the unknown format.
   UNKNOWN
 };
 
 inline bool IsOpaque(SurfaceFormat aFormat)
 {
   switch (aFormat) {
   case SurfaceFormat::B8G8R8X8:
   case SurfaceFormat::R8G8B8X8: