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

Side by Side Diff: src/core/SkConfig8888.h

Issue 199733016: implement readPixels and writePixels natively, w/o using the (deprecated) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkConfig8888.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 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 SkConfig8888_DEFINED 8 #ifndef SkPixelInfo_DEFINED
9 #define SkConfig8888_DEFINED 9 #define SkPixelInfo_DEFINED
10 10
11 #include "SkCanvas.h" 11 #include "SkImageInfo.h"
12 #include "SkColorPriv.h"
13 12
14 /** 13 struct SkPixelInfo {
15 * Converts pixels from one Config8888 to another Config8888 14 SkColorType fColorType;
16 */ 15 SkAlphaType fAlphaType;
17 void SkConvertConfig8888Pixels(uint32_t* dstPixels, 16 size_t fRowBytes;
18 size_t dstRowBytes, 17 };
19 SkCanvas::Config8888 dstConfig,
20 const uint32_t* srcPixels,
21 size_t srcRowBytes,
22 SkCanvas::Config8888 srcConfig,
23 int width,
24 int height);
25 18
26 /** 19 struct SkDstPixelInfo : SkPixelInfo {
27 * Packs a, r, g, b, values into byte order specified by config. 20 void* fPixels;
28 */ 21 };
29 uint32_t SkPackConfig8888(SkCanvas::Config8888 config,
30 uint32_t a,
31 uint32_t r,
32 uint32_t g,
33 uint32_t b);
34 22
35 /////////////////////////////////////////////////////////////////////////////// 23 struct SkSrcPixelInfo : SkPixelInfo {
36 // Implementation 24 const void* fPixels;
37 25
38 namespace { 26 // Guaranteed to work even if src.fPixels and dst.fPixels are the same
39 27 // (but not if they overlap partially)
40 /** 28 bool convertPixelsTo(SkDstPixelInfo* dst, int width, int height) const;
41 Copies all pixels from a bitmap to a dst ptr with a given rowBytes and 29 };
42 Config8888. The bitmap must have kARGB_8888_Config.
43 */
44
45 static inline void SkCopyBitmapToConfig8888(uint32_t* dstPixels,
46 size_t dstRowBytes,
47 SkCanvas::Config8888 dstConfig8888,
48 const SkBitmap& srcBmp) {
49 SkASSERT(SkBitmap::kARGB_8888_Config == srcBmp.config());
50 SkAutoLockPixels alp(srcBmp);
51 int w = srcBmp.width();
52 int h = srcBmp.height();
53 size_t srcRowBytes = srcBmp.rowBytes();
54 const uint32_t* srcPixels = reinterpret_cast<uint32_t*>(srcBmp.getPixels());
55
56 SkConvertConfig8888Pixels(dstPixels, dstRowBytes, dstConfig8888, srcPixels, srcRowBytes, SkCanvas::kNative_Premul_Config8888, w, h);
57 }
58
59 /**
60 Copies over all pixels in a bitmap from a src ptr with a given rowBytes and
61 Config8888. The bitmap must have pixels and be kARGB_8888_Config.
62 */
63 static inline void SkCopyConfig8888ToBitmap(const SkBitmap& dstBmp,
64 const uint32_t* srcPixels,
65 size_t srcRowBytes,
66 SkCanvas::Config8888 srcConfig8888) {
67 SkASSERT(SkBitmap::kARGB_8888_Config == dstBmp.config());
68 SkAutoLockPixels alp(dstBmp);
69 int w = dstBmp.width();
70 int h = dstBmp.height();
71 size_t dstRowBytes = dstBmp.rowBytes();
72 uint32_t* dstPixels = reinterpret_cast<uint32_t*>(dstBmp.getPixels());
73
74 SkConvertConfig8888Pixels(dstPixels, dstRowBytes, SkCanvas::kNative_Premul_C onfig8888, srcPixels, srcRowBytes, srcConfig8888, w, h);
75 }
76
77 }
78 30
79 #endif 31 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkConfig8888.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698