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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 } | 1292 } |
1293 } | 1293 } |
1294 | 1294 |
1295 bool GrContext::readRenderTargetPixels(GrRenderTarget* target, | 1295 bool GrContext::readRenderTargetPixels(GrRenderTarget* target, |
1296 int left, int top, int width, int height, | 1296 int left, int top, int width, int height, |
1297 GrPixelConfig dstConfig, void* buffer, si
ze_t rowBytes, | 1297 GrPixelConfig dstConfig, void* buffer, si
ze_t rowBytes, |
1298 uint32_t flags) { | 1298 uint32_t flags) { |
1299 ASSERT_OWNED_RESOURCE(target); | 1299 ASSERT_OWNED_RESOURCE(target); |
1300 | 1300 |
1301 if (NULL == target) { | 1301 if (NULL == target) { |
1302 target = fRenderTarget.get(); | 1302 target = fRenderTarget1.get(); |
1303 if (NULL == target) { | 1303 if (NULL == target) { |
1304 return false; | 1304 return false; |
1305 } | 1305 } |
1306 } | 1306 } |
1307 | 1307 |
1308 if (!(kDontFlush_PixelOpsFlag & flags)) { | 1308 if (!(kDontFlush_PixelOpsFlag & flags)) { |
1309 this->flush(); | 1309 this->flush(); |
1310 } | 1310 } |
1311 | 1311 |
1312 // Determine which conversions have to be applied: flipY, swapRAnd, and/or u
npremul. | 1312 // Determine which conversions have to be applied: flipY, swapRAnd, and/or u
npremul. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 | 1486 |
1487 bool GrContext::writeRenderTargetPixels(GrRenderTarget* target, | 1487 bool GrContext::writeRenderTargetPixels(GrRenderTarget* target, |
1488 int left, int top, int width, int height
, | 1488 int left, int top, int width, int height
, |
1489 GrPixelConfig srcConfig, | 1489 GrPixelConfig srcConfig, |
1490 const void* buffer, | 1490 const void* buffer, |
1491 size_t rowBytes, | 1491 size_t rowBytes, |
1492 uint32_t flags) { | 1492 uint32_t flags) { |
1493 ASSERT_OWNED_RESOURCE(target); | 1493 ASSERT_OWNED_RESOURCE(target); |
1494 | 1494 |
1495 if (NULL == target) { | 1495 if (NULL == target) { |
1496 target = fRenderTarget.get(); | 1496 target = fRenderTarget1.get(); |
1497 if (NULL == target) { | 1497 if (NULL == target) { |
1498 return false; | 1498 return false; |
1499 } | 1499 } |
1500 } | 1500 } |
1501 | 1501 |
1502 // TODO: when underlying api has a direct way to do this we should use it (e
.g. glDrawPixels on | 1502 // TODO: when underlying api has a direct way to do this we should use it (e
.g. glDrawPixels on |
1503 // desktop GL). | 1503 // desktop GL). |
1504 | 1504 |
1505 // We will always call some form of writeTexturePixels and we will pass our
flags on to it. | 1505 // We will always call some form of writeTexturePixels and we will pass our
flags on to it. |
1506 // Thus, we don't perform a flush here since that call will do it (if the kN
oFlush flag isn't | 1506 // Thus, we don't perform a flush here since that call will do it (if the kN
oFlush flag isn't |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 AutoRestoreEffects* are, | 1618 AutoRestoreEffects* are, |
1619 AutoCheckFlush* acf) { | 1619 AutoCheckFlush* acf) { |
1620 // All users of this draw state should be freeing up all effects when they'r
e done. | 1620 // All users of this draw state should be freeing up all effects when they'r
e done. |
1621 // Otherwise effects that own resources may keep those resources alive indef
initely. | 1621 // Otherwise effects that own resources may keep those resources alive indef
initely. |
1622 SkASSERT(0 == fDrawState->numColorStages() && 0 == fDrawState->numCoverageSt
ages()); | 1622 SkASSERT(0 == fDrawState->numColorStages() && 0 == fDrawState->numCoverageSt
ages()); |
1623 | 1623 |
1624 if (kNo_BufferedDraw == buffered && kYes_BufferedDraw == fLastDrawWasBuffere
d) { | 1624 if (kNo_BufferedDraw == buffered && kYes_BufferedDraw == fLastDrawWasBuffere
d) { |
1625 fDrawBuffer->flush(); | 1625 fDrawBuffer->flush(); |
1626 fLastDrawWasBuffered = kNo_BufferedDraw; | 1626 fLastDrawWasBuffered = kNo_BufferedDraw; |
1627 } | 1627 } |
1628 ASSERT_OWNED_RESOURCE(fRenderTarget.get()); | 1628 ASSERT_OWNED_RESOURCE(fRenderTarget1.get()); |
1629 if (NULL != paint) { | 1629 if (NULL != paint) { |
1630 SkASSERT(NULL != are); | 1630 SkASSERT(NULL != are); |
1631 SkASSERT(NULL != acf); | 1631 SkASSERT(NULL != acf); |
1632 are->set(fDrawState); | 1632 are->set(fDrawState); |
1633 fDrawState->setFromPaint(*paint, fViewMatrix, fRenderTarget.get()); | 1633 fDrawState->setFromPaint(*paint, fViewMatrix, fRenderTarget1.get()); |
1634 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK | 1634 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK |
1635 if ((paint->hasMask() || 0xff != paint->fCoverage) && | 1635 if ((paint->hasMask() || 0xff != paint->fCoverage) && |
1636 !fGpu->canApplyCoverage()) { | 1636 !fGpu->canApplyCoverage()) { |
1637 GrPrintf("Partial pixel coverage will be incorrectly blended.\n"); | 1637 GrPrintf("Partial pixel coverage will be incorrectly blended.\n"); |
1638 } | 1638 } |
1639 #endif | 1639 #endif |
1640 } else { | 1640 } else { |
1641 fDrawState->reset(fViewMatrix); | 1641 fDrawState->reset(fViewMatrix); |
1642 fDrawState->setRenderTarget(fRenderTarget.get()); | 1642 fDrawState->setRenderTarget(fRenderTarget1.get()); |
1643 } | 1643 } |
1644 GrDrawTarget* target; | 1644 GrDrawTarget* target; |
1645 if (kYes_BufferedDraw == buffered) { | 1645 if (kYes_BufferedDraw == buffered) { |
1646 fLastDrawWasBuffered = kYes_BufferedDraw; | 1646 fLastDrawWasBuffered = kYes_BufferedDraw; |
1647 target = fDrawBuffer; | 1647 target = fDrawBuffer; |
1648 } else { | 1648 } else { |
1649 SkASSERT(kNo_BufferedDraw == buffered); | 1649 SkASSERT(kNo_BufferedDraw == buffered); |
1650 fLastDrawWasBuffered = kNo_BufferedDraw; | 1650 fLastDrawWasBuffered = kNo_BufferedDraw; |
1651 target = fGpu; | 1651 target = fGpu; |
1652 } | 1652 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 } | 1798 } |
1799 return path; | 1799 return path; |
1800 } | 1800 } |
1801 | 1801 |
1802 /////////////////////////////////////////////////////////////////////////////// | 1802 /////////////////////////////////////////////////////////////////////////////// |
1803 #if GR_CACHE_STATS | 1803 #if GR_CACHE_STATS |
1804 void GrContext::printCacheStats() const { | 1804 void GrContext::printCacheStats() const { |
1805 fTextureCache->printStats(); | 1805 fTextureCache->printStats(); |
1806 } | 1806 } |
1807 #endif | 1807 #endif |
OLD | NEW |