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

Side by Side Diff: src/opts/SkRasterPipeline_opts.h

Issue 2477013002: Detect pipelines which can compile to memsets. (Closed)
Patch Set: natty Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef SkRasterPipeline_opts_DEFINED 8 #ifndef SkRasterPipeline_opts_DEFINED
9 #define SkRasterPipeline_opts_DEFINED 9 #define SkRasterPipeline_opts_DEFINED
10 10
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 #include "SkHalf.h" 12 #include "SkHalf.h"
13 #include "SkPM4f.h" 13 #include "SkPM4f.h"
14 #include "SkPM4fPriv.h"
14 #include "SkRasterPipeline.h" 15 #include "SkRasterPipeline.h"
15 #include "SkSRGB.h" 16 #include "SkSRGB.h"
17 #include "SkUtils.h"
16 #include <utility> 18 #include <utility>
17 19
18 namespace { 20 namespace {
19 21
20 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_AVX2 22 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_AVX2
21 static constexpr int N = 8; 23 static constexpr int N = 8;
22 #else 24 #else
23 static constexpr int N = 4; 25 static constexpr int N = 4;
24 #endif 26 #endif
25 27
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 #undef M 494 #undef M
493 } 495 }
494 SkASSERT(false); 496 SkASSERT(false);
495 return just_return; 497 return just_return;
496 } 498 }
497 499
498 namespace SK_OPTS_NS { 500 namespace SK_OPTS_NS {
499 501
500 SI std::function<void(size_t, size_t)> compile_pipeline(const SkRasterPipeli ne::Stage* stages, 502 SI std::function<void(size_t, size_t)> compile_pipeline(const SkRasterPipeli ne::Stage* stages,
501 int nstages) { 503 int nstages) {
504 if (nstages == 2 && stages[0].stage == SkRasterPipeline::constant_color) {
505 SkPM4f src = *(const SkPM4f*)stages[0].ctx;
506 void* dst = stages[1].ctx;
507 switch (stages[1].stage) {
508 case SkRasterPipeline::store_565: {
509 auto v = SkPackRGB16(src.r() * SK_R16_MASK + 0.5f,
510 src.g() * SK_G16_MASK + 0.5f,
511 src.b() * SK_B16_MASK + 0.5f);
512 return [v,dst](size_t x, size_t n) { sk_memset16(*(uint16_t* *)dst + x, v, n); };
513 }
514
515 case SkRasterPipeline::store_srgb: {
516 auto v = Sk4f_toS32(src.to4f_pmorder());
517 return [v,dst](size_t x, size_t n) { sk_memset32(*(uint32_t* *)dst + x, v, n); };
518 }
519
520 case SkRasterPipeline::store_f16: {
521 auto v = src.toF16();
522 return [v,dst](size_t x, size_t n) { sk_memset64(*(uint64_t* *)dst + x, v, n); };
523 }
524
525 default: break;
526 }
527 }
528
502 struct Compiled { 529 struct Compiled {
503 Compiled(const SkRasterPipeline::Stage* stages, int nstages) { 530 Compiled(const SkRasterPipeline::Stage* stages, int nstages) {
504 if (nstages == 0) { 531 if (nstages == 0) {
505 return; 532 return;
506 } 533 }
507 534
508 fBodyStart = enum_to_Fn<Body>(stages[0].stage); 535 fBodyStart = enum_to_Fn<Body>(stages[0].stage);
509 fTailStart = enum_to_Fn<Tail>(stages[0].stage); 536 fTailStart = enum_to_Fn<Tail>(stages[0].stage);
510 for (int i = 0; i < nstages-1; i++) { 537 for (int i = 0; i < nstages-1; i++) {
511 fBody[i].next = enum_to_Fn<Body>(stages[i+1].stage); 538 fBody[i].next = enum_to_Fn<Body>(stages[i+1].stage);
(...skipping 29 matching lines...) Expand all
541 } 568 }
542 569
543 } // namespace SK_OPTS_NS 570 } // namespace SK_OPTS_NS
544 571
545 #undef SI 572 #undef SI
546 #undef STAGE 573 #undef STAGE
547 #undef RGBA_XFERMODE 574 #undef RGBA_XFERMODE
548 #undef RGB_XFERMODE 575 #undef RGB_XFERMODE
549 576
550 #endif//SkRasterPipeline_opts_DEFINED 577 #endif//SkRasterPipeline_opts_DEFINED
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698