Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: include/gpu/GrContext.h

Issue 1406173003: Loosen requirement that there be only one GrDrawTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | include/gpu/GrDrawContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 * @return a draw context 181 * @return a draw context
182 */ 182 */
183 GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surface Props = NULL) { 183 GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surface Props = NULL) {
184 return fDrawingMgr.drawContext(rt, surfaceProps); 184 return fDrawingMgr.drawContext(rt, surfaceProps);
185 } 185 }
186 186
187 GrTextContext* textContext(const SkSurfaceProps& surfaceProps, GrRenderTarge t* rt) { 187 GrTextContext* textContext(const SkSurfaceProps& surfaceProps, GrRenderTarge t* rt) {
188 return fDrawingMgr.textContext(surfaceProps, rt); 188 return fDrawingMgr.textContext(surfaceProps, rt);
189 } 189 }
190 190
191 // The caller automatically gets a ref on the returned drawTarget. It must
192 // be balanced by an unref call.
193 GrDrawTarget* newDrawTarget(GrRenderTarget* rt) {
194 return fDrawingMgr.newDrawTarget(rt);
195 }
196
191 /////////////////////////////////////////////////////////////////////////// 197 ///////////////////////////////////////////////////////////////////////////
192 // Misc. 198 // Misc.
193 199
194 /** 200 /**
195 * Flags that affect flush() behavior. 201 * Flags that affect flush() behavior.
196 */ 202 */
197 enum FlushBits { 203 enum FlushBits {
198 /** 204 /**
199 * A client may reach a point where it has partially rendered a frame 205 * A client may reach a point where it has partially rendered a frame
200 * through a GrContext that it knows the user will never see. This flag 206 * through a GrContext that it knows the user will never see. This flag
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 // combination of text drawing options (pixel geometry x DFT use) 425 // combination of text drawing options (pixel geometry x DFT use)
420 // and hands the appropriate one back given the DrawContext's request. 426 // and hands the appropriate one back given the DrawContext's request.
421 // 427 //
422 // It allocates a new GrDrawContext for each GrRenderTarget 428 // It allocates a new GrDrawContext for each GrRenderTarget
423 // but all of them still land in the same GrDrawTarget! 429 // but all of them still land in the same GrDrawTarget!
424 // 430 //
425 // In the future this class will allocate a new GrDrawContext for 431 // In the future this class will allocate a new GrDrawContext for
426 // each GrRenderTarget/GrDrawTarget and manage the DAG. 432 // each GrRenderTarget/GrDrawTarget and manage the DAG.
427 class DrawingMgr { 433 class DrawingMgr {
428 public: 434 public:
429 DrawingMgr() : fDrawTarget(nullptr), fNVPRTextContext(nullptr) { 435 DrawingMgr()
436 : fContext(nullptr)
437 , fAbandoned(false)
438 , fNVPRTextContext(nullptr) {
430 sk_bzero(fTextContexts, sizeof(fTextContexts)); 439 sk_bzero(fTextContexts, sizeof(fTextContexts));
431 } 440 }
432 441
433 ~DrawingMgr(); 442 ~DrawingMgr();
434 443
435 void init(GrContext* context); 444 void init(GrContext* context);
436 445
437 void abandon(); 446 void abandon();
438 bool abandoned() const { return NULL == fDrawTarget; } 447 bool abandoned() const { return fAbandoned; }
439 448
440 void reset(); 449 void reset();
441 void flush(); 450 void flush();
442 451
443 // Callers assume the creation ref of the drawContext! 452 // Callers assume the creation ref of the drawContext!
444 // NULL will be returned if the context has been abandoned. 453 // NULL will be returned if the context has been abandoned.
445 GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* sur faceProps); 454 GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* sur faceProps);
446 455
447 GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt); 456 GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt);
457
458 GrDrawTarget* newDrawTarget(GrRenderTarget* rt);
448 459
449 private: 460 private:
450 void cleanup(); 461 void cleanup();
451 462
452 friend class GrContext; // for access to fDrawTarget for testing 463 friend class GrContext; // for access to fDrawTarget for testing
453 464
454 static const int kNumPixelGeometries = 5; // The different pixel geometr ies 465 static const int kNumPixelGeometries = 5; // The different pixel geometr ies
455 static const int kNumDFTOptions = 2; // DFT or no DFT 466 static const int kNumDFTOptions = 2; // DFT or no DFT
456 467
457 GrContext* fContext; 468 GrContext* fContext;
458 GrDrawTarget* fDrawTarget; 469
470 bool fAbandoned;
471 SkTDArray<GrDrawTarget*> fDrawTargets;
459 472
460 GrTextContext* fNVPRTextContext; 473 GrTextContext* fNVPRTextContext;
461 GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions]; 474 GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions];
462 }; 475 };
463 476
464 DrawingMgr fDrawingMgr; 477 DrawingMgr fDrawingMgr;
465 478
466 void initMockContext(); 479 void initMockContext();
467 void initCommon(); 480 void initCommon();
468 481
(...skipping 23 matching lines...) Expand all
492 /** 505 /**
493 * A callback similar to the above for use by the TextBlobCache 506 * A callback similar to the above for use by the TextBlobCache
494 * TODO move textblob draw calls below context so we can use the call above. 507 * TODO move textblob draw calls below context so we can use the call above.
495 */ 508 */
496 static void TextBlobCacheOverBudgetCB(void* data); 509 static void TextBlobCacheOverBudgetCB(void* data);
497 510
498 typedef SkRefCnt INHERITED; 511 typedef SkRefCnt INHERITED;
499 }; 512 };
500 513
501 #endif 514 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrDrawContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698