OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 SkPixelInfo_DEFINED | 8 #ifndef SkPixelInfo_DEFINED |
9 #define SkPixelInfo_DEFINED | 9 #define SkPixelInfo_DEFINED |
10 | 10 |
11 #include "SkImageInfo.h" | 11 #include "SkImageInfo.h" |
12 | 12 |
13 class SkColorTable; | 13 class SkColorTable; |
14 | 14 |
15 struct SkPixelInfo { | 15 struct SkPixelInfo { |
16 SkColorType fColorType; | 16 SkColorType fColorType; |
17 SkAlphaType fAlphaType; | 17 SkAlphaType fAlphaType; |
18 size_t fRowBytes; | 18 size_t fRowBytes; |
19 | 19 |
20 static bool CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t d
stRowBytes, | 20 static bool CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t d
stRowBytes, |
21 const SkImageInfo& srcInfo, const void* srcPixels, si
ze_t srcRowBytes, | 21 const SkImageInfo& srcInfo, const void* srcPixels, si
ze_t srcRowBytes, |
22 SkColorTable* srcCTable = NULL); | 22 SkColorTable* srcCTable = nullptr); |
23 }; | 23 }; |
24 | 24 |
25 struct SkDstPixelInfo : SkPixelInfo { | 25 struct SkDstPixelInfo : SkPixelInfo { |
26 void* fPixels; | 26 void* fPixels; |
27 }; | 27 }; |
28 | 28 |
29 struct SkSrcPixelInfo : SkPixelInfo { | 29 struct SkSrcPixelInfo : SkPixelInfo { |
30 const void* fPixels; | 30 const void* fPixels; |
31 | 31 |
32 // Guaranteed to work even if src.fPixels and dst.fPixels are the same | 32 // Guaranteed to work even if src.fPixels and dst.fPixels are the same |
33 // (but not if they overlap partially) | 33 // (but not if they overlap partially) |
34 bool convertPixelsTo(SkDstPixelInfo* dst, int width, int height) const; | 34 bool convertPixelsTo(SkDstPixelInfo* dst, int width, int height) const; |
35 }; | 35 }; |
36 | 36 |
37 static inline void SkRectMemcpy(void* dst, size_t dstRB, const void* src, size_t
srcRB, | 37 static inline void SkRectMemcpy(void* dst, size_t dstRB, const void* src, size_t
srcRB, |
38 size_t bytesPerRow, int rowCount) { | 38 size_t bytesPerRow, int rowCount) { |
39 SkASSERT(bytesPerRow <= srcRB); | 39 SkASSERT(bytesPerRow <= srcRB); |
40 SkASSERT(bytesPerRow <= dstRB); | 40 SkASSERT(bytesPerRow <= dstRB); |
41 for (int i = 0; i < rowCount; ++i) { | 41 for (int i = 0; i < rowCount; ++i) { |
42 memcpy(dst, src, bytesPerRow); | 42 memcpy(dst, src, bytesPerRow); |
43 dst = (char*)dst + dstRB; | 43 dst = (char*)dst + dstRB; |
44 src = (const char*)src + srcRB; | 44 src = (const char*)src + srcRB; |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 #endif | 48 #endif |
OLD | NEW |