OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrDrawState_DEFINED | 8 #ifndef GrDrawState_DEFINED |
9 #define GrDrawState_DEFINED | 9 #define GrDrawState_DEFINED |
10 | 10 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 /// pixel coverage rather than as input to the src/dst color blend step. | 333 /// pixel coverage rather than as input to the src/dst color blend step. |
334 /// | 334 /// |
335 /// The input color to the first color-stage is either the constant color or
interpolated | 335 /// The input color to the first color-stage is either the constant color or
interpolated |
336 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage | 336 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage |
337 /// (usually full-coverage) or interpolated per-vertex coverage. | 337 /// (usually full-coverage) or interpolated per-vertex coverage. |
338 /// | 338 /// |
339 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the | 339 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the |
340 /// the color / coverage distinction. | 340 /// the color / coverage distinction. |
341 //// | 341 //// |
342 | 342 |
343 const GrEffectRef* addColorEffect(const GrEffectRef* effect, int attr0 = -1,
int attr1 = -1) { | 343 const GrEffect* addColorEffect(const GrEffect* effect, int attr0 = -1, int a
ttr1 = -1) { |
344 SkASSERT(NULL != effect); | 344 SkASSERT(NULL != effect); |
345 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att
r1)); | 345 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att
r1)); |
346 return effect; | 346 return effect; |
347 } | 347 } |
348 | 348 |
349 const GrEffectRef* addCoverageEffect(const GrEffectRef* effect, int attr0 =
-1, int attr1 = -1) { | 349 const GrEffect* addCoverageEffect(const GrEffect* effect, int attr0 = -1, in
t attr1 = -1) { |
350 SkASSERT(NULL != effect); | 350 SkASSERT(NULL != effect); |
351 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0,
attr1)); | 351 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0,
attr1)); |
352 return effect; | 352 return effect; |
353 } | 353 } |
354 | 354 |
355 /** | 355 /** |
356 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin
ates. | 356 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin
ates. |
357 */ | 357 */ |
358 void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) { | 358 void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) { |
359 GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix); | 359 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix))->un
ref(); |
360 this->addColorEffect(effect)->unref(); | |
361 } | 360 } |
362 | 361 |
363 void addCoverageTextureEffect(GrTexture* texture, const SkMatrix& matrix) { | 362 void addCoverageTextureEffect(GrTexture* texture, const SkMatrix& matrix) { |
364 GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix); | 363 this->addCoverageEffect(GrSimpleTextureEffect::Create(texture, matrix))-
>unref(); |
365 this->addCoverageEffect(effect)->unref(); | |
366 } | 364 } |
367 | 365 |
368 void addColorTextureEffect(GrTexture* texture, | 366 void addColorTextureEffect(GrTexture* texture, |
369 const SkMatrix& matrix, | 367 const SkMatrix& matrix, |
370 const GrTextureParams& params) { | 368 const GrTextureParams& params) { |
371 GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, par
ams); | 369 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix, para
ms))->unref(); |
372 this->addColorEffect(effect)->unref(); | |
373 } | 370 } |
374 | 371 |
375 void addCoverageTextureEffect(GrTexture* texture, | 372 void addCoverageTextureEffect(GrTexture* texture, |
376 const SkMatrix& matrix, | 373 const SkMatrix& matrix, |
377 const GrTextureParams& params) { | 374 const GrTextureParams& params) { |
378 GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, par
ams); | 375 this->addCoverageEffect(GrSimpleTextureEffect::Create(texture, matrix, p
arams))->unref(); |
379 this->addCoverageEffect(effect)->unref(); | |
380 } | 376 } |
381 | 377 |
382 /** | 378 /** |
383 * When this object is destroyed it will remove any effects from the draw st
ate that were added | 379 * When this object is destroyed it will remove any effects from the draw st
ate that were added |
384 * after its constructor. | 380 * after its constructor. |
385 */ | 381 */ |
386 class AutoRestoreEffects : public ::SkNoncopyable { | 382 class AutoRestoreEffects : public ::SkNoncopyable { |
387 public: | 383 public: |
388 AutoRestoreEffects() : fDrawState(NULL), fColorEffectCnt(0), fCoverageEf
fectCnt(0) {} | 384 AutoRestoreEffects() : fDrawState(NULL), fColorEffectCnt(0), fCoverageEf
fectCnt(0) {} |
389 | 385 |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 * @param count the number of attributes being set, limited to kMaxVer
texAttribCnt. | 959 * @param count the number of attributes being set, limited to kMaxVer
texAttribCnt. |
964 */ | 960 */ |
965 void setVertexAttribs(const GrVertexAttrib attribs[], int count); | 961 void setVertexAttribs(const GrVertexAttrib attribs[], int count); |
966 | 962 |
967 typedef SkRefCnt INHERITED; | 963 typedef SkRefCnt INHERITED; |
968 }; | 964 }; |
969 | 965 |
970 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); | 966 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); |
971 | 967 |
972 #endif | 968 #endif |
OLD | NEW |