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 28 matching lines...) Expand all Loading... |
39 // debugging simpler. | 39 // debugging simpler. |
40 SK_CONF_DECLARE(bool, c_Defer, "gpu.deferContext", true, | 40 SK_CONF_DECLARE(bool, c_Defer, "gpu.deferContext", true, |
41 "Defers rendering in GrContext via GrInOrderDrawBuffer."); | 41 "Defers rendering in GrContext via GrInOrderDrawBuffer."); |
42 | 42 |
43 #define BUFFERED_DRAW (c_Defer ? kYes_BufferedDraw : kNo_BufferedDraw) | 43 #define BUFFERED_DRAW (c_Defer ? kYes_BufferedDraw : kNo_BufferedDraw) |
44 | 44 |
45 // When we're using coverage AA but the blend is incompatible (given gpu | 45 // When we're using coverage AA but the blend is incompatible (given gpu |
46 // limitations) should we disable AA or draw wrong? | 46 // limitations) should we disable AA or draw wrong? |
47 #define DISABLE_COVERAGE_AA_FOR_BLEND 1 | 47 #define DISABLE_COVERAGE_AA_FOR_BLEND 1 |
48 | 48 |
49 #if GR_DEBUG | 49 #if SK_DEBUG |
50 // change this to a 1 to see notifications when partial coverage fails | 50 // change this to a 1 to see notifications when partial coverage fails |
51 #define GR_DEBUG_PARTIAL_COVERAGE_CHECK 0 | 51 #define GR_DEBUG_PARTIAL_COVERAGE_CHECK 0 |
52 #else | 52 #else |
53 #define GR_DEBUG_PARTIAL_COVERAGE_CHECK 0 | 53 #define GR_DEBUG_PARTIAL_COVERAGE_CHECK 0 |
54 #endif | 54 #endif |
55 | 55 |
56 static const size_t MAX_TEXTURE_CACHE_COUNT = 2048; | 56 static const size_t MAX_TEXTURE_CACHE_COUNT = 2048; |
57 static const size_t MAX_TEXTURE_CACHE_BYTES = GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT
* 1024 * 1024; | 57 static const size_t MAX_TEXTURE_CACHE_BYTES = GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT
* 1024 * 1024; |
58 | 58 |
59 static const size_t DRAW_BUFFER_VBPOOL_BUFFER_SIZE = 1 << 15; | 59 static const size_t DRAW_BUFFER_VBPOOL_BUFFER_SIZE = 1 << 15; |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 // we check if the rect will be axis-aligned, and the rect won't land on | 688 // we check if the rect will be axis-aligned, and the rect won't land on |
689 // integer coords. | 689 // integer coords. |
690 | 690 |
691 // we are keeping around the "tweak the alpha" trick because | 691 // we are keeping around the "tweak the alpha" trick because |
692 // it is our only hope for the fixed-pipe implementation. | 692 // it is our only hope for the fixed-pipe implementation. |
693 // In a shader implementation we can give a separate coverage input | 693 // In a shader implementation we can give a separate coverage input |
694 // TODO: remove this ugliness when we drop the fixed-pipe impl | 694 // TODO: remove this ugliness when we drop the fixed-pipe impl |
695 *useVertexCoverage = false; | 695 *useVertexCoverage = false; |
696 if (!target->getDrawState().canTweakAlphaForCoverage()) { | 696 if (!target->getDrawState().canTweakAlphaForCoverage()) { |
697 if (disable_coverage_aa_for_blend(target)) { | 697 if (disable_coverage_aa_for_blend(target)) { |
698 #if GR_DEBUG | 698 #if SK_DEBUG |
699 //GrPrintf("Turning off AA to correctly apply blend.\n"); | 699 //GrPrintf("Turning off AA to correctly apply blend.\n"); |
700 #endif | 700 #endif |
701 return false; | 701 return false; |
702 } else { | 702 } else { |
703 *useVertexCoverage = true; | 703 *useVertexCoverage = true; |
704 } | 704 } |
705 } | 705 } |
706 const GrDrawState& drawState = target->getDrawState(); | 706 const GrDrawState& drawState = target->getDrawState(); |
707 if (drawState.getRenderTarget()->isMultisampled()) { | 707 if (drawState.getRenderTarget()->isMultisampled()) { |
708 return false; | 708 return false; |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 | 1106 |
1107 void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath&
path, | 1107 void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath&
path, |
1108 const SkStrokeRec& stroke) { | 1108 const SkStrokeRec& stroke) { |
1109 SkASSERT(!path.isEmpty()); | 1109 SkASSERT(!path.isEmpty()); |
1110 | 1110 |
1111 // An Assumption here is that path renderer would use some form of tweaking | 1111 // An Assumption here is that path renderer would use some form of tweaking |
1112 // the src color (either the input alpha or in the frag shader) to implement | 1112 // the src color (either the input alpha or in the frag shader) to implement |
1113 // aa. If we have some future driver-mojo path AA that can do the right | 1113 // aa. If we have some future driver-mojo path AA that can do the right |
1114 // thing WRT to the blend then we'll need some query on the PR. | 1114 // thing WRT to the blend then we'll need some query on the PR. |
1115 if (disable_coverage_aa_for_blend(target)) { | 1115 if (disable_coverage_aa_for_blend(target)) { |
1116 #if GR_DEBUG | 1116 #if SK_DEBUG |
1117 //GrPrintf("Turning off AA to correctly apply blend.\n"); | 1117 //GrPrintf("Turning off AA to correctly apply blend.\n"); |
1118 #endif | 1118 #endif |
1119 useAA = false; | 1119 useAA = false; |
1120 } | 1120 } |
1121 | 1121 |
1122 GrPathRendererChain::DrawType type = useAA ? GrPathRendererChain::kColorAnti
Alias_DrawType : | 1122 GrPathRendererChain::DrawType type = useAA ? GrPathRendererChain::kColorAnti
Alias_DrawType : |
1123 GrPathRendererChain::kColor_Dra
wType; | 1123 GrPathRendererChain::kColor_Dra
wType; |
1124 | 1124 |
1125 const SkPath* pathPtr = &path; | 1125 const SkPath* pathPtr = &path; |
1126 SkPath tmpPath; | 1126 SkPath tmpPath; |
(...skipping 12 matching lines...) Expand all Loading... |
1139 } | 1139 } |
1140 if (pathPtr->isEmpty()) { | 1140 if (pathPtr->isEmpty()) { |
1141 return; | 1141 return; |
1142 } | 1142 } |
1143 | 1143 |
1144 // This time, allow SW renderer | 1144 // This time, allow SW renderer |
1145 pr = this->getPathRenderer(*pathPtr, strokeRec, target, true, type); | 1145 pr = this->getPathRenderer(*pathPtr, strokeRec, target, true, type); |
1146 } | 1146 } |
1147 | 1147 |
1148 if (NULL == pr) { | 1148 if (NULL == pr) { |
1149 #if GR_DEBUG | 1149 #if SK_DEBUG |
1150 GrPrintf("Unable to find path renderer compatible with path.\n"); | 1150 GrPrintf("Unable to find path renderer compatible with path.\n"); |
1151 #endif | 1151 #endif |
1152 return; | 1152 return; |
1153 } | 1153 } |
1154 | 1154 |
1155 pr->drawPath(*pathPtr, strokeRec, target, useAA); | 1155 pr->drawPath(*pathPtr, strokeRec, target, useAA); |
1156 } | 1156 } |
1157 | 1157 |
1158 //////////////////////////////////////////////////////////////////////////////// | 1158 //////////////////////////////////////////////////////////////////////////////// |
1159 | 1159 |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 return NULL; | 1733 return NULL; |
1734 } | 1734 } |
1735 } | 1735 } |
1736 | 1736 |
1737 /////////////////////////////////////////////////////////////////////////////// | 1737 /////////////////////////////////////////////////////////////////////////////// |
1738 #if GR_CACHE_STATS | 1738 #if GR_CACHE_STATS |
1739 void GrContext::printCacheStats() const { | 1739 void GrContext::printCacheStats() const { |
1740 fTextureCache->printStats(); | 1740 fTextureCache->printStats(); |
1741 } | 1741 } |
1742 #endif | 1742 #endif |
OLD | NEW |