Chromium Code Reviews| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 * NULL will be returned if the context has been abandoned. | 176 * NULL will be returned if the context has been abandoned. |
| 177 * | 177 * |
| 178 * @param surfaceProps the surface properties (mainly defines text drawing) | 178 * @param surfaceProps the surface properties (mainly defines text drawing) |
| 179 * | 179 * |
| 180 * @return a draw context | 180 * @return a draw context |
| 181 */ | 181 */ |
| 182 GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps = NULL) { | 182 GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps = NULL) { |
| 183 return fDrawingMgr.drawContext(surfaceProps); | 183 return fDrawingMgr.drawContext(surfaceProps); |
| 184 } | 184 } |
| 185 | 185 |
| 186 GrTextContext* textContext(const SkSurfaceProps& surfaceProps, GrRenderTarge t* rt) { | |
|
bsalomon
2015/10/06 13:42:42
Should we be using the GrContext to get the text c
robertphillips
2015/10/06 13:50:58
draw contexts come and go now so the text contexts
| |
| 187 return fDrawingMgr.textContext(surfaceProps, rt); | |
| 188 } | |
| 189 | |
| 186 /////////////////////////////////////////////////////////////////////////// | 190 /////////////////////////////////////////////////////////////////////////// |
| 187 // Misc. | 191 // Misc. |
| 188 | 192 |
| 189 /** | 193 /** |
| 190 * Flags that affect flush() behavior. | 194 * Flags that affect flush() behavior. |
| 191 */ | 195 */ |
| 192 enum FlushBits { | 196 enum FlushBits { |
| 193 /** | 197 /** |
| 194 * A client may reach a point where it has partially rendered a frame | 198 * A client may reach a point where it has partially rendered a frame |
| 195 * through a GrContext that it knows the user will never see. This flag | 199 * through a GrContext that it knows the user will never see. This flag |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 void* fInfo; | 407 void* fInfo; |
| 404 }; | 408 }; |
| 405 | 409 |
| 406 SkTDArray<CleanUpData> fCleanUpData; | 410 SkTDArray<CleanUpData> fCleanUpData; |
| 407 | 411 |
| 408 const uint32_t fUniqueID; | 412 const uint32_t fUniqueID; |
| 409 | 413 |
| 410 GrContext(); // init must be called after the constructor. | 414 GrContext(); // init must be called after the constructor. |
| 411 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); | 415 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); |
| 412 | 416 |
| 413 // Currently the DrawingMgr stores a separate GrDrawContext for each | 417 // Currently the DrawingMgr creates a separate GrTextContext for each |
| 414 // combination of text drawing options (pixel geometry x DFT use) | 418 // combination of text drawing options (pixel geometry x DFT use) |
| 415 // and hands the appropriate one back given the user's request. | 419 // and hands the appropriate one back given the DrawContext's request. |
| 416 // All of the GrDrawContexts still land in the same GrDrawTarget! | 420 // |
| 421 // It allocates a new GrDrawContext for each GrRenderTarget | |
| 422 // but all of them still land in the same GrDrawTarget! | |
| 417 // | 423 // |
| 418 // In the future this class will allocate a new GrDrawContext for | 424 // In the future this class will allocate a new GrDrawContext for |
| 419 // each GrRenderTarget/GrDrawTarget and manage the DAG. | 425 // each GrRenderTarget/GrDrawTarget and manage the DAG. |
| 420 class DrawingMgr { | 426 class DrawingMgr { |
| 421 public: | 427 public: |
| 422 DrawingMgr() : fDrawTarget(NULL) { | 428 DrawingMgr() : fDrawTarget(nullptr), fNVPRTextContext(nullptr) { |
| 423 sk_bzero(fDrawContext, sizeof(fDrawContext)); | 429 sk_bzero(fTextContexts, sizeof(fTextContexts)); |
| 424 } | 430 } |
| 425 | 431 |
| 426 ~DrawingMgr(); | 432 ~DrawingMgr(); |
| 427 | 433 |
| 428 void init(GrContext* context); | 434 void init(GrContext* context); |
| 429 | 435 |
| 430 void abandon(); | 436 void abandon(); |
| 431 bool abandoned() const { return NULL == fDrawTarget; } | 437 bool abandoned() const { return NULL == fDrawTarget; } |
| 432 | 438 |
| 433 void reset(); | 439 void reset(); |
| 434 void flush(); | 440 void flush(); |
| 435 | 441 |
| 436 // Callers should take a ref if they rely on the GrDrawContext sticking around. | 442 // Callers assume the creation ref of the drawContext! |
| 437 // NULL will be returned if the context has been abandoned. | 443 // NULL will be returned if the context has been abandoned. |
| 438 GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps); | 444 GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps); |
| 439 | 445 |
| 446 GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt); | |
| 447 | |
| 440 private: | 448 private: |
| 441 void cleanup(); | 449 void cleanup(); |
| 442 | 450 |
| 443 friend class GrContext; // for access to fDrawTarget for testing | 451 friend class GrContext; // for access to fDrawTarget for testing |
| 444 | 452 |
| 445 static const int kNumPixelGeometries = 5; // The different pixel geometr ies | 453 static const int kNumPixelGeometries = 5; // The different pixel geometr ies |
| 446 static const int kNumDFTOptions = 2; // DFT or no DFT | 454 static const int kNumDFTOptions = 2; // DFT or no DFT |
| 447 | 455 |
| 448 GrContext* fContext; | 456 GrContext* fContext; |
| 449 GrDrawTarget* fDrawTarget; | 457 GrDrawTarget* fDrawTarget; |
| 450 | 458 |
| 451 GrDrawContext* fDrawContext[kNumPixelGeometries][kNumDFTOptions]; | 459 GrTextContext* fNVPRTextContext; |
| 460 GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions]; | |
| 452 }; | 461 }; |
| 453 | 462 |
| 454 DrawingMgr fDrawingMgr; | 463 DrawingMgr fDrawingMgr; |
| 455 | 464 |
| 456 void initMockContext(); | 465 void initMockContext(); |
| 457 void initCommon(); | 466 void initCommon(); |
| 458 | 467 |
| 459 /** | 468 /** |
| 460 * These functions create premul <-> unpremul effects if it is possible to g enerate a pair | 469 * These functions create premul <-> unpremul effects if it is possible to g enerate a pair |
| 461 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O therwise, they | 470 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O therwise, they |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 482 /** | 491 /** |
| 483 * A callback similar to the above for use by the TextBlobCache | 492 * A callback similar to the above for use by the TextBlobCache |
| 484 * TODO move textblob draw calls below context so we can use the call above. | 493 * TODO move textblob draw calls below context so we can use the call above. |
| 485 */ | 494 */ |
| 486 static void TextBlobCacheOverBudgetCB(void* data); | 495 static void TextBlobCacheOverBudgetCB(void* data); |
| 487 | 496 |
| 488 typedef SkRefCnt INHERITED; | 497 typedef SkRefCnt INHERITED; |
| 489 }; | 498 }; |
| 490 | 499 |
| 491 #endif | 500 #endif |
| OLD | NEW |