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

Side by Side Diff: src/core/SkBitmapProcState.h

Issue 1153123003: refactor bitmapshader to use a controller (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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/SkBitmapController.cpp ('k') | src/core/SkBitmapProcState.cpp » ('j') | 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 2007 The Android Open Source Project 2 * Copyright 2007 The Android Open Source Project
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 SkBitmapProcState_DEFINED 8 #ifndef SkBitmapProcState_DEFINED
9 #define SkBitmapProcState_DEFINED 9 #define SkBitmapProcState_DEFINED
10 10
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkBitmapController.h"
12 #include "SkBitmapFilter.h" 13 #include "SkBitmapFilter.h"
13 #include "SkMatrix.h" 14 #include "SkMatrix.h"
14 #include "SkMipMap.h" 15 #include "SkMipMap.h"
15 #include "SkPaint.h" 16 #include "SkPaint.h"
16 17
17 typedef SkFixed3232 SkFractionalInt; 18 typedef SkFixed3232 SkFractionalInt;
18 #define SkScalarToFractionalInt(x) SkScalarToFixed3232(x) 19 #define SkScalarToFractionalInt(x) SkScalarToFixed3232(x)
19 #define SkFractionalIntToFixed(x) SkFixed3232ToFixed(x) 20 #define SkFractionalIntToFixed(x) SkFixed3232ToFixed(x)
20 #define SkFixedToFractionalInt(x) SkFixedToFixed3232(x) 21 #define SkFixedToFractionalInt(x) SkFixedToFixed3232(x)
21 #define SkFractionalIntToInt(x) SkFixed3232ToInt(x) 22 #define SkFractionalIntToInt(x) SkFixed3232ToInt(x)
22 23
23 class SkPaint; 24 class SkPaint;
24 25
25 struct SkBitmapProcState { 26 struct SkBitmapProcState {
27 SkBitmapProcState();
28 ~SkBitmapProcState();
29
26 typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y, 30 typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y,
27 SkPMColor[], int count); 31 SkPMColor[], int count);
28 32
29 typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y, 33 typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y,
30 uint16_t[], int count); 34 uint16_t[], int count);
31 35
32 typedef void (*MatrixProc)(const SkBitmapProcState&, 36 typedef void (*MatrixProc)(const SkBitmapProcState&,
33 uint32_t bitmapXY[], 37 uint32_t bitmapXY[],
34 int count, 38 int count,
35 int x, int y); 39 int x, int y);
36 40
37 typedef void (*SampleProc32)(const SkBitmapProcState&, 41 typedef void (*SampleProc32)(const SkBitmapProcState&,
38 const uint32_t[], 42 const uint32_t[],
39 int count, 43 int count,
40 SkPMColor colors[]); 44 SkPMColor colors[]);
41 45
42 typedef void (*SampleProc16)(const SkBitmapProcState&, 46 typedef void (*SampleProc16)(const SkBitmapProcState&,
43 const uint32_t[], 47 const uint32_t[],
44 int count, 48 int count,
45 uint16_t colors[]); 49 uint16_t colors[]);
46 50
47 typedef U16CPU (*FixedTileProc)(SkFixed); // returns 0..0xFFFF 51 typedef U16CPU (*FixedTileProc)(SkFixed); // returns 0..0xFFFF
48 typedef U16CPU (*FixedTileLowBitsProc)(SkFixed, int); // returns 0..0xF 52 typedef U16CPU (*FixedTileLowBitsProc)(SkFixed, int); // returns 0..0xF
49 typedef U16CPU (*IntTileProc)(int value, int count); // returns 0..count-1 53 typedef U16CPU (*IntTileProc)(int value, int count); // returns 0..count-1
50 54
51 const SkBitmap* fBitmap; // chooseProcs - orig or scaled 55 const SkBitmap* fBitmap; // chooseProcs - orig or scaled
52 SkMatrix fInvMatrix; // chooseProcs 56 SkMatrix fInvMatrix; // copy of what is in fBMState, can we remove the dup?
57
53 SkMatrix::MapXYProc fInvProc; // chooseProcs 58 SkMatrix::MapXYProc fInvProc; // chooseProcs
54 59
55 SkFractionalInt fInvSxFractionalInt; 60 SkFractionalInt fInvSxFractionalInt;
56 SkFractionalInt fInvKyFractionalInt; 61 SkFractionalInt fInvKyFractionalInt;
57 62
58 FixedTileProc fTileProcX; // chooseProcs 63 FixedTileProc fTileProcX; // chooseProcs
59 FixedTileProc fTileProcY; // chooseProcs 64 FixedTileProc fTileProcY; // chooseProcs
60 FixedTileLowBitsProc fTileLowBitsProcX; // chooseProcs 65 FixedTileLowBitsProc fTileLowBitsProcX; // chooseProcs
61 FixedTileLowBitsProc fTileLowBitsProcY; // chooseProcs 66 FixedTileLowBitsProc fTileLowBitsProcY; // chooseProcs
62 IntTileProc fIntTileProcY; // chooseProcs 67 IntTileProc fIntTileProcY; // chooseProcs
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 friend class SkBitmapProcShader; 120 friend class SkBitmapProcShader;
116 121
117 ShaderProc32 fShaderProc32; // chooseProcs 122 ShaderProc32 fShaderProc32; // chooseProcs
118 ShaderProc16 fShaderProc16; // chooseProcs 123 ShaderProc16 fShaderProc16; // chooseProcs
119 // These are used if the shaderproc is NULL 124 // These are used if the shaderproc is NULL
120 MatrixProc fMatrixProc; // chooseProcs 125 MatrixProc fMatrixProc; // chooseProcs
121 SampleProc32 fSampleProc32; // chooseProcs 126 SampleProc32 fSampleProc32; // chooseProcs
122 SampleProc16 fSampleProc16; // chooseProcs 127 SampleProc16 fSampleProc16; // chooseProcs
123 128
124 SkBitmap fOrigBitmap; // CONSTRUCTOR 129 SkBitmap fOrigBitmap; // CONSTRUCTOR
125 SkBitmap fScaledBitmap; // chooseProcs
126 130
127 SkAutoTUnref<const SkMipMap> fCurrMip; 131 enum {
robertphillips 2015/06/04 15:27:27 Is there any static assert we could write that wou
128 132 kBMStateSize = 136 // found by inspection. if too small, we will call n ew/delete
129 void processHQRequest(); 133 };
130 void processMediumRequest(); 134 SkAlignedSStorage<kBMStateSize> fBMStateStorage;
135 SkBitmapController::State* fBMState;
131 136
132 MatrixProc chooseMatrixProc(bool trivial_matrix); 137 MatrixProc chooseMatrixProc(bool trivial_matrix);
133 bool chooseProcs(const SkMatrix& inv, const SkPaint&); 138 bool chooseProcs(const SkMatrix& inv, const SkPaint&);
134 bool chooseScanlineProcs(bool trivialMatrix, bool clampClamp, const SkPaint& paint); 139 bool chooseScanlineProcs(bool trivialMatrix, bool clampClamp, const SkPaint& paint);
135 ShaderProc32 chooseShaderProc32(); 140 ShaderProc32 chooseShaderProc32();
136 141
137 // returns false if we failed to "lock" the pixels at all. Typically this
138 // means we have to abort the shader.
139 bool lockBaseBitmap();
140
141 // Return false if we failed to setup for fast translate (e.g. overflow) 142 // Return false if we failed to setup for fast translate (e.g. overflow)
142 bool setupForTranslate(); 143 bool setupForTranslate();
143 144
144 #ifdef SK_DEBUG 145 #ifdef SK_DEBUG
145 static void DebugMatrixProc(const SkBitmapProcState&, 146 static void DebugMatrixProc(const SkBitmapProcState&,
146 uint32_t[], int count, int x, int y); 147 uint32_t[], int count, int x, int y);
147 #endif 148 #endif
148 }; 149 };
149 150
150 /* Macros for packing and unpacking pairs of 16bit values in a 32bit uint. 151 /* Macros for packing and unpacking pairs of 16bit values in a 32bit uint.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s, 189 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s,
189 uint32_t xy[], int count, int x, int y); 190 uint32_t xy[], int count, int x, int y);
190 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s, 191 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s,
191 uint32_t xy[], int count, int x, int y); 192 uint32_t xy[], int count, int x, int y);
192 void S32_D16_filter_DX(const SkBitmapProcState& s, 193 void S32_D16_filter_DX(const SkBitmapProcState& s,
193 const uint32_t* xy, int count, uint16_t* colors); 194 const uint32_t* xy, int count, uint16_t* colors);
194 void S32_D16_filter_DXDY(const SkBitmapProcState& s, 195 void S32_D16_filter_DXDY(const SkBitmapProcState& s,
195 const uint32_t* xy, int count, uint16_t* colors); 196 const uint32_t* xy, int count, uint16_t* colors);
196 197
197 #endif 198 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapController.cpp ('k') | src/core/SkBitmapProcState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698