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

Unified Diff: gm/xfermodes.cpp

Issue 1685203002: lots of sRGB and F16 blits (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use SkAutoTMalloc 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 | « bench/XferU64Bench.cpp ('k') | gyp/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/xfermodes.cpp
diff --git a/gm/xfermodes.cpp b/gm/xfermodes.cpp
index 9e87c04455d5cb4d82101c37fe4e72b25cf70b98..c1095747adb042ae1f4d0f291894ecfe608fcdd4 100644
--- a/gm/xfermodes.cpp
+++ b/gm/xfermodes.cpp
@@ -293,55 +293,17 @@ private:
DEF_GM( return new XfermodesGM; )
///////////////////////////////////////////////////////////////////////////////////////////////////
-#include "SkNx.h"
-
-static SkPMColor apply_proc(SkPMColor src, SkPMColor dst, SkXfermodeProc4f proc, float src_alpha) {
- SkPM4f src4 = SkPM4f::FromPMColor(src);
- for (int i = 0; i < 4; ++i) {
- src4.fVec[i] *= src_alpha;
- }
- SkPM4f dst4 = SkPM4f::FromPMColor(dst);
- SkPM4f res4 = proc(src4, dst4);
- SkPMColor res;
- SkNx_cast<uint8_t>(Sk4f::Load(res4.fVec) * Sk4f(255) + Sk4f(0.5f)).store(&res);
- return res;
-}
-
-static bool apply_mode(const SkPixmap& res, const SkPixmap& src, const SkPixmap& dst,
- SkXfermode* xfer, float src_alpha) {
- SkXfermode::Mode mode;
- if (!xfer) {
- mode = SkXfermode::kSrcOver_Mode;
- } else if (!xfer->asMode(&mode)) {
- return false;
- }
- SkXfermodeProc4f proc = SkXfermode::GetProc4f(mode);
- if (!proc) {
- return false;
- }
-
- for (int y = 0; y < res.height(); ++y) {
- for (int x = 0; x < res.width(); ++x) {
- *res.writable_addr32(x, y) = apply_proc(*src.addr32(x, y), *dst.addr32(x, y),
- proc, src_alpha);
- }
- }
- return true;
-}
void draw_mode(const SkBitmap& srcB, const SkBitmap& dstB,
SkCanvas* canvas, SkXfermode* mode, SkScalar x, SkScalar y, float src_alpha) {
- SkBitmap resB;
- resB.allocN32Pixels(64, 64);
+ canvas->saveLayer(SkRect::MakeXYWH(x, y, 64, 64), nullptr);
+ canvas->drawBitmap(srcB, x, y, nullptr);
- SkPixmap srcPM, dstPM, resPM;
- srcB.peekPixels(&srcPM);
- dstB.peekPixels(&dstPM);
- resB.peekPixels(&resPM);
+ SkPaint paint;
+ paint.setXfermode(mode);
+ canvas->drawBitmap(dstB, x, y, &paint);
- if (apply_mode(resPM, srcPM, dstPM, mode, src_alpha)) {
- canvas->drawBitmap(resB, x, y, nullptr);
- }
+ canvas->restore();
}
DEF_SIMPLE_GM(xfermodes_proc4f, canvas, 1000, 1000) {
« no previous file with comments | « bench/XferU64Bench.cpp ('k') | gyp/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698