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

Side by Side Diff: gm/xfer4f.cpp

Issue 1634273002: float components in xfermodes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: disable blitter for official checkin 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkImageInfo.h" 10 #include "SkImageInfo.h"
11 #include "SkXfer4f.h" 11 #include "SkXfermode.h"
12 12
13 static void draw_rect(SkCanvas* canvas, const SkRect& r, SkColor c, SkColorProfi leType profile) { 13 static void draw_rect(SkCanvas* canvas, const SkRect& r, SkColor c, SkColorProfi leType profile) {
14 const SkIRect ir = r.round(); 14 const SkIRect ir = r.round();
15 15
16 SkBitmap bm; 16 SkBitmap bm;
17 bm.allocN32Pixels(ir.width(), ir.height()); 17 bm.allocN32Pixels(ir.width(), ir.height());
18 bm.eraseColor(0xFFFFFFFF); 18 bm.eraseColor(0xFFFFFFFF);
19 SkPixmap pm; 19 SkPixmap pm;
20 bm.peekPixels(&pm); 20 bm.peekPixels(&pm);
21 21
22 uint32_t flags = 0; 22 uint32_t flags = 0;
23 if (SkColorGetA(c) == 0xFF) { 23 if (SkColorGetA(c) == 0xFF) {
24 flags |= kSrcIsOpaque_SkXfer4fFlag; 24 flags |= SkXfermode::kSrcIsOpaque_PM4fFlag;
25 } 25 }
26 if (kSRGB_SkColorProfileType == profile) { 26 if (kSRGB_SkColorProfileType == profile) {
27 flags |= kDstIsSRGB_SkXfer4fFlag; 27 flags |= SkXfermode::kDstIsSRGB_PM4fFlag;
28 } 28 }
29 29
30 const SkPM4f src = SkPM4f::FromPMColor(SkPreMultiplyColor(c)); 30 const SkXfermode::PM4fState state { nullptr, flags };
31 auto proc1 = SkPM4fXfer1ProcFactory(SkXfermode::kSrcOver_Mode, flags); 31
32 const SkPM4f src = SkColor4f::FromColor(c).premul();
33 auto proc1 = SkXfermode::GetPM4fProc1(SkXfermode::kSrcOver_Mode, flags);
32 for (int y = 0; y < ir.height()/2; ++y) { 34 for (int y = 0; y < ir.height()/2; ++y) {
33 proc1(pm.writable_addr32(0, y), src, ir.width()); 35 proc1(state, pm.writable_addr32(0, y), src, ir.width(), nullptr);
34 } 36 }
35 37
36 SkPM4f srcRow[1000]; 38 SkPM4f srcRow[1000];
37 for (int i = 0; i < ir.width(); ++i) { 39 for (int i = 0; i < ir.width(); ++i) {
38 srcRow[i] = src; 40 srcRow[i] = src;
39 } 41 }
40 auto procN = SkPM4fXferNProcFactory(SkXfermode::kSrcOver_Mode, flags); 42 auto procN = SkXfermode::GetPM4fProcN(SkXfermode::kSrcOver_Mode, flags);
41 // +1 to skip a row, so we can see the boundary between proc1 and procN 43 // +1 to skip a row, so we can see the boundary between proc1 and procN
42 for (int y = ir.height()/2 + 1; y < ir.height(); ++y) { 44 for (int y = ir.height()/2 + 1; y < ir.height(); ++y) {
43 procN(pm.writable_addr32(0, y), srcRow, ir.width()); 45 procN(state, pm.writable_addr32(0, y), srcRow, ir.width(), nullptr);
44 } 46 }
45 47
46 canvas->drawBitmap(bm, r.left(), r.top(), nullptr); 48 canvas->drawBitmap(bm, r.left(), r.top(), nullptr);
47 } 49 }
48 50
49 /* 51 /*
50 * Test SkXfer4fProcs directly for src-over, comparing them to current SkColor blits. 52 * Test SkXfer4fProcs directly for src-over, comparing them to current SkColor blits.
51 */ 53 */
52 DEF_SIMPLE_GM(xfer4f_srcover, canvas, 580, 380) { 54 DEF_SIMPLE_GM(xfer4f_srcover, canvas, 580, 380) {
53 const SkScalar W = 50; 55 const SkScalar W = 50;
(...skipping 20 matching lines...) Expand all
74 canvas->drawRect(r, p); 76 canvas->drawRect(r, p);
75 } else { 77 } else {
76 draw_rect(canvas, r, c, (SkColorProfileType)profile); 78 draw_rect(canvas, r, c, (SkColorProfileType)profile);
77 } 79 }
78 canvas->translate(W + 20, 0); 80 canvas->translate(W + 20, 0);
79 } 81 }
80 canvas->restore(); 82 canvas->restore();
81 canvas->translate(0, H + 20); 83 canvas->translate(0, H + 20);
82 } 84 }
83 } 85 }
OLDNEW
« no previous file with comments | « gm/color4f.cpp ('k') | gyp/core.gypi » ('j') | include/core/SkXfermode.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698