From 99578d24c0abd5b0e4fa2fc40b44fbec0c2bd627 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Thu, 14 Dec 2017 21:13:47 -0500 Subject: SkBitmap now *has* a SkPixmap. Before: class SkBitmap { sk_sp fPixelRef; void* fPixels; SkImageInfo fInfo; uint32_t fRowBytes; uint8_t fFlags; }; After: class SkBitmap { sk_sp fPixelRef; SkPixmap fPixmap; uint8_t fFlags; }; Change-Id: I62d59ca3e702b7adea022cd3cfbf0cc3186af957 Reviewed-on: https://skia-review.googlesource.com/85560 Commit-Queue: Hal Canary Reviewed-by: Cary Clark Reviewed-by: Leon Scroggins --- docs/SkBitmap_Reference.bmh | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'docs/SkBitmap_Reference.bmh') diff --git a/docs/SkBitmap_Reference.bmh b/docs/SkBitmap_Reference.bmh index 94a993ce89..5eba984ebb 100644 --- a/docs/SkBitmap_Reference.bmh +++ b/docs/SkBitmap_Reference.bmh @@ -122,7 +122,7 @@ is useful to position one or more Bitmaps within a shared pixel array. # peekPixels # Returns Pixmap if possible. ## # pixelRef # Returns Pixel_Ref, or nullptr. ## # pixelRefOrigin # Returns offset within Pixel_Ref. ## -# pixmap() # Returns Pixmap if possible. ## +# pixmap() # Returns Pixmap. ## # readPixels # Copies and converts pixels. ## # readyToDraw # Returns true if address of pixels is not nullptr. ## # refColorSpace # Returns Image_Info Color_Space. ## @@ -448,16 +448,12 @@ two width:1 height:1 colorType:kRGBA_8888_SkColorType alphaType:kOpaque_SkAlphaT # ------------------------------------------------------------------------------ -#Method SkPixmap pixmap() const +#Method const SkPixmap& pixmap() const -Returns Pixmap with Bitmap pixel address, row bytes, and Image_Info, if address -is available. If pixel address is not available, returns default constructed -Pixmap: nullptr pixels, kUnknown_SkColorType, kUnknown_SkAlphaType, width and -height of zero. +Returns a constant reference to the Pixmap holding the Bitmap pixel +address, row bytes, and Image_Info. -Returned Pixmap becomes invalid on any future change to Bitmap - -#Return Pixmap describing Bitmap, if pixels are readable; otherwise containing zeroes ## +#Return reference to Pixmap describing this Bitmap. ## #Example SkBitmap bitmap; @@ -466,13 +462,12 @@ Returned Pixmap becomes invalid on any future change to Bitmap offscreen.clear(SK_ColorWHITE); SkPaint paint; offscreen.drawString("&", 0, 10, paint); - SkPixmap pixmap = bitmap.pixmap(); + const SkPixmap& pixmap = bitmap.pixmap(); if (pixmap.addr()) { - const SkPMColor* pixels = pixmap.addr32(); - SkPMColor pmWhite = pixels[0]; - for (int y = 0; y < bitmap.height(); ++y) { - for (int x = 0; x < bitmap.width(); ++x) { - SkDebugf("%c", *pixels++ == pmWhite ? '-' : 'x'); + SkPMColor pmWhite = *pixmap.addr32(0, 0); + for (int y = 0; y < pixmap.height(); ++y) { + for (int x = 0; x < pixmap.width(); ++x) { + SkDebugf("%c", *pixmap.addr32(x, y) == pmWhite ? '-' : 'x'); } SkDebugf("\n"); } -- cgit v1.2.3