diff options
author | Hal Canary <halcanary@google.com> | 2017-12-14 21:13:47 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-09 16:46:22 +0000 |
commit | 99578d24c0abd5b0e4fa2fc40b44fbec0c2bd627 (patch) | |
tree | 0a1f00691905194d45e70aeea82835c0b2661407 /docs/SkBitmap_Reference.bmh | |
parent | 7e6dc6394518252ae6acd56eea0ac2d19fbc361b (diff) |
SkBitmap now *has* a SkPixmap.
Before:
class SkBitmap {
sk_sp<SkPixelRef> fPixelRef;
void* fPixels;
SkImageInfo fInfo;
uint32_t fRowBytes;
uint8_t fFlags;
};
After:
class SkBitmap {
sk_sp<SkPixelRef> fPixelRef;
SkPixmap fPixmap;
uint8_t fFlags;
};
Change-Id: I62d59ca3e702b7adea022cd3cfbf0cc3186af957
Reviewed-on: https://skia-review.googlesource.com/85560
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'docs/SkBitmap_Reference.bmh')
-rw-r--r-- | docs/SkBitmap_Reference.bmh | 25 |
1 files changed, 10 insertions, 15 deletions
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"); } |