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 |
11 | 11 #include "GrBatch.h" |
12 #include "GrBlend.h" | 12 #include "GrBlend.h" |
13 #include "GrDrawTargetCaps.h" | 13 #include "GrDrawTargetCaps.h" |
14 #include "GrGeometryProcessor.h" | 14 #include "GrGeometryProcessor.h" |
15 #include "GrGpuResourceRef.h" | 15 #include "GrGpuResourceRef.h" |
16 #include "GrFragmentStage.h" | 16 #include "GrFragmentStage.h" |
17 #include "GrProcOptInfo.h" | 17 #include "GrProcOptInfo.h" |
18 #include "GrRenderTarget.h" | 18 #include "GrRenderTarget.h" |
19 #include "GrStencil.h" | 19 #include "GrStencil.h" |
20 #include "GrXferProcessor.h" | 20 #include "GrXferProcessor.h" |
21 #include "SkMatrix.h" | 21 #include "SkMatrix.h" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 399 |
400 /// @} | 400 /// @} |
401 | 401 |
402 /////////////////////////////////////////////////////////////////////////// | 402 /////////////////////////////////////////////////////////////////////////// |
403 | 403 |
404 GrDrawState& operator= (const GrDrawState& that); | 404 GrDrawState& operator= (const GrDrawState& that); |
405 | 405 |
406 private: | 406 private: |
407 bool isEqual(const GrDrawState& that, bool explicitLocalCoords) const; | 407 bool isEqual(const GrDrawState& that, bool explicitLocalCoords) const; |
408 | 408 |
| 409 // Calculating invariant color / coverage information is expensive, so we pa
rtially cache the |
| 410 // results. |
| 411 // |
| 412 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result
s but only for a |
| 413 // specific color and coverage. May be calle
d multiple times |
| 414 // willBlendWithDst() - only called by Nvpr, does not cache results |
| 415 // GrOptDrawState constructor - never caches results |
| 416 |
| 417 // TODO delete when we have Batch |
409 const GrProcOptInfo& colorProcInfo(const GrPrimitiveProcessor* pp) const { | 418 const GrProcOptInfo& colorProcInfo(const GrPrimitiveProcessor* pp) const { |
410 this->calcColorInvariantOutput(pp); | 419 this->calcColorInvariantOutput(pp); |
411 return fColorProcInfo; | 420 return fColorProcInfo; |
412 } | 421 } |
413 | 422 |
414 const GrProcOptInfo& coverageProcInfo(const GrPrimitiveProcessor* pp) const
{ | 423 const GrProcOptInfo& coverageProcInfo(const GrPrimitiveProcessor* pp) const
{ |
415 this->calcCoverageInvariantOutput(pp); | 424 this->calcCoverageInvariantOutput(pp); |
416 return fCoverageProcInfo; | 425 return fCoverageProcInfo; |
417 } | 426 } |
418 | 427 |
| 428 const GrProcOptInfo& colorProcInfo(const GrBatch* batch) const { |
| 429 this->calcColorInvariantOutput(batch); |
| 430 return fColorProcInfo; |
| 431 } |
| 432 |
| 433 const GrProcOptInfo& coverageProcInfo(const GrBatch* batch) const { |
| 434 this->calcCoverageInvariantOutput(batch); |
| 435 return fCoverageProcInfo; |
| 436 } |
| 437 |
419 /** | 438 /** |
420 * If fColorProcInfoValid is false, function calculates the invariant output
for the color | 439 * Primproc variants of the calc functions |
421 * stages and results are stored in fColorProcInfo. | 440 * TODO remove these when batch is everywhere |
422 */ | 441 */ |
423 void calcColorInvariantOutput(const GrPrimitiveProcessor*) const; | 442 void calcColorInvariantOutput(const GrPrimitiveProcessor*) const; |
424 | |
425 /** | |
426 * If fCoverageProcInfoValid is false, function calculates the invariant out
put for the coverage | |
427 * stages and results are stored in fCoverageProcInfo. | |
428 */ | |
429 void calcCoverageInvariantOutput(const GrPrimitiveProcessor*) const; | 443 void calcCoverageInvariantOutput(const GrPrimitiveProcessor*) const; |
430 | 444 |
431 /** | 445 /** |
| 446 * GrBatch provides the initial seed for these loops based off of its initia
l geometry data |
| 447 */ |
| 448 void calcColorInvariantOutput(const GrBatch*) const; |
| 449 void calcCoverageInvariantOutput(const GrBatch*) const; |
| 450 |
| 451 /** |
432 * If fColorProcInfoValid is false, function calculates the invariant output
for the color | 452 * If fColorProcInfoValid is false, function calculates the invariant output
for the color |
433 * stages and results are stored in fColorProcInfo. | 453 * stages and results are stored in fColorProcInfo. |
434 */ | 454 */ |
435 void calcColorInvariantOutput(GrColor) const; | 455 void calcColorInvariantOutput(GrColor) const; |
436 | 456 |
437 /** | 457 /** |
438 * If fCoverageProcInfoValid is false, function calculates the invariant out
put for the coverage | 458 * If fCoverageProcInfoValid is false, function calculates the invariant out
put for the coverage |
439 * stages and results are stored in fCoverageProcInfo. | 459 * stages and results are stored in fCoverageProcInfo. |
440 */ | 460 */ |
441 void calcCoverageInvariantOutput(GrColor) const; | 461 void calcCoverageInvariantOutput(GrColor) const; |
(...skipping 13 matching lines...) Expand all Loading... |
455 SkAutoTUnref<const GrXPFactory> fXPFactory; | 475 SkAutoTUnref<const GrXPFactory> fXPFactory; |
456 FragmentStageArray fColorStages; | 476 FragmentStageArray fColorStages; |
457 FragmentStageArray fCoverageStages; | 477 FragmentStageArray fCoverageStages; |
458 | 478 |
459 mutable GrProcOptInfo fColorProcInfo; | 479 mutable GrProcOptInfo fColorProcInfo; |
460 mutable GrProcOptInfo fCoverageProcInfo; | 480 mutable GrProcOptInfo fCoverageProcInfo; |
461 mutable bool fColorProcInfoValid; | 481 mutable bool fColorProcInfoValid; |
462 mutable bool fCoverageProcInfoValid; | 482 mutable bool fCoverageProcInfoValid; |
463 mutable GrColor fColorCache; | 483 mutable GrColor fColorCache; |
464 mutable GrColor fCoverageCache; | 484 mutable GrColor fCoverageCache; |
465 mutable const GrPrimitiveProcessor* fColorPrimProc; | |
466 mutable const GrPrimitiveProcessor* fCoveragePrimProc; | |
467 | 485 |
468 friend class GrOptDrawState; | 486 friend class GrOptDrawState; |
469 }; | 487 }; |
470 | 488 |
471 #endif | 489 #endif |
OLD | NEW |