diff options
author | Mike Klein <mtklein@chromium.org> | 2017-09-01 11:20:46 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-01 15:58:47 +0000 |
commit | adbbfa6c06e2dd5f4feb8acb3f820a4ddeb14dbb (patch) | |
tree | 2a53e9657edd39f87c071434e7742401a4ae33a2 /src/core/SkPixmap.cpp | |
parent | 5f13bef50119961c8ba3698393d4afa20dd26b3e (diff) |
pixmap erase fast-path
Brian and I saw a measurable speedup on software path rendering when
calling memset(..., 0, ...) instead of looping over one memset per
scanline. This brings that fast path to the masses.
Change-Id: I792416e30e924efdd6ab40d445148b5c59f7bc62
Reviewed-on: https://skia-review.googlesource.com/41847
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkPixmap.cpp')
-rw-r--r-- | src/core/SkPixmap.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp index 9bc0e23386..5a6b27d8d7 100644 --- a/src/core/SkPixmap.cpp +++ b/src/core/SkPixmap.cpp @@ -116,6 +116,14 @@ bool SkPixmap::erase(SkColor color, const SkIRect& inArea) const { const int width = area.width(); const int rowBytes = this->rowBytes(); + if (color == 0 + && width == this->rowBytesAsPixels() + && inArea == this->bounds()) { + // All formats represent SkColor(0) as byte 0. + memset(this->writable_addr(), 0, height * rowBytes); + return true; + } + switch (this->colorType()) { case kGray_8_SkColorType: { if (255 != a) { |