OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkArithmeticMode.h" | 8 #include "SkArithmeticMode.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 private: | 42 private: |
43 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
bool enforcePMColor) { | 43 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
bool enforcePMColor) { |
44 fK[0] = k1; | 44 fK[0] = k1; |
45 fK[1] = k2; | 45 fK[1] = k2; |
46 fK[2] = k3; | 46 fK[2] = k3; |
47 fK[3] = k4; | 47 fK[3] = k4; |
48 fEnforcePMColor = enforcePMColor; | 48 fEnforcePMColor = enforcePMColor; |
49 } | 49 } |
50 | 50 |
51 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { | 51 void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { |
52 buffer.writeScalar(fK[0]); | 52 buffer.writeScalar(fK[0]); |
53 buffer.writeScalar(fK[1]); | 53 buffer.writeScalar(fK[1]); |
54 buffer.writeScalar(fK[2]); | 54 buffer.writeScalar(fK[2]); |
55 buffer.writeScalar(fK[3]); | 55 buffer.writeScalar(fK[3]); |
56 buffer.writeBool(fEnforcePMColor); | 56 buffer.writeBool(fEnforcePMColor); |
57 } | 57 } |
58 SkScalar fK[4]; | 58 SkScalar fK[4]; |
59 bool fEnforcePMColor; | 59 bool fEnforcePMColor; |
60 | 60 |
61 friend class SkArithmeticMode; | 61 friend class SkArithmeticMode; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 GrGLArithmeticEffect(const GrProcessor&); | 243 GrGLArithmeticEffect(const GrProcessor&); |
244 virtual ~GrGLArithmeticEffect(); | 244 virtual ~GrGLArithmeticEffect(); |
245 | 245 |
246 virtual void emitCode(GrGLFPBuilder*, | 246 virtual void emitCode(GrGLFPBuilder*, |
247 const GrFragmentProcessor&, | 247 const GrFragmentProcessor&, |
248 const char* outputColor, | 248 const char* outputColor, |
249 const char* inputColor, | 249 const char* inputColor, |
250 const TransformedCoordsArray&, | 250 const TransformedCoordsArray&, |
251 const TextureSamplerArray&) SK_OVERRIDE; | 251 const TextureSamplerArray&) SK_OVERRIDE; |
252 | 252 |
253 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 253 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; |
254 | 254 |
255 static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyB
uilder* b); | 255 static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyB
uilder* b); |
256 | 256 |
257 private: | 257 private: |
258 GrGLProgramDataManager::UniformHandle fKUni; | 258 GrGLProgramDataManager::UniformHandle fKUni; |
259 bool fEnforcePMColor; | 259 bool fEnforcePMColor; |
260 | 260 |
261 typedef GrGLFragmentProcessor INHERITED; | 261 typedef GrGLFragmentProcessor INHERITED; |
262 }; | 262 }; |
263 | 263 |
264 /////////////////////////////////////////////////////////////////////////////// | 264 /////////////////////////////////////////////////////////////////////////////// |
265 | 265 |
266 class GrArithmeticEffect : public GrFragmentProcessor { | 266 class GrArithmeticEffect : public GrFragmentProcessor { |
267 public: | 267 public: |
268 static GrFragmentProcessor* Create(float k1, float k2, float k3, float k4, b
ool enforcePMColor, | 268 static GrFragmentProcessor* Create(float k1, float k2, float k3, float k4, b
ool enforcePMColor, |
269 GrTexture* background) { | 269 GrTexture* background) { |
270 return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, b
ackground)); | 270 return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, b
ackground)); |
271 } | 271 } |
272 | 272 |
273 virtual ~GrArithmeticEffect(); | 273 virtual ~GrArithmeticEffect(); |
274 | 274 |
275 virtual const char* name() const SK_OVERRIDE { return "Arithmetic"; } | 275 const char* name() const SK_OVERRIDE { return "Arithmetic"; } |
276 | 276 |
277 virtual void getGLProcessorKey(const GrGLCaps& caps, | 277 virtual void getGLProcessorKey(const GrGLCaps& caps, |
278 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 278 GrProcessorKeyBuilder* b) const SK_OVERRIDE { |
279 GrGLArithmeticEffect::GenKey(*this, caps, b); | 279 GrGLArithmeticEffect::GenKey(*this, caps, b); |
280 } | 280 } |
281 | 281 |
282 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE { | 282 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE { |
283 return SkNEW_ARGS(GrGLArithmeticEffect, (*this)); | 283 return SkNEW_ARGS(GrGLArithmeticEffect, (*this)); |
284 } | 284 } |
285 | 285 |
286 GrTexture* backgroundTexture() const { return fBackgroundAccess.getTexture()
; } | 286 GrTexture* backgroundTexture() const { return fBackgroundAccess.getTexture()
; } |
287 | 287 |
288 float k1() const { return fK1; } | 288 float k1() const { return fK1; } |
289 float k2() const { return fK2; } | 289 float k2() const { return fK2; } |
290 float k3() const { return fK3; } | 290 float k3() const { return fK3; } |
291 float k4() const { return fK4; } | 291 float k4() const { return fK4; } |
292 bool enforcePMColor() const { return fEnforcePMColor; } | 292 bool enforcePMColor() const { return fEnforcePMColor; } |
293 | 293 |
294 private: | 294 private: |
295 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; | 295 bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; |
296 | 296 |
297 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; | 297 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; |
298 | 298 |
299 GrArithmeticEffect(float k1, float k2, float k3, float k4, bool enforcePMCol
or, | 299 GrArithmeticEffect(float k1, float k2, float k3, float k4, bool enforcePMCol
or, |
300 GrTexture* background); | 300 GrTexture* background); |
301 float fK1, fK2, fK3, fK4; | 301 float fK1, fK2, fK3, fK4; |
302 bool fEnforcePMColor; | 302 bool fEnforcePMColor; |
303 GrCoordTransform fBackgroundTransform; | 303 GrCoordTransform fBackgroundTransform; |
304 GrTextureAccess fBackgroundAccess; | 304 GrTextureAccess fBackgroundAccess; |
305 | 305 |
306 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 306 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
307 typedef GrFragmentProcessor INHERITED; | 307 typedef GrFragmentProcessor INHERITED; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 background); | 443 background); |
444 } | 444 } |
445 return true; | 445 return true; |
446 } | 446 } |
447 | 447 |
448 #endif | 448 #endif |
449 | 449 |
450 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) | 450 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) |
451 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) | 451 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) |
452 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 452 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |