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

Unified Diff: src/core/SkPixmap.cpp

Issue 1666343002: add kRGBA_F16_SkColorType (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add unittest Created 4 years, 10 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/SkColor.cpp ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPixmap.cpp
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index e2d4d30ebff3a07aa07368262ba7b31f1427ca26..f28566871a0ebbf09391b1971f86aac01dd84bfe 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -207,6 +207,41 @@ bool SkPixmap::erase(SkColor color, const SkIRect& inArea) const {
return true;
}
+#include "SkNx.h"
+#include "SkHalf.h"
+
+static void sk_memset64(uint64_t dst[], uint64_t value, int count) {
+ for (int i = 0; i < count; ++i) {
+ dst[i] = value;
+ }
+}
+
+bool SkPixmap::erase(const SkColor4f& origColor, const SkIRect* subset) const {
+ SkPixmap pm;
+ if (subset) {
+ if (!this->extractSubset(&pm, *subset)) {
+ return false;
+ }
+ } else {
+ pm = *this;
+ }
+
+ const SkColor4f color = origColor.pin();
+
+ if (kRGBA_F16_SkColorType != pm.colorType()) {
+ Sk4f c4 = Sk4f::Load(color.vec());
+ SkColor c;
+ (c4 * Sk4f(255) + Sk4f(0.5f)).store(&c);
+ return pm.erase(c);
+ }
+
+ const uint64_t half4 = color.premul().toF16();
+ for (int y = 0; y < pm.height(); ++y) {
+ sk_memset64(pm.writable_addr64(0, y), half4, pm.width());
+ }
+ return true;
+}
+
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkSurface.h"
« no previous file with comments | « src/core/SkColor.cpp ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698