| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
| 3 * | 3 * |
| 4 * 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 |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrContext_DEFINED | 8 #ifndef GrContext_DEFINED |
| 9 #define GrContext_DEFINED | 9 #define GrContext_DEFINED |
| 10 | 10 |
| 11 #include "GrClip.h" | 11 #include "GrClip.h" |
| 12 #include "GrColor.h" | 12 #include "GrColor.h" |
| 13 #include "GrPaint.h" | 13 #include "GrPaint.h" |
| 14 #include "GrPathRendererChain.h" | 14 #include "GrPathRendererChain.h" |
| 15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
| 16 #include "GrTextureProvider.h" | 16 #include "GrTextureProvider.h" |
| 17 #include "SkMatrix.h" | 17 #include "SkMatrix.h" |
| 18 #include "SkMutex.h" |
| 18 #include "SkPathEffect.h" | 19 #include "SkPathEffect.h" |
| 19 #include "SkTypes.h" | 20 #include "SkTypes.h" |
| 20 | 21 |
| 21 struct GrBatchAtlasConfig; | 22 struct GrBatchAtlasConfig; |
| 22 class GrBatchFontCache; | 23 class GrBatchFontCache; |
| 23 class GrCaps; | 24 class GrCaps; |
| 24 struct GrContextOptions; | 25 struct GrContextOptions; |
| 25 class GrDrawContext; | 26 class GrDrawContext; |
| 26 class GrDrawTarget; | 27 class GrDrawTarget; |
| 27 class GrFragmentProcessor; | 28 class GrFragmentProcessor; |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 SkAutoTDelete<GrTextBlobCache> fTextBlobCache; | 374 SkAutoTDelete<GrTextBlobCache> fTextBlobCache; |
| 374 | 375 |
| 375 GrPathRendererChain* fPathRendererChain; | 376 GrPathRendererChain* fPathRendererChain; |
| 376 GrSoftwarePathRenderer* fSoftwarePathRenderer; | 377 GrSoftwarePathRenderer* fSoftwarePathRenderer; |
| 377 | 378 |
| 378 // Set by OverbudgetCB() to request that GrContext flush before exiting a dr
aw. | 379 // Set by OverbudgetCB() to request that GrContext flush before exiting a dr
aw. |
| 379 bool fFlushToReduceCacheSize; | 380 bool fFlushToReduceCacheSize; |
| 380 bool fDidTestPMConversions; | 381 bool fDidTestPMConversions; |
| 381 int fPMToUPMConversion; | 382 int fPMToUPMConversion; |
| 382 int fUPMToPMConversion; | 383 int fUPMToPMConversion; |
| 384 // The sw backend may call GrContext::readSurfacePixels on multiple threads |
| 385 // We may transfer the responsibilty for using a mutex to the sw backend |
| 386 // when there are fewer code paths that lead to a readSurfacePixels call |
| 387 // from the sw backend. readSurfacePixels is reentrant in one case - when pe
rforming |
| 388 // the PM conversions test. To handle this we do the PM conversions test out
side |
| 389 // of fReadPixelsMutex and use a separate mutex to guard it. When it re-ente
rs |
| 390 // readSurfacePixels it will grab fReadPixelsMutex and release it before the
outer |
| 391 // readSurfacePixels proceeds to grab it. |
| 392 // TODO: Stop pretending to make GrContext thread-safe for sw rasterization
and provide |
| 393 // a mechanism to make a SkPicture safe for multithreaded sw rasterization. |
| 394 SkMutex fReadPixelsMutex; |
| 395 SkMutex fTestPMConversionsMutex; |
| 383 | 396 |
| 384 struct CleanUpData { | 397 struct CleanUpData { |
| 385 PFCleanUpFunc fFunc; | 398 PFCleanUpFunc fFunc; |
| 386 void* fInfo; | 399 void* fInfo; |
| 387 }; | 400 }; |
| 388 | 401 |
| 389 SkTDArray<CleanUpData> fCleanUpData; | 402 SkTDArray<CleanUpData> fCleanUpData; |
| 390 | 403 |
| 391 const uint32_t fUniqueID; | 404 const uint32_t fUniqueID; |
| 392 | 405 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 452 |
| 440 void initMockContext(); | 453 void initMockContext(); |
| 441 void initCommon(); | 454 void initCommon(); |
| 442 | 455 |
| 443 /** | 456 /** |
| 444 * These functions create premul <-> unpremul effects if it is possible to g
enerate a pair | 457 * These functions create premul <-> unpremul effects if it is possible to g
enerate a pair |
| 445 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O
therwise, they | 458 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O
therwise, they |
| 446 * return NULL. | 459 * return NULL. |
| 447 */ | 460 */ |
| 448 const GrFragmentProcessor* createPMToUPMEffect(GrProcessorDataManager*, GrTe
xture*, | 461 const GrFragmentProcessor* createPMToUPMEffect(GrProcessorDataManager*, GrTe
xture*, |
| 449 bool swapRAndB, const SkMatri
x&); | 462 bool swapRAndB, const SkMatri
x&) const; |
| 450 const GrFragmentProcessor* createUPMToPMEffect(GrProcessorDataManager*, GrTe
xture*, | 463 const GrFragmentProcessor* createUPMToPMEffect(GrProcessorDataManager*, GrTe
xture*, |
| 451 bool swapRAndB, const SkMatri
x&); | 464 bool swapRAndB, const SkMatri
x&) const; |
| 465 /** Called before either of the above two functions to determine the appropr
iate fragment |
| 466 processors for conversions. This must be called by readSurfacePixels bef
or a mutex is taken, |
| 467 since testingvPM conversions itself will call readSurfacePixels */ |
| 468 void testPMConversionsIfNecessary(uint32_t flags); |
| 452 /** Returns true if we've already determined that createPMtoUPMEffect and cr
eateUPMToPMEffect | 469 /** Returns true if we've already determined that createPMtoUPMEffect and cr
eateUPMToPMEffect |
| 453 will fail. In such cases fall back to SW conversion. */ | 470 will fail. In such cases fall back to SW conversion. */ |
| 454 bool didFailPMUPMConversionTest() const; | 471 bool didFailPMUPMConversionTest() const; |
| 455 | 472 |
| 456 /** | 473 /** |
| 457 * This callback allows the resource cache to callback into the GrContext | 474 * This callback allows the resource cache to callback into the GrContext |
| 458 * when the cache is still over budget after a purge. | 475 * when the cache is still over budget after a purge. |
| 459 */ | 476 */ |
| 460 static void OverBudgetCB(void* data); | 477 static void OverBudgetCB(void* data); |
| 461 | 478 |
| 462 /** | 479 /** |
| 463 * A callback similar to the above for use by the TextBlobCache | 480 * A callback similar to the above for use by the TextBlobCache |
| 464 * TODO move textblob draw calls below context so we can use the call above. | 481 * TODO move textblob draw calls below context so we can use the call above. |
| 465 */ | 482 */ |
| 466 static void TextBlobCacheOverBudgetCB(void* data); | 483 static void TextBlobCacheOverBudgetCB(void* data); |
| 467 | 484 |
| 468 typedef SkRefCnt INHERITED; | 485 typedef SkRefCnt INHERITED; |
| 469 }; | 486 }; |
| 470 | 487 |
| 471 #endif | 488 #endif |
| OLD | NEW |