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" | |
15 #include "GrRenderTarget.h" | 14 #include "GrRenderTarget.h" |
16 #include "GrTextureProvider.h" | 15 #include "GrTextureProvider.h" |
17 #include "SkMatrix.h" | 16 #include "SkMatrix.h" |
18 #include "../private/SkMutex.h" | 17 #include "../private/SkMutex.h" |
19 #include "SkPathEffect.h" | 18 #include "SkPathEffect.h" |
20 #include "SkTypes.h" | 19 #include "SkTypes.h" |
21 | 20 |
22 struct GrBatchAtlasConfig; | 21 struct GrBatchAtlasConfig; |
23 class GrBatchFontCache; | 22 class GrBatchFontCache; |
24 class GrCaps; | 23 class GrCaps; |
25 struct GrContextOptions; | 24 struct GrContextOptions; |
26 class GrDrawingManager; | 25 class GrDrawingManager; |
27 class GrDrawContext; | 26 class GrDrawContext; |
28 class GrDrawTarget; | 27 class GrDrawTarget; |
29 class GrFragmentProcessor; | 28 class GrFragmentProcessor; |
30 class GrGpu; | 29 class GrGpu; |
31 class GrIndexBuffer; | 30 class GrIndexBuffer; |
32 class GrLayerCache; | 31 class GrLayerCache; |
33 class GrOvalRenderer; | 32 class GrOvalRenderer; |
34 class GrPath; | 33 class GrPath; |
35 class GrPathRenderer; | |
36 class GrPipelineBuilder; | 34 class GrPipelineBuilder; |
37 class GrResourceEntry; | 35 class GrResourceEntry; |
38 class GrResourceCache; | 36 class GrResourceCache; |
39 class GrResourceProvider; | 37 class GrResourceProvider; |
40 class GrTestTarget; | 38 class GrTestTarget; |
41 class GrTextBlobCache; | 39 class GrTextBlobCache; |
42 class GrTextContext; | 40 class GrTextContext; |
43 class GrTextureParams; | 41 class GrTextureParams; |
44 class GrVertexBuffer; | 42 class GrVertexBuffer; |
45 class GrStrokeInfo; | 43 class GrStrokeInfo; |
46 class GrSoftwarePathRenderer; | |
47 class SkTraceMemoryDump; | 44 class SkTraceMemoryDump; |
48 | 45 |
49 class SK_API GrContext : public SkRefCnt { | 46 class SK_API GrContext : public SkRefCnt { |
50 public: | 47 public: |
51 /** | 48 /** |
52 * Creates a GrContext for a backend context. | 49 * Creates a GrContext for a backend context. |
53 */ | 50 */ |
54 static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions
& options); | 51 static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions
& options); |
55 static GrContext* Create(GrBackend, GrBackendContext); | 52 static GrContext* Create(GrBackend, GrBackendContext); |
56 | 53 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 GrLayerCache* getLayerCache() { return fLayerCache.get(); } | 323 GrLayerCache* getLayerCache() { return fLayerCache.get(); } |
327 GrTextBlobCache* getTextBlobCache() { return fTextBlobCache; } | 324 GrTextBlobCache* getTextBlobCache() { return fTextBlobCache; } |
328 bool abandoned() const; | 325 bool abandoned() const; |
329 GrResourceProvider* resourceProvider() { return fResourceProvider; } | 326 GrResourceProvider* resourceProvider() { return fResourceProvider; } |
330 const GrResourceProvider* resourceProvider() const { return fResourceProvide
r; } | 327 const GrResourceProvider* resourceProvider() const { return fResourceProvide
r; } |
331 GrResourceCache* getResourceCache() { return fResourceCache; } | 328 GrResourceCache* getResourceCache() { return fResourceCache; } |
332 | 329 |
333 // Called by tests that draw directly to the context via GrDrawTarget | 330 // Called by tests that draw directly to the context via GrDrawTarget |
334 void getTestTarget(GrTestTarget*); | 331 void getTestTarget(GrTestTarget*); |
335 | 332 |
336 GrPathRenderer* getPathRenderer( | |
337 const GrPipelineBuilder&, | |
338 const SkMatrix& viewMatrix, | |
339 const SkPath& path, | |
340 const GrStrokeInfo& stroke, | |
341 bool allowSW, | |
342 GrPathRendererChain::DrawType drawType = GrPathRendererChain
::kColor_DrawType, | |
343 GrPathRendererChain::StencilSupport* stencilSupport = NULL); | |
344 | |
345 /** Prints cache stats to the string if GR_CACHE_STATS == 1. */ | 333 /** Prints cache stats to the string if GR_CACHE_STATS == 1. */ |
346 void dumpCacheStats(SkString*) const; | 334 void dumpCacheStats(SkString*) const; |
347 void printCacheStats() const; | 335 void printCacheStats() const; |
348 | 336 |
349 /** Prints GPU stats to the string if GR_GPU_STATS == 1. */ | 337 /** Prints GPU stats to the string if GR_GPU_STATS == 1. */ |
350 void dumpGpuStats(SkString*) const; | 338 void dumpGpuStats(SkString*) const; |
351 void printGpuStats() const; | 339 void printGpuStats() const; |
352 | 340 |
353 /** Specify the TextBlob cache limit. If the current cache exceeds this limi
t it will purge. | 341 /** Specify the TextBlob cache limit. If the current cache exceeds this limi
t it will purge. |
354 this is for testing only */ | 342 this is for testing only */ |
(...skipping 14 matching lines...) Expand all Loading... |
369 // is in a private header. | 357 // is in a private header. |
370 union { | 358 union { |
371 GrResourceProvider* fResourceProvider; | 359 GrResourceProvider* fResourceProvider; |
372 GrTextureProvider* fTextureProvider; | 360 GrTextureProvider* fTextureProvider; |
373 }; | 361 }; |
374 | 362 |
375 GrBatchFontCache* fBatchFontCache; | 363 GrBatchFontCache* fBatchFontCache; |
376 SkAutoTDelete<GrLayerCache> fLayerCache; | 364 SkAutoTDelete<GrLayerCache> fLayerCache; |
377 SkAutoTDelete<GrTextBlobCache> fTextBlobCache; | 365 SkAutoTDelete<GrTextBlobCache> fTextBlobCache; |
378 | 366 |
379 GrPathRendererChain* fPathRendererChain; | |
380 GrSoftwarePathRenderer* fSoftwarePathRenderer; | |
381 | |
382 // Set by OverbudgetCB() to request that GrContext flush before exiting a dr
aw. | 367 // Set by OverbudgetCB() to request that GrContext flush before exiting a dr
aw. |
383 bool fFlushToReduceCacheSize; | 368 bool fFlushToReduceCacheSize; |
384 bool fDidTestPMConversions; | 369 bool fDidTestPMConversions; |
385 int fPMToUPMConversion; | 370 int fPMToUPMConversion; |
386 int fUPMToPMConversion; | 371 int fUPMToPMConversion; |
387 // The sw backend may call GrContext::readSurfacePixels on multiple threads | 372 // The sw backend may call GrContext::readSurfacePixels on multiple threads |
388 // We may transfer the responsibilty for using a mutex to the sw backend | 373 // We may transfer the responsibilty for using a mutex to the sw backend |
389 // when there are fewer code paths that lead to a readSurfacePixels call | 374 // when there are fewer code paths that lead to a readSurfacePixels call |
390 // from the sw backend. readSurfacePixels is reentrant in one case - when pe
rforming | 375 // from the sw backend. readSurfacePixels is reentrant in one case - when pe
rforming |
391 // the PM conversions test. To handle this we do the PM conversions test out
side | 376 // the PM conversions test. To handle this we do the PM conversions test out
side |
392 // of fReadPixelsMutex and use a separate mutex to guard it. When it re-ente
rs | 377 // of fReadPixelsMutex and use a separate mutex to guard it. When it re-ente
rs |
393 // readSurfacePixels it will grab fReadPixelsMutex and release it before the
outer | 378 // readSurfacePixels it will grab fReadPixelsMutex and release it before the
outer |
394 // readSurfacePixels proceeds to grab it. | 379 // readSurfacePixels proceeds to grab it. |
395 // TODO: Stop pretending to make GrContext thread-safe for sw rasterization
and provide | 380 // TODO: Stop pretending to make GrContext thread-safe for sw rasterization
and provide |
396 // a mechanism to make a SkPicture safe for multithreaded sw rasterization. | 381 // a mechanism to make a SkPicture safe for multithreaded sw rasterization. |
397 SkMutex fReadPixelsMutex; | 382 SkMutex fReadPixelsMutex; |
398 SkMutex fTestPMConversionsMutex; | 383 SkMutex fTestPMConversionsMutex; |
399 | 384 |
400 struct CleanUpData { | 385 struct CleanUpData { |
401 PFCleanUpFunc fFunc; | 386 PFCleanUpFunc fFunc; |
402 void* fInfo; | 387 void* fInfo; |
403 }; | 388 }; |
404 | 389 |
405 SkTDArray<CleanUpData> fCleanUpData; | 390 SkTDArray<CleanUpData> fCleanUpData; |
406 | 391 |
407 const uint32_t fUniqueID; | 392 const uint32_t fUniqueID; |
408 | 393 |
409 SkAutoTDelete<GrDrawingManager> fDrawingManager; | 394 SkAutoTDelete<GrDrawingManager> fDrawingManager; |
410 | 395 |
| 396 // TODO: have the CMM use drawContexts and rm this friending |
| 397 friend class GrClipMaskManager; // the CMM is friended just so it can call '
drawingManager' |
| 398 GrDrawingManager* drawingManager() { return fDrawingManager; } |
| 399 |
411 GrContext(); // init must be called after the constructor. | 400 GrContext(); // init must be called after the constructor. |
412 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); | 401 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); |
413 | 402 |
414 void initMockContext(); | 403 void initMockContext(); |
415 void initCommon(const GrContextOptions& options); | 404 void initCommon(const GrContextOptions& options); |
416 | 405 |
417 /** | 406 /** |
418 * These functions create premul <-> unpremul effects if it is possible to g
enerate a pair | 407 * These functions create premul <-> unpremul effects if it is possible to g
enerate a pair |
419 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O
therwise, they | 408 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O
therwise, they |
420 * return NULL. | 409 * return NULL. |
(...skipping 19 matching lines...) Expand all Loading... |
440 /** | 429 /** |
441 * A callback similar to the above for use by the TextBlobCache | 430 * A callback similar to the above for use by the TextBlobCache |
442 * TODO move textblob draw calls below context so we can use the call above. | 431 * TODO move textblob draw calls below context so we can use the call above. |
443 */ | 432 */ |
444 static void TextBlobCacheOverBudgetCB(void* data); | 433 static void TextBlobCacheOverBudgetCB(void* data); |
445 | 434 |
446 typedef SkRefCnt INHERITED; | 435 typedef SkRefCnt INHERITED; |
447 }; | 436 }; |
448 | 437 |
449 #endif | 438 #endif |
OLD | NEW |