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

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

Issue 120633004: use templates instead of macros to build blitters (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBitmapProcState_matrix.h ('k') | src/core/SkBitmapProcState_matrix_template.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* NEON optimized code (C) COPYRIGHT 2009 Motorola 1 /* NEON optimized code (C) COPYRIGHT 2009 Motorola
2 * 2 *
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include "SkBitmapProcState.h" 7 #include "SkBitmapProcState.h"
8 #include "SkPerspIter.h" 8 #include "SkPerspIter.h"
9 #include "SkShader.h" 9 #include "SkShader.h"
10 #include "SkUtils.h" 10 #include "SkUtils.h"
(...skipping 15 matching lines...) Expand all
26 } else { 26 } else {
27 x = x % n; 27 x = x % n;
28 } 28 }
29 } 29 }
30 return x; 30 return x;
31 } 31 }
32 32
33 void decal_nofilter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count); 33 void decal_nofilter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count);
34 void decal_filter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count); 34 void decal_filter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count);
35 35
36 #include "SkBitmapProcState_matrix_template.h"
37
38 ///////////////////////////////////////////////////////////////////////////////
39
36 // Compile neon code paths if needed 40 // Compile neon code paths if needed
37 #if !SK_ARM_NEON_IS_NONE 41 #if !SK_ARM_NEON_IS_NONE
38 42
39 // These are defined in src/opts/SkBitmapProcState_matrixProcs_neon.cpp 43 // These are defined in src/opts/SkBitmapProcState_matrixProcs_neon.cpp
40 extern const SkBitmapProcState::MatrixProc ClampX_ClampY_Procs_neon[]; 44 extern const SkBitmapProcState::MatrixProc ClampX_ClampY_Procs_neon[];
41 extern const SkBitmapProcState::MatrixProc RepeatX_RepeatY_Procs_neon[]; 45 extern const SkBitmapProcState::MatrixProc RepeatX_RepeatY_Procs_neon[];
42 46
43 #endif // !SK_ARM_NEON_IS_NONE 47 #endif // !SK_ARM_NEON_IS_NONE
44 48
45 // Compile non-neon code path if needed 49 // Compile non-neon code path if needed
46 #if !SK_ARM_NEON_IS_ALWAYS 50 #if !SK_ARM_NEON_IS_ALWAYS
47 #define MAKENAME(suffix) ClampX_ClampY ## suffix 51 #define MAKENAME(suffix) ClampX_ClampY ## suffix
48 #define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) 52 #define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max)
49 #define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max) 53 #define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max)
50 #define TILEX_LOW_BITS(fx, max) (((fx) >> 12) & 0xF) 54 #define TILEX_LOW_BITS(fx, max) (((fx) >> 12) & 0xF)
51 #define TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF) 55 #define TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF)
52 #define CHECK_FOR_DECAL 56 #define CHECK_FOR_DECAL
53 #include "SkBitmapProcState_matrix.h" 57 #include "SkBitmapProcState_matrix.h"
54 58
59 class ClampTileProcs {
mtklein 2014/01/03 15:49:57 I usually see these traity classes as structs, whi
reed1 2014/04/11 13:12:27 Done.
60 public:
61 static unsigned X(const SkBitmapProcState&, SkFixed fx, int max) {
62 return SkClampMax(fx >> 16, max);
63 }
64 static unsigned Y(const SkBitmapProcState&, SkFixed fx, int max) {
mtklein 2014/01/03 15:49:57 These Y methods take fy, no?
reed1 2014/04/11 13:12:27 Done.
65 return SkClampMax(fx >> 16, max);
66 }
67 };
68
69 static SkBitmapProcState::MatrixProc ClampX_ClampY_Procs[] = {
70 NoFilterProc_Scale<ClampTileProcs, true>,
71 ClampX_ClampY_filter_scale,
72 NoFilterProc_Affine<ClampTileProcs>,
73 ClampX_ClampY_filter_affine,
74 NoFilterProc_Persp<ClampTileProcs>,
75 ClampX_ClampY_filter_persp
76 };
77
78 // Referenced in opts_check_SSE2.cpp
79 void ClampX_ClampY_nofilter_scale(const SkBitmapProcState& s, uint32_t xy[],
80 int count, int x, int y) {
81 return NoFilterProc_Scale<ClampTileProcs, true>(s, xy, count, x, y);
82 }
83 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s, uint32_t xy[],
84 int count, int x, int y) {
85 return NoFilterProc_Affine<ClampTileProcs>(s, xy, count, x, y);
86 }
87
55 #define MAKENAME(suffix) RepeatX_RepeatY ## suffix 88 #define MAKENAME(suffix) RepeatX_RepeatY ## suffix
56 #define TILEX_PROCF(fx, max) SK_USHIFT16(((fx) & 0xFFFF) * ((max) + 1)) 89 #define TILEX_PROCF(fx, max) SK_USHIFT16(((fx) & 0xFFFF) * ((max) + 1))
57 #define TILEY_PROCF(fy, max) SK_USHIFT16(((fy) & 0xFFFF) * ((max) + 1)) 90 #define TILEY_PROCF(fy, max) SK_USHIFT16(((fy) & 0xFFFF) * ((max) + 1))
58 #define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) 91 #define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
59 #define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) 92 #define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
60 #include "SkBitmapProcState_matrix.h" 93 #include "SkBitmapProcState_matrix.h"
61 #endif 94 #endif
62 95
96 class RepeatTileProcs {
97 public:
98 static unsigned X(const SkBitmapProcState&, SkFixed fx, int max) {
99 return SK_USHIFT16(((fx) & 0xFFFF) * ((max) + 1));
100 }
101 static unsigned Y(const SkBitmapProcState&, SkFixed fx, int max) {
102 return SK_USHIFT16(((fx) & 0xFFFF) * ((max) + 1));
103 }
104 };
105
106 static SkBitmapProcState::MatrixProc RepeatX_RepeatY_Procs[] = {
107 NoFilterProc_Scale<RepeatTileProcs, true>,
108 RepeatX_RepeatY_filter_scale,
109 NoFilterProc_Affine<RepeatTileProcs>,
110 RepeatX_RepeatY_filter_affine,
111 NoFilterProc_Persp<RepeatTileProcs>,
112 RepeatX_RepeatY_filter_persp
113 };
114
63 #define MAKENAME(suffix) GeneralXY ## suffix 115 #define MAKENAME(suffix) GeneralXY ## suffix
64 #define PREAMBLE(state) SkBitmapProcState::FixedTileProc tileProcX = (st ate).fTileProcX; (void) tileProcX; \ 116 #define PREAMBLE(state) SkBitmapProcState::FixedTileProc tileProcX = (st ate).fTileProcX; (void) tileProcX; \
65 SkBitmapProcState::FixedTileProc tileProcY = (st ate).fTileProcY; (void) tileProcY; \ 117 SkBitmapProcState::FixedTileProc tileProcY = (st ate).fTileProcY; (void) tileProcY; \
66 SkBitmapProcState::FixedTileLowBitsProc tileLowB itsProcX = (state).fTileLowBitsProcX; (void) tileLowBitsProcX; \ 118 SkBitmapProcState::FixedTileLowBitsProc tileLowB itsProcX = (state).fTileLowBitsProcX; (void) tileLowBitsProcX; \
67 SkBitmapProcState::FixedTileLowBitsProc tileLowB itsProcY = (state).fTileLowBitsProcY; (void) tileLowBitsProcY 119 SkBitmapProcState::FixedTileLowBitsProc tileLowB itsProcY = (state).fTileLowBitsProcY; (void) tileLowBitsProcY
68 #define PREAMBLE_PARAM_X , SkBitmapProcState::FixedTileProc tileProcX, Sk BitmapProcState::FixedTileLowBitsProc tileLowBitsProcX 120 #define PREAMBLE_PARAM_X , SkBitmapProcState::FixedTileProc tileProcX, Sk BitmapProcState::FixedTileLowBitsProc tileLowBitsProcX
69 #define PREAMBLE_PARAM_Y , SkBitmapProcState::FixedTileProc tileProcY, Sk BitmapProcState::FixedTileLowBitsProc tileLowBitsProcY 121 #define PREAMBLE_PARAM_Y , SkBitmapProcState::FixedTileProc tileProcY, Sk BitmapProcState::FixedTileLowBitsProc tileLowBitsProcY
70 #define PREAMBLE_ARG_X , tileProcX, tileLowBitsProcX 122 #define PREAMBLE_ARG_X , tileProcX, tileLowBitsProcX
71 #define PREAMBLE_ARG_Y , tileProcY, tileLowBitsProcY 123 #define PREAMBLE_ARG_Y , tileProcY, tileLowBitsProcY
72 #define TILEX_PROCF(fx, max) SK_USHIFT16(tileProcX(fx) * ((max) + 1)) 124 #define TILEX_PROCF(fx, max) SK_USHIFT16(tileProcX(fx) * ((max) + 1))
73 #define TILEY_PROCF(fy, max) SK_USHIFT16(tileProcY(fy) * ((max) + 1)) 125 #define TILEY_PROCF(fy, max) SK_USHIFT16(tileProcY(fy) * ((max) + 1))
74 #define TILEX_LOW_BITS(fx, max) tileLowBitsProcX(fx, (max) + 1) 126 #define TILEX_LOW_BITS(fx, max) tileLowBitsProcX(fx, (max) + 1)
75 #define TILEY_LOW_BITS(fy, max) tileLowBitsProcY(fy, (max) + 1) 127 #define TILEY_LOW_BITS(fy, max) tileLowBitsProcY(fy, (max) + 1)
76 #include "SkBitmapProcState_matrix.h" 128 #include "SkBitmapProcState_matrix.h"
77 129
130 class GeneralTileProcs {
131 public:
132 static unsigned X(const SkBitmapProcState& s, SkFixed fx, int max) {
133 return SK_USHIFT16(s.fTileProcX(fx) * ((max) + 1));
134 }
135 static unsigned Y(const SkBitmapProcState& s, SkFixed fx, int max) {
136 return SK_USHIFT16(s.fTileProcY(fx) * ((max) + 1));
137 }
138 };
139
140 static SkBitmapProcState::MatrixProc GeneralXY_Procs[] = {
141 NoFilterProc_Scale<GeneralTileProcs, true>,
142 GeneralXY_filter_scale,
143 NoFilterProc_Affine<GeneralTileProcs>,
144 GeneralXY_filter_affine,
145 NoFilterProc_Persp<GeneralTileProcs>,
146 GeneralXY_filter_persp
147 };
148
149 ///////////////////////////////////////////////////////////////////////////////
150
78 static inline U16CPU fixed_clamp(SkFixed x) 151 static inline U16CPU fixed_clamp(SkFixed x)
79 { 152 {
80 if (x < 0) { 153 if (x < 0) {
81 x = 0; 154 x = 0;
82 } 155 }
83 if (x >> 16) { 156 if (x >> 16) {
84 x = 0xFFFF; 157 x = 0xFFFF;
85 } 158 }
86 return x; 159 return x;
87 } 160 }
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 { 530 {
458 return SK_ARM_NEON_WRAP(RepeatX_RepeatY_Procs)[index]; 531 return SK_ARM_NEON_WRAP(RepeatX_RepeatY_Procs)[index];
459 } 532 }
460 533
461 fTileProcX = choose_tile_proc(fTileModeX); 534 fTileProcX = choose_tile_proc(fTileModeX);
462 fTileProcY = choose_tile_proc(fTileModeY); 535 fTileProcY = choose_tile_proc(fTileModeY);
463 fTileLowBitsProcX = choose_tile_lowbits_proc(fTileModeX); 536 fTileLowBitsProcX = choose_tile_lowbits_proc(fTileModeX);
464 fTileLowBitsProcY = choose_tile_lowbits_proc(fTileModeY); 537 fTileLowBitsProcY = choose_tile_lowbits_proc(fTileModeY);
465 return GeneralXY_Procs[index]; 538 return GeneralXY_Procs[index];
466 } 539 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState_matrix.h ('k') | src/core/SkBitmapProcState_matrix_template.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698