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

Side by Side Diff: src/codec/SkSwizzler.h

Issue 1010903003: Add scanline decoding to SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Cleanups Created 5 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkSwizzler_DEFINED 8 #ifndef SkSwizzler_DEFINED
9 #define SkSwizzler_DEFINED 9 #define SkSwizzler_DEFINED
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 #include "SkColor.h" 12 #include "SkColor.h"
13 #include "SkImageInfo.h" 13 #include "SkImageInfo.h"
14 14
15 class SkSwizzler : public SkNoncopyable { 15 class SkSwizzler : public SkNoncopyable {
16 public: 16 public:
17 /** 17 /**
18 * Enum describing the config of the source data. 18 * Enum describing the config of the source data.
19 */ 19 */
20 enum SrcConfig { 20 enum SrcConfig {
21 kUnknown, // Invalid type.
21 kGray, // 1 byte per pixel 22 kGray, // 1 byte per pixel
22 kIndex, // 1 byte per pixel 23 kIndex, // 1 byte per pixel
23 kRGB, // 3 bytes per pixel 24 kRGB, // 3 bytes per pixel
24 kRGBX, // 4 byes per pixel (ignore 4th) 25 kRGBX, // 4 byes per pixel (ignore 4th)
25 kRGBA, // 4 bytes per pixel 26 kRGBA, // 4 bytes per pixel
26 kRGB_565 // 2 bytes per pixel 27 kRGB_565 // 2 bytes per pixel
27 }; 28 };
28 29
29 static int BytesPerPixel(SrcConfig sc) { 30 static int BytesPerPixel(SrcConfig sc) {
30 switch (sc) { 31 switch (sc) {
(...skipping 26 matching lines...) Expand all
57 */ 58 */
58 static SkSwizzler* CreateSwizzler(SrcConfig sc, const SkPMColor* ctable, 59 static SkSwizzler* CreateSwizzler(SrcConfig sc, const SkPMColor* ctable,
59 const SkImageInfo& info, void* dst, 60 const SkImageInfo& info, void* dst,
60 size_t dstRowBytes, bool skipZeroes); 61 size_t dstRowBytes, bool skipZeroes);
61 /** 62 /**
62 * Swizzle the next line. Call height times, once for each row of source. 63 * Swizzle the next line. Call height times, once for each row of source.
63 * @param src The next row of the source data. 64 * @param src The next row of the source data.
64 * @return Whether the row had non-opaque alpha. 65 * @return Whether the row had non-opaque alpha.
65 */ 66 */
66 bool next(const uint8_t* SK_RESTRICT src); 67 bool next(const uint8_t* SK_RESTRICT src);
68
69 /**
70 * Update the destination row.
71 *
72 * Typically this is done by next, but for a client that wants to manually
73 * modify the destination row (for example, for decoding scanline one at a
74 * time) they can call this before each call to next.
75 * TODO: Maybe replace this with a version of next which allows supplying t he
76 * destination?
77 */
78 void setDstRow(void* dst) { fDstRow = dst; }
67 private: 79 private:
68 /** 80 /**
69 * Method for converting raw data to Skia pixels. 81 * Method for converting raw data to Skia pixels.
70 * @param dstRow Row in which to write the resulting pixels. 82 * @param dstRow Row in which to write the resulting pixels.
71 * @param src Row of src data, in format specified by SrcConfig 83 * @param src Row of src data, in format specified by SrcConfig
72 * @param width Width in pixels 84 * @param width Width in pixels
73 * @param bpp bytes per pixel of the source. 85 * @param bpp bytes per pixel of the source.
74 * @param y Line of source. 86 * @param y Line of source.
75 * @param ctable Colors (used for kIndex source). 87 * @param ctable Colors (used for kIndex source).
76 */ 88 */
77 typedef bool (*RowProc)(void* SK_RESTRICT dstRow, 89 typedef bool (*RowProc)(void* SK_RESTRICT dstRow,
78 const uint8_t* SK_RESTRICT src, 90 const uint8_t* SK_RESTRICT src,
79 int width, int bpp, int y, 91 int width, int bpp, int y,
80 const SkPMColor ctable[]); 92 const SkPMColor ctable[]);
81 93
82 const RowProc fRowProc; 94 const RowProc fRowProc;
83 const SkPMColor* fColorTable; // Unowned pointer 95 const SkPMColor* fColorTable; // Unowned pointer
84 const int fSrcPixelSize; 96 const int fSrcPixelSize;
85 const SkImageInfo fDstInfo; 97 const SkImageInfo fDstInfo;
86 void* fDstRow; 98 void* fDstRow;
87 const size_t fDstRowBytes; 99 const size_t fDstRowBytes;
88 int fCurrY; 100 int fCurrY;
89 101
90 SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcBpp, 102 SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcBpp,
91 const SkImageInfo& info, void* dst, size_t rowBytes); 103 const SkImageInfo& info, void* dst, size_t rowBytes);
92 104
93 }; 105 };
94 #endif // SkSwizzler_DEFINED 106 #endif // SkSwizzler_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698