| 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 #include "GrContextOptions.h" | 10 #include "GrContextOptions.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool GrContext::init(GrBackend backend, GrBackendContext backendContext, | 67 bool GrContext::init(GrBackend backend, GrBackendContext backendContext, |
| 68 const GrContextOptions& options) { | 68 const GrContextOptions& options) { |
| 69 SkASSERT(!fGpu); | 69 SkASSERT(!fGpu); |
| 70 | 70 |
| 71 fGpu = GrGpu::Create(backend, backendContext, options, this); | 71 fGpu = GrGpu::Create(backend, backendContext, options, this); |
| 72 if (!fGpu) { | 72 if (!fGpu) { |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 this->initCommon(); | 75 this->initCommon(options); |
| 76 return true; | 76 return true; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void GrContext::initCommon() { | 79 void GrContext::initCommon(const GrContextOptions& options) { |
| 80 fCaps = SkRef(fGpu->caps()); | 80 fCaps = SkRef(fGpu->caps()); |
| 81 fResourceCache = new GrResourceCache(fCaps); | 81 fResourceCache = new GrResourceCache(fCaps); |
| 82 fResourceCache->setOverBudgetCallback(OverBudgetCB, this); | 82 fResourceCache->setOverBudgetCallback(OverBudgetCB, this); |
| 83 fResourceProvider = new GrResourceProvider(fGpu, fResourceCache); | 83 fResourceProvider = new GrResourceProvider(fGpu, fResourceCache); |
| 84 | 84 |
| 85 fLayerCache.reset(new GrLayerCache(this)); | 85 fLayerCache.reset(new GrLayerCache(this)); |
| 86 | 86 |
| 87 fDidTestPMConversions = false; | 87 fDidTestPMConversions = false; |
| 88 | 88 |
| 89 fDrawingManager.reset(new GrDrawingManager(this)); | 89 GrDrawTarget::Options dtOptions; |
| 90 dtOptions.fClipBatchToBounds = options.fClipBatchToBounds; |
| 91 fDrawingManager.reset(new GrDrawingManager(this, dtOptions)); |
| 90 | 92 |
| 91 // GrBatchFontCache will eventually replace GrFontCache | 93 // GrBatchFontCache will eventually replace GrFontCache |
| 92 fBatchFontCache = new GrBatchFontCache(this); | 94 fBatchFontCache = new GrBatchFontCache(this); |
| 93 | 95 |
| 94 fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this)); | 96 fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this)); |
| 95 } | 97 } |
| 96 | 98 |
| 97 GrContext::~GrContext() { | 99 GrContext::~GrContext() { |
| 98 if (!fGpu) { | 100 if (!fGpu) { |
| 99 SkASSERT(!fCaps); | 101 SkASSERT(!fCaps); |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 | 623 |
| 622 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
{ | 624 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
{ |
| 623 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 625 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
| 624 } | 626 } |
| 625 | 627 |
| 626 ////////////////////////////////////////////////////////////////////////////// | 628 ////////////////////////////////////////////////////////////////////////////// |
| 627 | 629 |
| 628 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 630 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
| 629 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 631 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
| 630 } | 632 } |
| OLD | NEW |