| 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 "GrCaps.h" | 11 #include "GrCaps.h" |
| 12 #include "GrClip.h" | 12 #include "GrClip.h" |
| 13 #include "GrColor.h" | 13 #include "GrColor.h" |
| 14 #include "GrPaint.h" | 14 #include "GrPaint.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 "SkPathEffect.h" | 18 #include "SkPathEffect.h" |
| 19 #include "SkTypes.h" | 19 #include "SkTypes.h" |
| 20 #include "../private/GrAuditTrail.h" | 20 #include "../private/GrAuditTrail.h" |
| 21 #include "../private/GrSingleOwner.h" | 21 #include "../private/GrSingleOwner.h" |
| 22 #include "../private/SkMutex.h" | 22 #include "../private/SkMutex.h" |
| 23 | 23 |
| 24 struct GrBatchAtlasConfig; | 24 struct GrBatchAtlasConfig; |
| 25 class GrBatchFontCache; | 25 class GrBatchFontCache; |
| 26 struct GrContextOptions; | 26 struct GrContextOptions; |
| 27 class GrContextThreadSafeProxy; |
| 27 class GrDrawingManager; | 28 class GrDrawingManager; |
| 28 class GrDrawContext; | 29 class GrDrawContext; |
| 29 class GrDrawTarget; | 30 class GrDrawTarget; |
| 30 class GrFragmentProcessor; | 31 class GrFragmentProcessor; |
| 31 class GrGpu; | 32 class GrGpu; |
| 32 class GrIndexBuffer; | 33 class GrIndexBuffer; |
| 33 class GrLayerCache; | 34 class GrLayerCache; |
| 34 class GrOvalRenderer; | 35 class GrOvalRenderer; |
| 35 class GrPath; | 36 class GrPath; |
| 36 class GrPipelineBuilder; | 37 class GrPipelineBuilder; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 54 static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions
& options); | 55 static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions
& options); |
| 55 static GrContext* Create(GrBackend, GrBackendContext); | 56 static GrContext* Create(GrBackend, GrBackendContext); |
| 56 | 57 |
| 57 /** | 58 /** |
| 58 * Only defined in test apps. | 59 * Only defined in test apps. |
| 59 */ | 60 */ |
| 60 static GrContext* CreateMockContext(); | 61 static GrContext* CreateMockContext(); |
| 61 | 62 |
| 62 virtual ~GrContext(); | 63 virtual ~GrContext(); |
| 63 | 64 |
| 65 GrContextThreadSafeProxy* threadSafeProxy(); |
| 66 |
| 64 /** | 67 /** |
| 65 * The GrContext normally assumes that no outsider is setting state | 68 * The GrContext normally assumes that no outsider is setting state |
| 66 * within the underlying 3D API's context/device/whatever. This call informs | 69 * within the underlying 3D API's context/device/whatever. This call informs |
| 67 * the context that the state was modified and it should resend. Shouldn't | 70 * the context that the state was modified and it should resend. Shouldn't |
| 68 * be called frequently for good performance. | 71 * be called frequently for good performance. |
| 69 * The flag bits, state, is dpendent on which backend is used by the | 72 * The flag bits, state, is dpendent on which backend is used by the |
| 70 * context, either GL or D3D (possible in future). | 73 * context, either GL or D3D (possible in future). |
| 71 */ | 74 */ |
| 72 void resetContext(uint32_t state = kAll_GrBackendState); | 75 void resetContext(uint32_t state = kAll_GrBackendState); |
| 73 | 76 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 355 |
| 353 /** Get pointer to atlas texture for given mask format */ | 356 /** Get pointer to atlas texture for given mask format */ |
| 354 GrTexture* getFontAtlasTexture(GrMaskFormat format); | 357 GrTexture* getFontAtlasTexture(GrMaskFormat format); |
| 355 | 358 |
| 356 GrAuditTrail* getAuditTrail() { return &fAuditTrail; } | 359 GrAuditTrail* getAuditTrail() { return &fAuditTrail; } |
| 357 | 360 |
| 358 /** This is only useful for debug purposes */ | 361 /** This is only useful for debug purposes */ |
| 359 SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fSingleOwner;
} ) | 362 SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fSingleOwner;
} ) |
| 360 | 363 |
| 361 private: | 364 private: |
| 362 GrGpu* fGpu; | 365 GrGpu* fGpu; |
| 363 const GrCaps* fCaps; | 366 const GrCaps* fCaps; |
| 364 GrResourceCache* fResourceCache; | 367 GrResourceCache* fResourceCache; |
| 365 // this union exists because the inheritance of GrTextureProvider->GrResourc
eProvider | 368 // this union exists because the inheritance of GrTextureProvider->GrResourc
eProvider |
| 366 // is in a private header. | 369 // is in a private header. |
| 367 union { | 370 union { |
| 368 GrResourceProvider* fResourceProvider; | 371 GrResourceProvider* fResourceProvider; |
| 369 GrTextureProvider* fTextureProvider; | 372 GrTextureProvider* fTextureProvider; |
| 370 }; | 373 }; |
| 371 | 374 |
| 372 GrBatchFontCache* fBatchFontCache; | 375 SkAutoTUnref<GrContextThreadSafeProxy> fThreadSafeProxy; |
| 373 SkAutoTDelete<GrLayerCache> fLayerCache; | 376 |
| 374 SkAutoTDelete<GrTextBlobCache> fTextBlobCache; | 377 GrBatchFontCache* fBatchFontCache; |
| 378 SkAutoTDelete<GrLayerCache> fLayerCache; |
| 379 SkAutoTDelete<GrTextBlobCache> fTextBlobCache; |
| 375 | 380 |
| 376 // Set by OverbudgetCB() to request that GrContext flush before exiting a dr
aw. | 381 // Set by OverbudgetCB() to request that GrContext flush before exiting a dr
aw. |
| 377 bool fFlushToReduceCacheSize; | 382 bool fFlushToReduceCacheSize; |
| 378 bool fDidTestPMConversions; | 383 bool fDidTestPMConversions; |
| 379 int fPMToUPMConversion; | 384 int fPMToUPMConversion; |
| 380 int fUPMToPMConversion; | 385 int fUPMToPMConversion; |
| 381 // The sw backend may call GrContext::readSurfacePixels on multiple threads | 386 // The sw backend may call GrContext::readSurfacePixels on multiple threads |
| 382 // We may transfer the responsibilty for using a mutex to the sw backend | 387 // We may transfer the responsibilty for using a mutex to the sw backend |
| 383 // when there are fewer code paths that lead to a readSurfacePixels call | 388 // when there are fewer code paths that lead to a readSurfacePixels call |
| 384 // from the sw backend. readSurfacePixels is reentrant in one case - when pe
rforming | 389 // from the sw backend. readSurfacePixels is reentrant in one case - when pe
rforming |
| 385 // the PM conversions test. To handle this we do the PM conversions test out
side | 390 // the PM conversions test. To handle this we do the PM conversions test out
side |
| 386 // of fReadPixelsMutex and use a separate mutex to guard it. When it re-ente
rs | 391 // of fReadPixelsMutex and use a separate mutex to guard it. When it re-ente
rs |
| 387 // readSurfacePixels it will grab fReadPixelsMutex and release it before the
outer | 392 // readSurfacePixels it will grab fReadPixelsMutex and release it before the
outer |
| 388 // readSurfacePixels proceeds to grab it. | 393 // readSurfacePixels proceeds to grab it. |
| 389 // TODO: Stop pretending to make GrContext thread-safe for sw rasterization
and provide | 394 // TODO: Stop pretending to make GrContext thread-safe for sw rasterization
and provide |
| 390 // a mechanism to make a SkPicture safe for multithreaded sw rasterization. | 395 // a mechanism to make a SkPicture safe for multithreaded sw rasterization. |
| 391 SkMutex fReadPixelsMutex; | 396 SkMutex fReadPixelsMutex; |
| 392 SkMutex fTestPMConversionsMutex; | 397 SkMutex fTestPMConversionsMutex; |
| 393 | 398 |
| 394 // In debug builds we guard against improper thread handling | 399 // In debug builds we guard against improper thread handling |
| 395 // This guard is passed to the GrDrawingManager and, from there to all the | 400 // This guard is passed to the GrDrawingManager and, from there to all the |
| 396 // GrDrawContexts. It is also passed to the GrTextureProvider and SkGpuDevi
ce. | 401 // GrDrawContexts. It is also passed to the GrTextureProvider and SkGpuDevi
ce. |
| 397 mutable GrSingleOwner fSingleOwner; | 402 mutable GrSingleOwner fSingleOwner; |
| 398 | 403 |
| 399 struct CleanUpData { | 404 struct CleanUpData { |
| 400 PFCleanUpFunc fFunc; | 405 PFCleanUpFunc fFunc; |
| 401 void* fInfo; | 406 void* fInfo; |
| 402 }; | 407 }; |
| 403 | 408 |
| 404 SkTDArray<CleanUpData> fCleanUpData; | 409 SkTDArray<CleanUpData> fCleanUpData; |
| 405 | 410 |
| 406 const uint32_t fUniqueID; | 411 const uint32_t fUniqueID; |
| 407 | 412 |
| 408 SkAutoTDelete<GrDrawingManager> fDrawingManager; | 413 SkAutoTDelete<GrDrawingManager> fDrawingManager; |
| 409 | 414 |
| 410 GrAuditTrail fAuditTrail; | 415 GrAuditTrail fAuditTrail; |
| 411 | 416 |
| 412 // TODO: have the CMM use drawContexts and rm this friending | 417 // TODO: have the CMM use drawContexts and rm this friending |
| 413 friend class GrClipMaskManager; // the CMM is friended just so it can call '
drawingManager' | 418 friend class GrClipMaskManager; // the CMM is friended just so it can call '
drawingManager' |
| 414 friend class GrDrawingManager; // for access to drawingManager for ProgramU
nitTest | 419 friend class GrDrawingManager; // for access to drawingManager for ProgramU
nitTest |
| 415 GrDrawingManager* drawingManager() { return fDrawingManager; } | 420 GrDrawingManager* drawingManager() { return fDrawingManager; } |
| 416 | 421 |
| 417 GrContext(); // init must be called after the constructor. | 422 GrContext(); // init must be called after the constructor. |
| 418 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); | 423 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); |
| 419 | 424 |
| 420 void initMockContext(); | 425 void initMockContext(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 445 | 450 |
| 446 /** | 451 /** |
| 447 * A callback similar to the above for use by the TextBlobCache | 452 * A callback similar to the above for use by the TextBlobCache |
| 448 * TODO move textblob draw calls below context so we can use the call above. | 453 * TODO move textblob draw calls below context so we can use the call above. |
| 449 */ | 454 */ |
| 450 static void TextBlobCacheOverBudgetCB(void* data); | 455 static void TextBlobCacheOverBudgetCB(void* data); |
| 451 | 456 |
| 452 typedef SkRefCnt INHERITED; | 457 typedef SkRefCnt INHERITED; |
| 453 }; | 458 }; |
| 454 | 459 |
| 460 class GrContextThreadSafeProxy : public SkRefCnt { |
| 461 private: |
| 462 GrContextThreadSafeProxy(const GrCaps* caps, uint32_t uniqueID) |
| 463 : fCaps(SkRef(caps)) |
| 464 , fContextUniqueID(uniqueID) {} |
| 465 |
| 466 SkAutoTUnref<const GrCaps> fCaps; |
| 467 uint32_t fContextUniqueID; |
| 468 |
| 469 friend class GrContext; |
| 470 friend class SkImage; |
| 471 |
| 472 typedef SkRefCnt INHERITED; |
| 473 }; |
| 474 |
| 455 #endif | 475 #endif |
| OLD | NEW |