| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 fAARectRenderer = SkNEW_ARGS(GrAARectRenderer, (fGpu)); | 130 fAARectRenderer = SkNEW_ARGS(GrAARectRenderer, (fGpu)); |
| 131 fOvalRenderer = SkNEW_ARGS(GrOvalRenderer, (fGpu)); | 131 fOvalRenderer = SkNEW_ARGS(GrOvalRenderer, (fGpu)); |
| 132 | 132 |
| 133 fDidTestPMConversions = false; | 133 fDidTestPMConversions = false; |
| 134 | 134 |
| 135 this->setupDrawBuffer(); | 135 this->setupDrawBuffer(); |
| 136 | 136 |
| 137 // GrBatchFontCache will eventually replace GrFontCache | 137 // GrBatchFontCache will eventually replace GrFontCache |
| 138 fBatchFontCache = SkNEW_ARGS(GrBatchFontCache, (this)); | 138 fBatchFontCache = SkNEW_ARGS(GrBatchFontCache, (this)); |
| 139 | 139 |
| 140 fTextBlobCache.reset(SkNEW(GrTextBlobCache)); | 140 fTextBlobCache.reset(SkNEW_ARGS(GrTextBlobCache, (TextBlobCacheOverBudgetCB,
this))); |
| 141 } | 141 } |
| 142 | 142 |
| 143 GrContext::~GrContext() { | 143 GrContext::~GrContext() { |
| 144 if (NULL == fGpu) { | 144 if (NULL == fGpu) { |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 | 147 |
| 148 this->flush(); | 148 this->flush(); |
| 149 | 149 |
| 150 for (int i = 0; i < fCleanUpData.count(); ++i) { | 150 for (int i = 0; i < fCleanUpData.count(); ++i) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 347 |
| 348 void GrContext::OverBudgetCB(void* data) { | 348 void GrContext::OverBudgetCB(void* data) { |
| 349 SkASSERT(data); | 349 SkASSERT(data); |
| 350 | 350 |
| 351 GrContext* context = reinterpret_cast<GrContext*>(data); | 351 GrContext* context = reinterpret_cast<GrContext*>(data); |
| 352 | 352 |
| 353 // Flush the InOrderDrawBuffer to possibly free up some textures | 353 // Flush the InOrderDrawBuffer to possibly free up some textures |
| 354 context->fFlushToReduceCacheSize = true; | 354 context->fFlushToReduceCacheSize = true; |
| 355 } | 355 } |
| 356 | 356 |
| 357 void GrContext::TextBlobCacheOverBudgetCB(void* data) { |
| 358 SkASSERT(data); |
| 359 |
| 360 // Unlike the GrResourceCache, TextBlobs are drawn at the SkGpuDevice level,
therefore they |
| 361 // cannot use fFlushTorReduceCacheSize because it uses AutoCheckFlush. The
solution is to move |
| 362 // drawText calls to below the GrContext level, but this is not trivial beca
use they call |
| 363 // drawPath on SkGpuDevice |
| 364 GrContext* context = reinterpret_cast<GrContext*>(data); |
| 365 context->flush(); |
| 366 } |
| 367 |
| 357 int GrContext::getMaxTextureSize() const { | 368 int GrContext::getMaxTextureSize() const { |
| 358 return SkTMin(fGpu->caps()->maxTextureSize(), fMaxTextureSizeOverride); | 369 return SkTMin(fGpu->caps()->maxTextureSize(), fMaxTextureSizeOverride); |
| 359 } | 370 } |
| 360 | 371 |
| 361 int GrContext::getMaxRenderTargetSize() const { | 372 int GrContext::getMaxRenderTargetSize() const { |
| 362 return fGpu->caps()->maxRenderTargetSize(); | 373 return fGpu->caps()->maxRenderTargetSize(); |
| 363 } | 374 } |
| 364 | 375 |
| 365 int GrContext::getMaxSampleCount() const { | 376 int GrContext::getMaxSampleCount() const { |
| 366 return fGpu->caps()->maxSampleCount(); | 377 return fGpu->caps()->maxSampleCount(); |
| (...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 } | 2027 } |
| 2017 } | 2028 } |
| 2018 | 2029 |
| 2019 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { | 2030 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { |
| 2020 fGpu->removeGpuTraceMarker(marker); | 2031 fGpu->removeGpuTraceMarker(marker); |
| 2021 if (fDrawBuffer) { | 2032 if (fDrawBuffer) { |
| 2022 fDrawBuffer->removeGpuTraceMarker(marker); | 2033 fDrawBuffer->removeGpuTraceMarker(marker); |
| 2023 } | 2034 } |
| 2024 } | 2035 } |
| 2025 | 2036 |
| OLD | NEW |