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

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

Issue 2307053002: Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache. (Closed)
Patch Set: Fix uninit vars Created 4 years, 3 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 | src/gpu/GrContext.cpp » ('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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 sk_sp<SkColorSpace> colorSpace, 207 sk_sp<SkColorSpace> colorSpace,
208 int sampleCnt = 0, 208 int sampleCnt = 0,
209 GrSurfaceOrigin origin = kDefau lt_GrSurfaceOrigin, 209 GrSurfaceOrigin origin = kDefau lt_GrSurfaceOrigin,
210 const SkSurfaceProps* surfacePr ops = nullptr, 210 const SkSurfaceProps* surfacePr ops = nullptr,
211 SkBudgeted budgeted = SkBudgete d::kYes); 211 SkBudgeted budgeted = SkBudgete d::kYes);
212 212
213 /////////////////////////////////////////////////////////////////////////// 213 ///////////////////////////////////////////////////////////////////////////
214 // Misc. 214 // Misc.
215 215
216 /** 216 /**
217 * Flags that affect flush() behavior.
218 */
219 enum FlushBits {
220 /**
221 * A client may reach a point where it has partially rendered a frame
222 * through a GrContext that it knows the user will never see. This flag
223 * causes the flush to skip submission of deferred content to the 3D API
224 * during the flush.
225 */
226 kDiscard_FlushBit = 0x2,
227 };
228
229 /**
230 * Call to ensure all drawing to the context has been issued to the 217 * Call to ensure all drawing to the context has been issued to the
231 * underlying 3D API. 218 * underlying 3D API.
232 * @param flagsBitfield flags that control the flushing behavior. See
233 * FlushBits.
234 */ 219 */
235 void flush(int flagsBitfield = 0); 220 void flush();
236
237 void flushIfNecessary() {
238 if (fFlushToReduceCacheSize || this->caps()->immediateFlush()) {
239 this->flush();
240 }
241 }
242 221
243 /** 222 /**
244 * These flags can be used with the read/write pixels functions below. 223 * These flags can be used with the read/write pixels functions below.
245 */ 224 */
246 enum PixelOpsFlags { 225 enum PixelOpsFlags {
247 /** The GrContext will not be flushed before the surface read or write. This means that 226 /** The GrContext will not be flushed before the surface read or write. This means that
248 the read or write may occur before previous draws have executed. */ 227 the read or write may occur before previous draws have executed. */
249 kDontFlush_PixelOpsFlag = 0x1, 228 kDontFlush_PixelOpsFlag = 0x1,
250 /** Any surface writes should be flushed to the backend 3D API after the surface operation 229 /** Any surface writes should be flushed to the backend 3D API after the surface operation
251 is complete */ 230 is complete */
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 union { 381 union {
403 GrResourceProvider* fResourceProvider; 382 GrResourceProvider* fResourceProvider;
404 GrTextureProvider* fTextureProvider; 383 GrTextureProvider* fTextureProvider;
405 }; 384 };
406 385
407 SkAutoTUnref<GrContextThreadSafeProxy> fThreadSafeProxy; 386 SkAutoTUnref<GrContextThreadSafeProxy> fThreadSafeProxy;
408 387
409 GrBatchFontCache* fBatchFontCache; 388 GrBatchFontCache* fBatchFontCache;
410 SkAutoTDelete<GrTextBlobCache> fTextBlobCache; 389 SkAutoTDelete<GrTextBlobCache> fTextBlobCache;
411 390
412 // Set by OverbudgetCB() to request that GrContext flush before exiting a dr aw.
413 bool fFlushToReduceCacheSize;
414 bool fDidTestPMConversions; 391 bool fDidTestPMConversions;
415 int fPMToUPMConversion; 392 int fPMToUPMConversion;
416 int fUPMToPMConversion; 393 int fUPMToPMConversion;
417 // The sw backend may call GrContext::readSurfacePixels on multiple threads 394 // The sw backend may call GrContext::readSurfacePixels on multiple threads
418 // We may transfer the responsibilty for using a mutex to the sw backend 395 // We may transfer the responsibilty for using a mutex to the sw backend
419 // when there are fewer code paths that lead to a readSurfacePixels call 396 // when there are fewer code paths that lead to a readSurfacePixels call
420 // from the sw backend. readSurfacePixels is reentrant in one case - when pe rforming 397 // from the sw backend. readSurfacePixels is reentrant in one case - when pe rforming
421 // the PM conversions test. To handle this we do the PM conversions test out side 398 // the PM conversions test. To handle this we do the PM conversions test out side
422 // of fReadPixelsMutex and use a separate mutex to guard it. When it re-ente rs 399 // of fReadPixelsMutex and use a separate mutex to guard it. When it re-ente rs
423 // readSurfacePixels it will grab fReadPixelsMutex and release it before the outer 400 // readSurfacePixels it will grab fReadPixelsMutex and release it before the outer
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 const SkMatrix&) const; 442 const SkMatrix&) const;
466 /** Called before either of the above two functions to determine the appropr iate fragment 443 /** Called before either of the above two functions to determine the appropr iate fragment
467 processors for conversions. This must be called by readSurfacePixels bef ore a mutex is 444 processors for conversions. This must be called by readSurfacePixels bef ore a mutex is
468 taken, since testingvPM conversions itself will call readSurfacePixels * / 445 taken, since testingvPM conversions itself will call readSurfacePixels * /
469 void testPMConversionsIfNecessary(uint32_t flags); 446 void testPMConversionsIfNecessary(uint32_t flags);
470 /** Returns true if we've already determined that createPMtoUPMEffect and cr eateUPMToPMEffect 447 /** Returns true if we've already determined that createPMtoUPMEffect and cr eateUPMToPMEffect
471 will fail. In such cases fall back to SW conversion. */ 448 will fail. In such cases fall back to SW conversion. */
472 bool didFailPMUPMConversionTest() const; 449 bool didFailPMUPMConversionTest() const;
473 450
474 /** 451 /**
475 * This callback allows the resource cache to callback into the GrContext
476 * when the cache is still over budget after a purge.
477 */
478 static void OverBudgetCB(void* data);
479
480 /**
481 * A callback similar to the above for use by the TextBlobCache 452 * A callback similar to the above for use by the TextBlobCache
482 * 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.
483 */ 454 */
484 static void TextBlobCacheOverBudgetCB(void* data); 455 static void TextBlobCacheOverBudgetCB(void* data);
485 456
486 typedef SkRefCnt INHERITED; 457 typedef SkRefCnt INHERITED;
487 }; 458 };
488 459
489 /** 460 /**
490 * Can be used to perform actions related to the generating GrContext in a threa d safe manner. The 461 * Can be used to perform actions related to the generating GrContext in a threa d safe manner. The
491 * proxy does not access the 3D API (e.g. OpenGL) that backs the generating GrCo ntext. 462 * proxy does not access the 3D API (e.g. OpenGL) that backs the generating GrCo ntext.
492 */ 463 */
493 class GrContextThreadSafeProxy : public SkRefCnt { 464 class GrContextThreadSafeProxy : public SkRefCnt {
494 private: 465 private:
495 GrContextThreadSafeProxy(const GrCaps* caps, uint32_t uniqueID) 466 GrContextThreadSafeProxy(const GrCaps* caps, uint32_t uniqueID)
496 : fCaps(SkRef(caps)) 467 : fCaps(SkRef(caps))
497 , fContextUniqueID(uniqueID) {} 468 , fContextUniqueID(uniqueID) {}
498 469
499 SkAutoTUnref<const GrCaps> fCaps; 470 SkAutoTUnref<const GrCaps> fCaps;
500 uint32_t fContextUniqueID; 471 uint32_t fContextUniqueID;
501 472
502 friend class GrContext; 473 friend class GrContext;
503 friend class SkImage; 474 friend class SkImage;
504 475
505 typedef SkRefCnt INHERITED; 476 typedef SkRefCnt INHERITED;
506 }; 477 };
507 478
508 #endif 479 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698