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

Side by Side Diff: src/core/SkRasterPipeline.cpp

Issue 2147533002: SkRasterPipeline preliminaries (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add & 0xff... >> is arithmetic for Sk4i Created 4 years, 5 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
« no previous file with comments | « src/core/SkRasterPipeline.h ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkRasterPipeline.h"
9
10 SkRasterPipeline::SkRasterPipeline() {}
11
12 void SkRasterPipeline::append(SkRasterPipeline::Fn body, const void* body_ctx,
13 SkRasterPipeline::Fn tail, const void* tail_ctx) {
14 // For now, just stash the stage's function in its own fNext slot.
15 // We'll rewire our stages before running the pipeline so fNext makes sense.
16 fBody.push_back({ body, const_cast<void*>(body_ctx) });
herb_g 2016/07/12 18:14:25 SkASSERT(!fReadyToRun)
mtklein_C 2016/07/12 18:24:16 Done.
17 fTail.push_back({ tail, const_cast<void*>(tail_ctx) });
18 }
19
20 void SkRasterPipeline::Rewire(SkRasterPipeline::Stages* stages) {
21 SkASSERT(!stages->empty());
herb_g 2016/07/12 18:14:25 RedayToRun assert here too
mtklein_C 2016/07/12 18:24:16 Done, by inlining Rewire() into run() as a lambda.
22
23 // Rotate the fNext pointers so they point to the next function to
24 // call, not function we're currently calling as set by append().
25 auto start = stages->front().fNext;
26 for (int i = 0; i < stages->count() - 1; i++) {
27 (*stages)[i].fNext = (*stages)[i+1].fNext;
28 }
29 stages->back().fNext = start; // This is a pretty handy place to stash this .
30 }
31
32 void SkRasterPipeline::run(size_t n) {
33 if (fBody.empty() || fTail.empty()) {
34 return;
35 }
36
37 if (!fReadyToRun) {
38 Rewire(&fBody);
39 Rewire(&fTail);
40 fReadyToRun = true;
41 }
42
43 // It's fastest to start uninitialized if the compilers all let us. If not, next fastest is 0.
44 Sk4f v;
45
46 size_t x = 0;
47 while (n >= 4) {
48 auto start = fBody.back().fNext; // See Rewire().
49 start(fBody.begin(), x, v,v,v,v, v,v,v,v);
50
51 x += 4;
52 n -= 4;
53 }
54 while (n > 0) {
55 auto start = fTail.back().fNext;
56 start(fTail.begin(), x, v,v,v,v, v,v,v,v);
57
58 x += 1;
59 n -= 1;
60 }
61 }
OLDNEW
« no previous file with comments | « src/core/SkRasterPipeline.h ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698