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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkConfig8888.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkConfig8888.h
diff --git a/src/core/SkConfig8888.h b/src/core/SkConfig8888.h
index 041773e6df433c22297bb2dd82d9d625b02c862a..97a3433ad24281f289d50c3b00c708a8066c9cf7 100644
--- a/src/core/SkConfig8888.h
+++ b/src/core/SkConfig8888.h
@@ -5,75 +5,27 @@
* found in the LICENSE file.
*/
-#ifndef SkConfig8888_DEFINED
-#define SkConfig8888_DEFINED
+#ifndef SkPixelInfo_DEFINED
+#define SkPixelInfo_DEFINED
-#include "SkCanvas.h"
-#include "SkColorPriv.h"
+#include "SkImageInfo.h"
-/**
- * Converts pixels from one Config8888 to another Config8888
- */
-void SkConvertConfig8888Pixels(uint32_t* dstPixels,
- size_t dstRowBytes,
- SkCanvas::Config8888 dstConfig,
- const uint32_t* srcPixels,
- size_t srcRowBytes,
- SkCanvas::Config8888 srcConfig,
- int width,
- int height);
-
-/**
- * Packs a, r, g, b, values into byte order specified by config.
- */
-uint32_t SkPackConfig8888(SkCanvas::Config8888 config,
- uint32_t a,
- uint32_t r,
- uint32_t g,
- uint32_t b);
-
-///////////////////////////////////////////////////////////////////////////////
-// Implementation
-
-namespace {
+struct SkPixelInfo {
+ SkColorType fColorType;
+ SkAlphaType fAlphaType;
+ size_t fRowBytes;
+};
-/**
- Copies all pixels from a bitmap to a dst ptr with a given rowBytes and
- Config8888. The bitmap must have kARGB_8888_Config.
- */
-
-static inline void SkCopyBitmapToConfig8888(uint32_t* dstPixels,
- size_t dstRowBytes,
- SkCanvas::Config8888 dstConfig8888,
- const SkBitmap& srcBmp) {
- SkASSERT(SkBitmap::kARGB_8888_Config == srcBmp.config());
- SkAutoLockPixels alp(srcBmp);
- int w = srcBmp.width();
- int h = srcBmp.height();
- size_t srcRowBytes = srcBmp.rowBytes();
- const uint32_t* srcPixels = reinterpret_cast<uint32_t*>(srcBmp.getPixels());
-
- SkConvertConfig8888Pixels(dstPixels, dstRowBytes, dstConfig8888, srcPixels, srcRowBytes, SkCanvas::kNative_Premul_Config8888, w, h);
-}
-
-/**
- Copies over all pixels in a bitmap from a src ptr with a given rowBytes and
- Config8888. The bitmap must have pixels and be kARGB_8888_Config.
- */
-static inline void SkCopyConfig8888ToBitmap(const SkBitmap& dstBmp,
- const uint32_t* srcPixels,
- size_t srcRowBytes,
- SkCanvas::Config8888 srcConfig8888) {
- SkASSERT(SkBitmap::kARGB_8888_Config == dstBmp.config());
- SkAutoLockPixels alp(dstBmp);
- int w = dstBmp.width();
- int h = dstBmp.height();
- size_t dstRowBytes = dstBmp.rowBytes();
- uint32_t* dstPixels = reinterpret_cast<uint32_t*>(dstBmp.getPixels());
+struct SkDstPixelInfo : SkPixelInfo {
+ void* fPixels;
+};
- SkConvertConfig8888Pixels(dstPixels, dstRowBytes, SkCanvas::kNative_Premul_Config8888, srcPixels, srcRowBytes, srcConfig8888, w, h);
-}
+struct SkSrcPixelInfo : SkPixelInfo {
+ const void* fPixels;
-}
+ // Guaranteed to work even if src.fPixels and dst.fPixels are the same
+ // (but not if they overlap partially)
+ bool convertPixelsTo(SkDstPixelInfo* dst, int width, int height) const;
+};
#endif
« 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