| 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 | 9 |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 | 1127 |
| 1128 pr->drawPath(*pathPtr, strokeRec, target, useAA); | 1128 pr->drawPath(*pathPtr, strokeRec, target, useAA); |
| 1129 } | 1129 } |
| 1130 | 1130 |
| 1131 //////////////////////////////////////////////////////////////////////////////// | 1131 //////////////////////////////////////////////////////////////////////////////// |
| 1132 | 1132 |
| 1133 void GrContext::flush(int flagsBitfield) { | 1133 void GrContext::flush(int flagsBitfield) { |
| 1134 if (kDiscard_FlushBit & flagsBitfield) { | 1134 if (kDiscard_FlushBit & flagsBitfield) { |
| 1135 fDrawBuffer->reset(); | 1135 fDrawBuffer->reset(); |
| 1136 } else { | 1136 } else { |
| 1137 this->flushDrawBuffer(); | |
| 1138 } | |
| 1139 // TODO: Remove this flag | |
| 1140 if (kForceCurrentRenderTarget_FlushBit & flagsBitfield) { | |
| 1141 fGpu->drawState()->setRenderTarget(this->getRenderTarget()); | |
| 1142 fGpu->forceRenderTargetFlush(); | |
| 1143 } | |
| 1144 } | |
| 1145 | |
| 1146 void GrContext::flushDrawBuffer() { | |
| 1147 if (NULL != fDrawBuffer && !fDrawBuffer->isFlushing()) { | |
| 1148 fDrawBuffer->flush(); | 1137 fDrawBuffer->flush(); |
| 1149 } | 1138 } |
| 1150 } | 1139 } |
| 1151 | 1140 |
| 1152 bool GrContext::writeTexturePixels(GrTexture* texture, | 1141 bool GrContext::writeTexturePixels(GrTexture* texture, |
| 1153 int left, int top, int width, int height, | 1142 int left, int top, int width, int height, |
| 1154 GrPixelConfig config, const void* buffer, siz
e_t rowBytes, | 1143 GrPixelConfig config, const void* buffer, siz
e_t rowBytes, |
| 1155 uint32_t flags) { | 1144 uint32_t flags) { |
| 1156 SK_TRACE_EVENT0("GrContext::writeTexturePixels"); | 1145 SK_TRACE_EVENT0("GrContext::writeTexturePixels"); |
| 1157 ASSERT_OWNED_RESOURCE(texture); | 1146 ASSERT_OWNED_RESOURCE(texture); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 //////////////////////////////////////////////////////////////////////////////// | 1542 //////////////////////////////////////////////////////////////////////////////// |
| 1554 | 1543 |
| 1555 GrDrawTarget* GrContext::prepareToDraw(const GrPaint* paint, | 1544 GrDrawTarget* GrContext::prepareToDraw(const GrPaint* paint, |
| 1556 BufferedDraw buffered, | 1545 BufferedDraw buffered, |
| 1557 AutoRestoreEffects* are) { | 1546 AutoRestoreEffects* are) { |
| 1558 // All users of this draw state should be freeing up all effects when they'r
e done. | 1547 // All users of this draw state should be freeing up all effects when they'r
e done. |
| 1559 // Otherwise effects that own resources may keep those resources alive indef
initely. | 1548 // Otherwise effects that own resources may keep those resources alive indef
initely. |
| 1560 GrAssert(0 == fDrawState->numColorStages() && 0 == fDrawState->numCoverageSt
ages()); | 1549 GrAssert(0 == fDrawState->numColorStages() && 0 == fDrawState->numCoverageSt
ages()); |
| 1561 | 1550 |
| 1562 if (kNo_BufferedDraw == buffered && kYes_BufferedDraw == fLastDrawWasBuffere
d) { | 1551 if (kNo_BufferedDraw == buffered && kYes_BufferedDraw == fLastDrawWasBuffere
d) { |
| 1563 this->flushDrawBuffer(); | 1552 fDrawBuffer->flush(); |
| 1564 fLastDrawWasBuffered = kNo_BufferedDraw; | 1553 fLastDrawWasBuffered = kNo_BufferedDraw; |
| 1565 } | 1554 } |
| 1566 ASSERT_OWNED_RESOURCE(fRenderTarget.get()); | 1555 ASSERT_OWNED_RESOURCE(fRenderTarget.get()); |
| 1567 if (NULL != paint) { | 1556 if (NULL != paint) { |
| 1568 GrAssert(NULL != are); | 1557 GrAssert(NULL != are); |
| 1569 are->set(fDrawState); | 1558 are->set(fDrawState); |
| 1570 fDrawState->setFromPaint(*paint, fViewMatrix, fRenderTarget.get()); | 1559 fDrawState->setFromPaint(*paint, fViewMatrix, fRenderTarget.get()); |
| 1571 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK | 1560 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK |
| 1572 if ((paint->hasMask() || 0xff != paint->fCoverage) && | 1561 if ((paint->hasMask() || 0xff != paint->fCoverage) && |
| 1573 !fGpu->canApplyCoverage()) { | 1562 !fGpu->canApplyCoverage()) { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 return srcTexture; | 1837 return srcTexture; |
| 1849 } | 1838 } |
| 1850 } | 1839 } |
| 1851 | 1840 |
| 1852 /////////////////////////////////////////////////////////////////////////////// | 1841 /////////////////////////////////////////////////////////////////////////////// |
| 1853 #if GR_CACHE_STATS | 1842 #if GR_CACHE_STATS |
| 1854 void GrContext::printCacheStats() const { | 1843 void GrContext::printCacheStats() const { |
| 1855 fTextureCache->printStats(); | 1844 fTextureCache->printStats(); |
| 1856 } | 1845 } |
| 1857 #endif | 1846 #endif |
| OLD | NEW |