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

Unified Diff: include/core/SkCanvas.h

Issue 180113010: Add SkCanvas::writePixels that takes info+pixels directly (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkCanvas.h
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 5bdf84d58bdc72f4b97527995bac4adb188f4f59..3a133bb34e0a98d506f3da1b56c6f6a719af9b21 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -18,6 +18,8 @@
#include "SkRegion.h"
#include "SkXfermode.h"
+//#define SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
+
class SkBounder;
class SkBaseDevice;
class SkDraw;
@@ -264,7 +266,9 @@ public:
*/
bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap);
+#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
/**
+ * DEPRECATED
* Similar to draw sprite, this method will copy the pixels in bitmap onto
* the canvas, with the top/left corner specified by (x, y). The canvas'
* pixel values are completely replaced: there is no blending.
@@ -279,9 +283,34 @@ public:
* Note: If you are recording drawing commands on this canvas to
* SkPicture, writePixels() is ignored!
*/
- void writePixels(const SkBitmap& bitmap,
- int x, int y,
- Config8888 config8888 = kNative_Premul_Config8888);
+ void writePixels(const SkBitmap& bitmap, int x, int y, Config8888 config8888);
+#endif
+
+ /**
+ * This method affects the pixels in the base-layer, and operates in pixel coordinates,
+ * ignoring the matrix and clip.
+ *
+ * The specified ImageInfo and (x,y) offset specifies a rectangle: target.
+ *
+ * target.setXYWH(x, y, info.width(), info.height());
+ *
+ * Target is intersected with the bounds of the base-layer. If this intersection is not empty,
+ * then we have two sets of pixels (of equal size), the "src" specified by info+pixels+rowBytes
+ * and the "dst" by the canvas' backend. Replace the dst pixels with the corresponding src
+ * pixels, performing any colortype/alphatype transformations needed (in the case where the
+ * src and dst have different colortypes or alphatypes).
+ *
+ * This call can fail, returning false, for several reasons:
+ * - If the src colortype/alphatype cannot be converted to the canvas' types
+ * - If this canvas is not backed by pixels (e.g. picture or PDF)
+ */
+ bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, int x, int y);
+
+ /**
+ * Helper for calling writePixels(info, ...) by passing its pixels and rowbytes. If the bitmap
+ * is just wrapping a texture, returns false and does nothing.
+ */
+ bool writePixels(const SkBitmap& bitmap, int x, int y);
///////////////////////////////////////////////////////////////////////////
« no previous file with comments | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698