| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 4 * | 3 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 #include "GrContext.h" | 8 #include "GrContext.h" |
| 10 #include "GrContextOptions.h" | 9 #include "GrContextOptions.h" |
| 11 #include "GrDrawingManager.h" | 10 #include "GrDrawingManager.h" |
| 12 #include "GrDrawContext.h" | 11 #include "GrDrawContext.h" |
| 13 #include "GrLayerCache.h" | 12 #include "GrLayerCache.h" |
| 14 #include "GrResourceCache.h" | 13 #include "GrResourceCache.h" |
| 15 #include "GrResourceProvider.h" | 14 #include "GrResourceProvider.h" |
| 16 #include "GrSoftwarePathRenderer.h" | 15 #include "GrSoftwarePathRenderer.h" |
| 17 #include "GrSurfacePriv.h" | 16 #include "GrSurfacePriv.h" |
| 18 #include "GrTextBlobCache.h" | 17 #include "GrTextBlobCache.h" |
| 19 | 18 |
| 20 #include "SkConfig8888.h" | 19 #include "SkConfig8888.h" |
| 21 #include "SkGrPriv.h" | 20 #include "SkGrPriv.h" |
| 21 #include "SkTypes.h" |
| 22 | 22 |
| 23 #include "effects/GrConfigConversionEffect.h" | 23 #include "effects/GrConfigConversionEffect.h" |
| 24 | 24 |
| 25 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) | 25 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) |
| 26 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } | 26 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } |
| 27 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal
se; } | 27 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal
se; } |
| 28 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return null
ptr; } | 28 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return null
ptr; } |
| 29 | 29 |
| 30 //////////////////////////////////////////////////////////////////////////////// | 30 //////////////////////////////////////////////////////////////////////////////// |
| 31 | 31 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 239 } |
| 240 | 240 |
| 241 GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference; | 241 GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference; |
| 242 // Don't prefer to draw for the conversion (and thereby access a texture fro
m the cache) when | 242 // Don't prefer to draw for the conversion (and thereby access a texture fro
m the cache) when |
| 243 // we've already determined that there isn't a roundtrip preserving conversi
on processor pair. | 243 // we've already determined that there isn't a roundtrip preserving conversi
on processor pair. |
| 244 if (applyPremulToSrc && !this->didFailPMUPMConversionTest()) { | 244 if (applyPremulToSrc && !this->didFailPMUPMConversionTest()) { |
| 245 drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference; | 245 drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference; |
| 246 } | 246 } |
| 247 | 247 |
| 248 GrGpu::WritePixelTempDrawInfo tempDrawInfo; | 248 GrGpu::WritePixelTempDrawInfo tempDrawInfo; |
| 249 if (!fGpu->getWritePixelsInfo(surface, width, height, rowBytes, srcConfig, &
drawPreference, | 249 if (!fGpu->getWritePixelsInfo(surface, width, height, srcConfig, &drawPrefer
ence, |
| 250 &tempDrawInfo)) { | 250 &tempDrawInfo)) { |
| 251 return false; | 251 return false; |
| 252 } | 252 } |
| 253 | 253 |
| 254 if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().has
PendingIO()) { | 254 if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().has
PendingIO()) { |
| 255 this->flush(); | 255 this->flush(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 SkAutoTUnref<GrTexture> tempTexture; | 258 SkAutoTUnref<GrTexture> tempTexture; |
| 259 if (GrGpu::kNoDraw_DrawPreference != drawPreference) { | 259 if (GrGpu::kNoDraw_DrawPreference != drawPreference) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, rect, nullp
tr); | 328 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, rect, nullp
tr); |
| 329 | 329 |
| 330 if (kFlushWrites_PixelOp & pixelOpsFlags) { | 330 if (kFlushWrites_PixelOp & pixelOpsFlags) { |
| 331 this->flushSurfaceWrites(surface); | 331 this->flushSurfaceWrites(surface); |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 if (!tempTexture) { | 335 if (!tempTexture) { |
| 336 if (applyPremulToSrc) { | 336 if (applyPremulToSrc) { |
| 337 size_t tmpRowBytes = 4 * width; | 337 size_t tmpRowBytes = 4 * width; |
| 338 |
| 338 tmpPixels.reset(width * height); | 339 tmpPixels.reset(width * height); |
| 339 if (!sw_convert_to_premul(srcConfig, width, height, rowBytes, buffer
, tmpRowBytes, | 340 if (!sw_convert_to_premul(srcConfig, width, height, rowBytes, buffer
, tmpRowBytes, |
| 340 tmpPixels.get())) { | 341 tmpPixels.get())) { |
| 341 return false; | 342 return false; |
| 342 } | 343 } |
| 343 rowBytes = tmpRowBytes; | 344 rowBytes = tmpRowBytes; |
| 344 buffer = tmpPixels.get(); | 345 buffer = tmpPixels.get(); |
| 345 applyPremulToSrc = false; | 346 applyPremulToSrc = false; |
| 346 } | 347 } |
| 347 return fGpu->writePixels(surface, left, top, width, height, srcConfig, b
uffer, rowBytes); | 348 return fGpu->writePixels(surface, left, top, width, height, srcConfig, b
uffer, rowBytes); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 621 |
| 621 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
{ | 622 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
{ |
| 622 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 623 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
| 623 } | 624 } |
| 624 | 625 |
| 625 ////////////////////////////////////////////////////////////////////////////// | 626 ////////////////////////////////////////////////////////////////////////////// |
| 626 | 627 |
| 627 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 628 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
| 628 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 629 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
| 629 } | 630 } |
| OLD | NEW |