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 |
(...skipping 25 matching lines...) Expand all Loading... | |
36 class GrResourceEntry; | 36 class GrResourceEntry; |
37 class GrResourceCache; | 37 class GrResourceCache; |
38 class GrResourceProvider; | 38 class GrResourceProvider; |
39 class GrTestTarget; | 39 class GrTestTarget; |
40 class GrTextBlobCache; | 40 class GrTextBlobCache; |
41 class GrTextContext; | 41 class GrTextContext; |
42 class GrTextureParams; | 42 class GrTextureParams; |
43 class GrVertexBuffer; | 43 class GrVertexBuffer; |
44 class GrStrokeInfo; | 44 class GrStrokeInfo; |
45 class GrSoftwarePathRenderer; | 45 class GrSoftwarePathRenderer; |
46 class SkGpuDevice; | |
47 | 46 |
48 class SK_API GrContext : public SkRefCnt { | 47 class SK_API GrContext : public SkRefCnt { |
49 public: | 48 public: |
50 SK_DECLARE_INST_COUNT(GrContext) | 49 SK_DECLARE_INST_COUNT(GrContext) |
51 | 50 |
52 /** | 51 /** |
53 * Creates a GrContext for a backend context. | 52 * Creates a GrContext for a backend context. |
54 */ | 53 */ |
55 static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions & options); | 54 static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions & options); |
56 static GrContext* Create(GrBackend, GrBackendContext); | 55 static GrContext* Create(GrBackend, GrBackendContext); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 * rendering quality for the display. Alternatively returns 0 if | 169 * rendering quality for the display. Alternatively returns 0 if |
171 * MSAA is not supported or recommended to be used by default. | 170 * MSAA is not supported or recommended to be used by default. |
172 */ | 171 */ |
173 int getRecommendedSampleCount(GrPixelConfig config, SkScalar dpi) const; | 172 int getRecommendedSampleCount(GrPixelConfig config, SkScalar dpi) const; |
174 | 173 |
175 /** | 174 /** |
176 * Returns a helper object to orchestrate draws. | 175 * Returns a helper object to orchestrate draws. |
177 * | 176 * |
178 * @return a draw context | 177 * @return a draw context |
179 */ | 178 */ |
180 GrDrawContext* drawContext() { | 179 GrDrawContext* drawContext(const SkDeviceProperties* devProps = NULL, bool u seDFT = false) { |
181 return fDrawingMgr.drawContext(); | 180 return fDrawingMgr.drawContext(devProps, useDFT); |
182 } | 181 } |
183 | 182 |
184 /////////////////////////////////////////////////////////////////////////// | 183 /////////////////////////////////////////////////////////////////////////// |
185 // Misc. | 184 // Misc. |
186 | 185 |
187 /** | 186 /** |
188 * Flags that affect flush() behavior. | 187 * Flags that affect flush() behavior. |
189 */ | 188 */ |
190 enum FlushBits { | 189 enum FlushBits { |
191 /** | 190 /** |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 | 388 |
390 GrContext(); // init must be called after the constructor. | 389 GrContext(); // init must be called after the constructor. |
391 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); | 390 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); |
392 | 391 |
393 // Currently the DrawingMgr just wraps the single GrDrawTarget in a single | 392 // Currently the DrawingMgr just wraps the single GrDrawTarget in a single |
394 // GrDrawContext and hands it out. In the future this class will allocate | 393 // GrDrawContext and hands it out. In the future this class will allocate |
395 // a new GrDrawContext for each GrRenderTarget/GrDrawTarget and manage | 394 // a new GrDrawContext for each GrRenderTarget/GrDrawTarget and manage |
396 // the DAG. | 395 // the DAG. |
397 class DrawingMgr { | 396 class DrawingMgr { |
398 public: | 397 public: |
399 DrawingMgr() | 398 DrawingMgr() : fDrawTarget(NULL) { |
400 : fDrawTarget(NULL) | 399 sk_bzero(fDrawContext, sizeof(fDrawContext)); |
401 , fDrawContext(NULL) { | |
402 } | 400 } |
403 | 401 |
404 ~DrawingMgr(); | 402 ~DrawingMgr(); |
405 | 403 |
406 void init(GrContext* context); | 404 void init(GrContext* context); |
407 | 405 |
408 void abandon(); | 406 void abandon(); |
409 bool abandoned() const { return NULL == fDrawTarget; } | 407 bool abandoned() const { return NULL == fDrawTarget; } |
410 | 408 |
411 void purgeResources(); | 409 void purgeResources(); |
412 void reset(); | 410 void reset(); |
413 void flush(); | 411 void flush(); |
414 | 412 |
415 // Callers should take a ref if they rely on the GrDrawContext sticking around. | 413 // Callers should take a ref if they rely on the GrDrawContext sticking around. |
416 // NULL will be returned if the context has been abandoned. | 414 // NULL will be returned if the context has been abandoned. |
417 GrDrawContext* drawContext(); | 415 GrDrawContext* drawContext(const SkDeviceProperties* devProps, bool useD FT); |
418 | 416 |
419 private: | 417 private: |
420 friend class GrContext; // for access to fDrawTarget for testing | 418 friend class GrContext; // for access to fDrawTarget for testing |
421 | 419 |
420 static const int kNumContextFlavors = 5; | |
jvanverth1
2015/06/09 19:22:38
It's not clear that these "flavors" are pixel geom
robertphillips
2015/06/09 19:26:20
I agree - should be fixed in PS #3.
| |
421 static const int kNumDFTOptions = 2; | |
422 | |
423 GrContext* fContext; | |
422 GrDrawTarget* fDrawTarget; | 424 GrDrawTarget* fDrawTarget; |
423 | 425 |
424 GrDrawContext* fDrawContext; | 426 GrDrawContext* fDrawContext[kNumContextFlavors][kNumDFTOptions]; |
425 }; | 427 }; |
426 | 428 |
427 DrawingMgr fDrawingMgr; | 429 DrawingMgr fDrawingMgr; |
428 | 430 |
429 void initMockContext(); | 431 void initMockContext(); |
430 void initCommon(); | 432 void initCommon(); |
431 | 433 |
432 /** | 434 /** |
433 * Creates a new text rendering context that is optimal for the | |
434 * render target and the context. Caller assumes the ownership | |
435 * of the returned object. The returned object must be deleted | |
436 * before the context is destroyed. | |
437 * TODO bury this behind context! | |
438 */ | |
439 GrTextContext* createTextContext(GrRenderTarget*, | |
440 const SkDeviceProperties&, | |
441 bool enableDistanceFieldFonts); | |
442 | |
443 | |
444 /** | |
445 * These functions create premul <-> unpremul effects if it is possible to g enerate a pair | 435 * These functions create premul <-> unpremul effects if it is possible to g enerate a pair |
446 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O therwise, they | 436 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O therwise, they |
447 * return NULL. | 437 * return NULL. |
448 */ | 438 */ |
449 const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB, c onst SkMatrix&); | 439 const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB, c onst SkMatrix&); |
450 const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, bool swapRAndB, c onst SkMatrix&); | 440 const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, bool swapRAndB, c onst SkMatrix&); |
451 | 441 |
452 /** | 442 /** |
453 * This callback allows the resource cache to callback into the GrContext | 443 * This callback allows the resource cache to callback into the GrContext |
454 * when the cache is still over budget after a purge. | 444 * when the cache is still over budget after a purge. |
455 */ | 445 */ |
456 static void OverBudgetCB(void* data); | 446 static void OverBudgetCB(void* data); |
457 | 447 |
458 /** | 448 /** |
459 * A callback similar to the above for use by the TextBlobCache | 449 * A callback similar to the above for use by the TextBlobCache |
460 * TODO move textblob draw calls below context so we can use the call above. | 450 * TODO move textblob draw calls below context so we can use the call above. |
461 */ | 451 */ |
462 static void TextBlobCacheOverBudgetCB(void* data); | 452 static void TextBlobCacheOverBudgetCB(void* data); |
463 | 453 |
464 // TODO see note on createTextContext | |
465 friend class SkGpuDevice; | |
466 | |
467 typedef SkRefCnt INHERITED; | 454 typedef SkRefCnt INHERITED; |
468 }; | 455 }; |
469 | 456 |
470 #endif | 457 #endif |
OLD | NEW |