aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-02-17 07:15:29 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-17 07:15:30 -0800
commitd96e7e503fd24825a6717d58e90a97f95e8ebbc6 (patch)
tree0450239b255fa7375f7c0e0ed8517258133398bf /src
parent34d26b965237de84ffc54eaf6213fd8bb07c10d1 (diff)
misc fixes to make float buffers work a little better
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmap.cpp14
-rw-r--r--src/core/SkBlitter.cpp4
-rw-r--r--src/core/SkConfig8888.cpp13
3 files changed, 30 insertions, 1 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index bdf1daafcc..fdb66b378b 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -563,6 +563,8 @@ void* SkBitmap::getAddr(int x, int y) const {
return base;
}
+#include "SkHalf.h"
+
SkColor SkBitmap::getColor(int x, int y) const {
SkASSERT((unsigned)x < (unsigned)this->width());
SkASSERT((unsigned)y < (unsigned)this->height());
@@ -599,6 +601,18 @@ SkColor SkBitmap::getColor(int x, int y) const {
SkPMColor c = SkSwizzle_RGBA_to_PMColor(addr[0]);
return SkUnPreMultiply::PMColorToColor(c);
}
+ case kRGBA_F16_SkColorType: {
+ const uint64_t* addr = (const uint64_t*)fPixels + y * (fRowBytes >> 3) + x;
+ Sk4f p4 = SkHalfToFloat_01(addr[0]);
+ if (p4[3]) {
+ float inva = 1 / p4[3];
+ p4 = p4 * Sk4f(inva, inva, inva, 1);
+ }
+ SkColor c;
+ SkNx_cast<uint8_t>(p4 * Sk4f(255) + Sk4f(0.5f)).store(&c);
+ // p4 is RGBA, but we want BGRA, so we need to swap next
+ return SkSwizzle_RB(c);
+ }
default:
SkASSERT(false);
return 0;
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp
index 45219c50cb..a3dbe5e80f 100644
--- a/src/core/SkBlitter.cpp
+++ b/src/core/SkBlitter.cpp
@@ -127,6 +127,10 @@ static uint8_t generate_right_mask(int maskBitCount) {
void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
SkASSERT(mask.fBounds.contains(clip));
+ if (mask.fFormat == SkMask::kLCD16_Format) {
+ return; // needs to be handled by subclass
+ }
+
if (mask.fFormat == SkMask::kBW_Format) {
int cx = clip.fLeft;
int cy = clip.fTop;
diff --git a/src/core/SkConfig8888.cpp b/src/core/SkConfig8888.cpp
index 53f35c3737..e2dd1020de 100644
--- a/src/core/SkConfig8888.cpp
+++ b/src/core/SkConfig8888.cpp
@@ -173,9 +173,20 @@ bool SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t
if (srcInfo.dimensions() != dstInfo.dimensions()) {
return false;
}
-
+
const int width = srcInfo.width();
const int height = srcInfo.height();
+
+ // Do the easiest one first : both configs are equal
+ if ((srcInfo == dstInfo) && !ctable) {
+ size_t bytes = width * srcInfo.bytesPerPixel();
+ for (int y = 0; y < height; ++y) {
+ memcpy(dstPixels, srcPixels, bytes);
+ srcPixels = (const char*)srcPixels + srcRB;
+ dstPixels = (char*)dstPixels + dstRB;
+ }
+ return true;
+ }
// Handle fancy alpha swizzling if both are ARGB32
if (4 == srcInfo.bytesPerPixel() && 4 == dstInfo.bytesPerPixel()) {