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 26 matching lines...) Expand all Loading... |
37 #include "SkRRect.h" | 37 #include "SkRRect.h" |
38 #include "SkStrokeRec.h" | 38 #include "SkStrokeRec.h" |
39 #include "SkTLazy.h" | 39 #include "SkTLazy.h" |
40 #include "SkTLS.h" | 40 #include "SkTLS.h" |
41 #include "SkTraceEvent.h" | 41 #include "SkTraceEvent.h" |
42 | 42 |
43 #include "effects/GrConfigConversionEffect.h" | 43 #include "effects/GrConfigConversionEffect.h" |
44 #include "effects/GrDashingEffect.h" | 44 #include "effects/GrDashingEffect.h" |
45 #include "effects/GrSingleTextureEffect.h" | 45 #include "effects/GrSingleTextureEffect.h" |
46 | 46 |
47 #ifdef SK_DEBUG | |
48 // change this to a 1 to see notifications when partial coverage fails | |
49 #define GR_DEBUG_PARTIAL_COVERAGE_CHECK 0 | |
50 #else | |
51 #define GR_DEBUG_PARTIAL_COVERAGE_CHECK 0 | |
52 #endif | |
53 | |
54 static const size_t DRAW_BUFFER_VBPOOL_BUFFER_SIZE = 1 << 15; | 47 static const size_t DRAW_BUFFER_VBPOOL_BUFFER_SIZE = 1 << 15; |
55 static const int DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS = 4; | 48 static const int DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS = 4; |
56 | 49 |
57 static const size_t DRAW_BUFFER_IBPOOL_BUFFER_SIZE = 1 << 11; | 50 static const size_t DRAW_BUFFER_IBPOOL_BUFFER_SIZE = 1 << 11; |
58 static const int DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS = 4; | 51 static const int DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS = 4; |
59 | 52 |
60 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) | 53 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) |
61 | 54 |
62 class GrContext::AutoCheckFlush { | 55 class GrContext::AutoCheckFlush { |
63 public: | 56 public: |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 449 |
457 void GrContext::OverBudgetCB(void* data) { | 450 void GrContext::OverBudgetCB(void* data) { |
458 SkASSERT(data); | 451 SkASSERT(data); |
459 | 452 |
460 GrContext* context = reinterpret_cast<GrContext*>(data); | 453 GrContext* context = reinterpret_cast<GrContext*>(data); |
461 | 454 |
462 // Flush the InOrderDrawBuffer to possibly free up some textures | 455 // Flush the InOrderDrawBuffer to possibly free up some textures |
463 context->fFlushToReduceCacheSize = true; | 456 context->fFlushToReduceCacheSize = true; |
464 } | 457 } |
465 | 458 |
466 | |
467 GrTexture* GrContext::createUncachedTexture(const GrSurfaceDesc& desc, | 459 GrTexture* GrContext::createUncachedTexture(const GrSurfaceDesc& desc, |
468 void* srcData, | 460 void* srcData, |
469 size_t rowBytes) { | 461 size_t rowBytes) { |
470 return fGpu->createTexture(desc, false, srcData, rowBytes); | 462 return fGpu->createTexture(desc, false, srcData, rowBytes); |
471 } | 463 } |
472 | 464 |
473 void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes
) const { | 465 void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes
) const { |
474 if (maxTextures) { | 466 if (maxTextures) { |
475 *maxTextures = fResourceCache2->getMaxResourceCount(); | 467 *maxTextures = fResourceCache2->getMaxResourceCount(); |
476 } | 468 } |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 | 1554 |
1563 GrDrawTarget* GrContext::prepareToDraw(GrDrawState* ds, | 1555 GrDrawTarget* GrContext::prepareToDraw(GrDrawState* ds, |
1564 const GrPaint* paint, | 1556 const GrPaint* paint, |
1565 const AutoCheckFlush* acf) { | 1557 const AutoCheckFlush* acf) { |
1566 if (NULL == fGpu) { | 1558 if (NULL == fGpu) { |
1567 return NULL; | 1559 return NULL; |
1568 } | 1560 } |
1569 | 1561 |
1570 ASSERT_OWNED_RESOURCE(fRenderTarget.get()); | 1562 ASSERT_OWNED_RESOURCE(fRenderTarget.get()); |
1571 if (ds) { | 1563 if (ds) { |
1572 if (paint) { | 1564 SkASSERT(paint && acf); |
1573 SkASSERT(acf); | 1565 ds->setFromPaint(*paint, fRenderTarget.get()); |
1574 ds->setFromPaint(*paint, fRenderTarget.get()); | |
1575 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK | |
1576 if ((paint->hasMask()) && | |
1577 !fDrawState->canUseFracCoveragePrimProc(paint.getColor(), fGpu->
caps())) { | |
1578 SkDebugf("Partial pixel coverage will be incorrectly blended.\n"
); | |
1579 } | |
1580 #endif | |
1581 } else { | |
1582 ds->reset(); | |
1583 ds->setRenderTarget(fRenderTarget.get()); | |
1584 } | |
1585 ds->setState(GrDrawState::kClip_StateBit, fClip && !fClip->fClipStack->i
sWideOpen()); | 1566 ds->setState(GrDrawState::kClip_StateBit, fClip && !fClip->fClipStack->i
sWideOpen()); |
1586 } | 1567 } |
1587 fDrawBuffer->setClip(fClip); | 1568 fDrawBuffer->setClip(fClip); |
1588 return fDrawBuffer; | 1569 return fDrawBuffer; |
1589 } | 1570 } |
1590 | 1571 |
1591 /* | 1572 /* |
1592 * This method finds a path renderer that can draw the specified path on | 1573 * This method finds a path renderer that can draw the specified path on |
1593 * the provided target. | 1574 * the provided target. |
1594 * Due to its expense, the software path renderer has split out so it can | 1575 * Due to its expense, the software path renderer has split out so it can |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 fResourceCache2->printStats(); | 1725 fResourceCache2->printStats(); |
1745 } | 1726 } |
1746 #endif | 1727 #endif |
1747 | 1728 |
1748 #if GR_GPU_STATS | 1729 #if GR_GPU_STATS |
1749 const GrContext::GPUStats* GrContext::gpuStats() const { | 1730 const GrContext::GPUStats* GrContext::gpuStats() const { |
1750 return fGpu->gpuStats(); | 1731 return fGpu->gpuStats(); |
1751 } | 1732 } |
1752 #endif | 1733 #endif |
1753 | 1734 |
OLD | NEW |