| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrDrawState.h" | 8 #include "GrDrawState.h" |
| 9 #include "GrPaint.h" | 9 #include "GrPaint.h" |
| 10 | 10 |
| 11 void GrDrawState::setFromPaint(const GrPaint& paint) { | 11 void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRende
rTarget* rt) { |
| 12 for (int i = 0; i < GrPaint::kMaxColorStages; ++i) { | 12 for (int i = 0; i < GrPaint::kMaxColorStages; ++i) { |
| 13 int s = i + GrPaint::kFirstColorStage; | 13 int s = i + GrPaint::kFirstColorStage; |
| 14 if (paint.isColorStageEnabled(i)) { | 14 if (paint.isColorStageEnabled(i)) { |
| 15 fStages[s] = paint.getColorStage(i); | 15 fStages[s] = paint.getColorStage(i); |
| 16 } else { | 16 } else { |
| 17 fStages[s].setEffect(NULL); | 17 fStages[s].setEffect(NULL); |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 this->setFirstCoverageStage(GrPaint::kFirstCoverageStage); | 21 this->setFirstCoverageStage(GrPaint::kFirstCoverageStage); |
| 22 | 22 |
| 23 for (int i = 0; i < GrPaint::kMaxCoverageStages; ++i) { | 23 for (int i = 0; i < GrPaint::kMaxCoverageStages; ++i) { |
| 24 int s = i + GrPaint::kFirstCoverageStage; | 24 int s = i + GrPaint::kFirstCoverageStage; |
| 25 if (paint.isCoverageStageEnabled(i)) { | 25 if (paint.isCoverageStageEnabled(i)) { |
| 26 fStages[s] = paint.getCoverageStage(i); | 26 fStages[s] = paint.getCoverageStage(i); |
| 27 } else { | 27 } else { |
| 28 fStages[s].setEffect(NULL); | 28 fStages[s].setEffect(NULL); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 // disable all stages not accessible via the paint | 32 // disable all stages not accessible via the paint |
| 33 for (int s = GrPaint::kTotalStages; s < GrDrawState::kNumStages; ++s) { | 33 for (int s = GrPaint::kTotalStages; s < GrDrawState::kNumStages; ++s) { |
| 34 this->disableStage(s); | 34 this->disableStage(s); |
| 35 } | 35 } |
| 36 | 36 |
| 37 this->setRenderTarget(rt); |
| 38 |
| 39 fCommon.fViewMatrix = vm; |
| 40 |
| 41 // These have no equivalent in GrPaint, set them to defaults |
| 42 fCommon.fBlendConstant = 0x0; |
| 43 fCommon.fCoverage = 0xffffffff; |
| 44 fCommon.fDrawFace = kBoth_DrawFace; |
| 45 fCommon.fStencilSettings.setDisabled(); |
| 46 this->resetStateFlags(); |
| 47 |
| 37 this->setColor(paint.getColor()); | 48 this->setColor(paint.getColor()); |
| 38 | |
| 39 this->setState(GrDrawState::kDither_StateBit, paint.isDither()); | 49 this->setState(GrDrawState::kDither_StateBit, paint.isDither()); |
| 40 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); | 50 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); |
| 41 | 51 |
| 42 this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff()); | 52 this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff()); |
| 43 this->setColorFilter(paint.getColorFilterColor(), paint.getColorFilterMode()
); | 53 this->setColorFilter(paint.getColorFilterColor(), paint.getColorFilterMode()
); |
| 44 this->setCoverage(paint.getCoverage()); | 54 this->setCoverage(paint.getCoverage()); |
| 45 } | 55 } |
| 46 | 56 |
| 47 //////////////////////////////////////////////////////////////////////////////// | 57 //////////////////////////////////////////////////////////////////////////////// |
| 48 | 58 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 } | 466 } |
| 457 fRestoreMask |= (1 << s); | 467 fRestoreMask |= (1 << s); |
| 458 GrEffectStage* stage = drawState->fStages + s; | 468 GrEffectStage* stage = drawState->fStages + s; |
| 459 stage->saveCoordChange(&fSavedCoordChanges[s]); | 469 stage->saveCoordChange(&fSavedCoordChanges[s]); |
| 460 stage->localCoordChange(invVM); | 470 stage->localCoordChange(invVM); |
| 461 } | 471 } |
| 462 } | 472 } |
| 463 drawState->viewMatrix()->reset(); | 473 drawState->viewMatrix()->reset(); |
| 464 return true; | 474 return true; |
| 465 } | 475 } |
| OLD | NEW |