| 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 27 matching lines...) Expand all Loading... |
| 38 #include "GrVertices.h" | 38 #include "GrVertices.h" |
| 39 #include "SkDashPathPriv.h" | 39 #include "SkDashPathPriv.h" |
| 40 #include "SkConfig8888.h" | 40 #include "SkConfig8888.h" |
| 41 #include "SkGrPriv.h" | 41 #include "SkGrPriv.h" |
| 42 #include "SkRRect.h" | 42 #include "SkRRect.h" |
| 43 #include "SkStrokeRec.h" | 43 #include "SkStrokeRec.h" |
| 44 #include "SkSurfacePriv.h" | 44 #include "SkSurfacePriv.h" |
| 45 #include "SkTLazy.h" | 45 #include "SkTLazy.h" |
| 46 #include "SkTLS.h" | 46 #include "SkTLS.h" |
| 47 #include "SkTraceEvent.h" | 47 #include "SkTraceEvent.h" |
| 48 | 48 #include "SkTTopoSort.h" |
| 49 | 49 |
| 50 #include "batches/GrBatch.h" | 50 #include "batches/GrBatch.h" |
| 51 | 51 |
| 52 #include "effects/GrConfigConversionEffect.h" | 52 #include "effects/GrConfigConversionEffect.h" |
| 53 #include "effects/GrDashingEffect.h" | 53 #include "effects/GrDashingEffect.h" |
| 54 #include "effects/GrSingleTextureEffect.h" | 54 #include "effects/GrSingleTextureEffect.h" |
| 55 | 55 |
| 56 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) | 56 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) |
| 57 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } | 57 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } |
| 58 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal
se; } | 58 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal
se; } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 88 this->cleanup(); | 88 this->cleanup(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void GrDrawingManager::reset() { | 91 void GrDrawingManager::reset() { |
| 92 for (int i = 0; i < fDrawTargets.count(); ++i) { | 92 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 93 fDrawTargets[i]->reset(); | 93 fDrawTargets[i]->reset(); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 void GrDrawingManager::flush() { | 97 void GrDrawingManager::flush() { |
| 98 |
| 99 struct TopoSortTraits { |
| 100 static void Output(GrDrawTarget* dt, int /* index */) { |
| 101 dt->setFlag(GrDrawTarget::kWasOutput_Flag); |
| 102 } |
| 103 static bool WasOutput(const GrDrawTarget* dt) { |
| 104 return dt->isSetFlag(GrDrawTarget::kWasOutput_Flag); |
| 105 } |
| 106 static void SetTempMark(GrDrawTarget* dt) { |
| 107 dt->setFlag(GrDrawTarget::kTempMark_Flag); |
| 108 } |
| 109 static void ResetTempMark(GrDrawTarget* dt) { |
| 110 dt->resetFlag(GrDrawTarget::kTempMark_Flag); |
| 111 } |
| 112 static bool IsTempMarked(const GrDrawTarget* dt) { |
| 113 return dt->isSetFlag(GrDrawTarget::kTempMark_Flag); |
| 114 } |
| 115 static int NumDependencies(const GrDrawTarget* dt) { |
| 116 return dt->numDependencies(); |
| 117 } |
| 118 static GrDrawTarget* Dependency(GrDrawTarget* dt, int index) { |
| 119 return dt->dependency(index); |
| 120 } |
| 121 }; |
| 122 |
| 123 SkDEBUGCODE(bool result =) SkTTopoSort<GrDrawTarget, TopoSortTraits>(&fDrawT
argets); |
| 124 SkASSERT(result); |
| 125 |
| 98 for (int i = 0; i < fDrawTargets.count(); ++i) { | 126 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 99 fDrawTargets[i]->flush(); | 127 fDrawTargets[i]->flush(); |
| 100 } | 128 } |
| 129 |
| 130 #ifndef ENABLE_MDB |
| 131 // When MDB is disabled we keep reusing the same drawTarget |
| 132 if (fDrawTargets.count()) { |
| 133 SkASSERT(fDrawTargets.count() == 1); |
| 134 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); |
| 135 } |
| 136 #endif |
| 101 } | 137 } |
| 102 | 138 |
| 103 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, | 139 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, |
| 104 GrRenderTarget* rt) { | 140 GrRenderTarget* rt) { |
| 105 if (this->abandoned()) { | 141 if (this->abandoned()) { |
| 106 return nullptr; | 142 return nullptr; |
| 107 } | 143 } |
| 108 | 144 |
| 109 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); | 145 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); |
| 110 bool useDIF = props.isUseDeviceIndependentFonts(); | 146 bool useDIF = props.isUseDeviceIndependentFonts(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 124 if (!fTextContexts[props.pixelGeometry()][useDIF]) { | 160 if (!fTextContexts[props.pixelGeometry()][useDIF]) { |
| 125 fTextContexts[props.pixelGeometry()][useDIF] = GrAtlasTextContext::Creat
e(fContext, props); | 161 fTextContexts[props.pixelGeometry()][useDIF] = GrAtlasTextContext::Creat
e(fContext, props); |
| 126 } | 162 } |
| 127 | 163 |
| 128 return fTextContexts[props.pixelGeometry()][useDIF]; | 164 return fTextContexts[props.pixelGeometry()][useDIF]; |
| 129 } | 165 } |
| 130 | 166 |
| 131 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { | 167 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { |
| 132 SkASSERT(fContext); | 168 SkASSERT(fContext); |
| 133 | 169 |
| 170 #ifndef ENABLE_MDB |
| 134 // When MDB is disabled we always just return the single drawTarget | 171 // When MDB is disabled we always just return the single drawTarget |
| 135 #ifndef ENABLE_MDB | |
| 136 if (fDrawTargets.count()) { | 172 if (fDrawTargets.count()) { |
| 137 SkASSERT(fDrawTargets.count() == 1); | 173 SkASSERT(fDrawTargets.count() == 1); |
| 138 // DrawingManager gets the creation ref - this ref is for the caller | 174 // DrawingManager gets the creation ref - this ref is for the caller |
| 139 return SkRef(fDrawTargets[0]); | 175 return SkRef(fDrawTargets[0]); |
| 140 } | 176 } |
| 141 #endif | 177 #endif |
| 142 | 178 |
| 143 GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourcePr
ovider()); | 179 GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourcePr
ovider()); |
| 144 | 180 |
| 145 *fDrawTargets.append() = dt; | 181 *fDrawTargets.append() = dt; |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 | 827 |
| 792 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
{ | 828 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
{ |
| 793 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 829 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
| 794 } | 830 } |
| 795 | 831 |
| 796 ////////////////////////////////////////////////////////////////////////////// | 832 ////////////////////////////////////////////////////////////////////////////// |
| 797 | 833 |
| 798 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 834 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
| 799 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 835 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
| 800 } | 836 } |
| OLD | NEW |