Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 | 10 |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 void GrContext::drawPaint(const GrPaint& origPaint, const SkMatrix& viewMatrix) { | 550 void GrContext::drawPaint(const GrPaint& origPaint, const SkMatrix& viewMatrix) { |
| 551 // set rect to be big enough to fill the space, but not super-huge, so we | 551 // set rect to be big enough to fill the space, but not super-huge, so we |
| 552 // don't overflow fixed-point implementations | 552 // don't overflow fixed-point implementations |
| 553 SkRect r; | 553 SkRect r; |
| 554 r.setLTRB(0, 0, | 554 r.setLTRB(0, 0, |
| 555 SkIntToScalar(getRenderTarget()->width()), | 555 SkIntToScalar(getRenderTarget()->width()), |
| 556 SkIntToScalar(getRenderTarget()->height())); | 556 SkIntToScalar(getRenderTarget()->height())); |
| 557 SkTCopyOnFirstWrite<GrPaint> paint(origPaint); | 557 SkTCopyOnFirstWrite<GrPaint> paint(origPaint); |
| 558 GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::drawPaint", this); | 558 GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::drawPaint", this); |
| 559 | 559 |
| 560 // by definition this fills the entire clip, no need for AA | |
| 561 if (paint->isAntiAlias()) { | |
| 562 paint.writable()->setAntiAlias(false); | |
| 563 } | |
| 564 | |
| 565 bool isPerspective = viewMatrix.hasPerspective(); | |
| 566 | |
| 560 // We attempt to map r by the inverse matrix and draw that. mapRect will | 567 // We attempt to map r by the inverse matrix and draw that. mapRect will |
| 561 // map the four corners and bound them with a new rect. This will not | 568 // map the four corners and bound them with a new rect. This will not |
| 562 // produce a correct result for some perspective matrices. | 569 // produce a correct result for some perspective matrices. |
| 563 if (!viewMatrix.hasPerspective()) { | 570 AutoCheckFlush acf(this); |
| 571 GrDrawState drawState; | |
| 572 GrDrawTarget* target = this->prepareToDraw(&drawState, paint, | |
| 573 isPerspective ? &SkMatrix::I() : &viewMatrix, &acf); | |
| 574 if (NULL == target) { | |
| 575 return; | |
| 576 } | |
| 577 | |
| 578 GR_CREATE_TRACE_MARKER("GrContext::drawPaint", target); | |
|
bsalomon
2014/12/22 15:33:53
this looks duplicated from above? probably don't w
| |
| 579 if (!isPerspective) { | |
| 564 SkMatrix inverse; | 580 SkMatrix inverse; |
| 565 if (!viewMatrix.invert(&inverse)) { | 581 if (!viewMatrix.invert(&inverse)) { |
| 566 SkDebugf("Could not invert matrix\n"); | 582 SkDebugf("Could not invert matrix\n"); |
| 567 return; | 583 return; |
| 568 } | 584 } |
| 569 inverse.mapRect(&r); | 585 inverse.mapRect(&r); |
| 586 target->drawSimpleRect(&drawState, paint->getColor(), r); | |
| 570 } else { | 587 } else { |
| 571 if (!paint.writable()->localCoordChangeInverse(viewMatrix)) { | 588 SkMatrix localMatrix; |
| 589 if (!viewMatrix.invert(&localMatrix)) { | |
| 572 SkDebugf("Could not invert matrix\n"); | 590 SkDebugf("Could not invert matrix\n"); |
| 573 return; | 591 return; |
| 574 } | 592 } |
| 593 target->drawRect(&drawState, paint->getColor(), r, NULL, NULL, &localMat rix); | |
| 575 } | 594 } |
| 576 // by definition this fills the entire clip, no need for AA | |
| 577 if (paint->isAntiAlias()) { | |
| 578 paint.writable()->setAntiAlias(false); | |
| 579 } | |
| 580 this->drawRect(*paint, viewMatrix.hasPerspective() ? SkMatrix::I() : viewMat rix, r); | |
| 581 } | 595 } |
| 582 | 596 |
| 583 #ifdef SK_DEVELOPER | 597 #ifdef SK_DEVELOPER |
| 584 void GrContext::dumpFontCache() const { | 598 void GrContext::dumpFontCache() const { |
| 585 fFontCache->dump(); | 599 fFontCache->dump(); |
| 586 } | 600 } |
| 587 #endif | 601 #endif |
| 588 | 602 |
| 589 //////////////////////////////////////////////////////////////////////////////// | 603 //////////////////////////////////////////////////////////////////////////////// |
| 590 | 604 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 const SkMatrix* localMatrix) { | 816 const SkMatrix* localMatrix) { |
| 803 AutoCheckFlush acf(this); | 817 AutoCheckFlush acf(this); |
| 804 GrDrawState drawState; | 818 GrDrawState drawState; |
| 805 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &viewMatrix, &acf); | 819 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &viewMatrix, &acf); |
| 806 if (NULL == target) { | 820 if (NULL == target) { |
| 807 return; | 821 return; |
| 808 } | 822 } |
| 809 | 823 |
| 810 GR_CREATE_TRACE_MARKER("GrContext::drawRectToRect", target); | 824 GR_CREATE_TRACE_MARKER("GrContext::drawRectToRect", target); |
| 811 | 825 |
| 812 target->drawRect(&drawState, paint.getColor(), rectToDraw, &localRect, local Matrix); | 826 target->drawRect(&drawState, paint.getColor(), rectToDraw, &localRect, local Matrix, NULL); |
| 813 } | 827 } |
| 814 | 828 |
| 815 static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords , | 829 static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords , |
| 816 const GrColor* colors, | 830 const GrColor* colors, |
| 817 int* colorOffset, | 831 int* colorOffset, |
| 818 int* texOffset, | 832 int* texOffset, |
| 819 GrColor color) { | 833 GrColor color) { |
| 820 *texOffset = -1; | 834 *texOffset = -1; |
| 821 *colorOffset = -1; | 835 *colorOffset = -1; |
| 822 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; | 836 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1736 fResourceCache2->printStats(); | 1750 fResourceCache2->printStats(); |
| 1737 } | 1751 } |
| 1738 #endif | 1752 #endif |
| 1739 | 1753 |
| 1740 #if GR_GPU_STATS | 1754 #if GR_GPU_STATS |
| 1741 const GrContext::GPUStats* GrContext::gpuStats() const { | 1755 const GrContext::GPUStats* GrContext::gpuStats() const { |
| 1742 return fGpu->gpuStats(); | 1756 return fGpu->gpuStats(); |
| 1743 } | 1757 } |
| 1744 #endif | 1758 #endif |
| 1745 | 1759 |
| OLD | NEW |