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

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

Issue 2307053002: Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache. (Closed)
Patch Set: cleanup 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') | src/gpu/GrDrawingManager.h » ('J')
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 sk_sp<SkColorSpace> colorSpace, 191 sk_sp<SkColorSpace> colorSpace,
192 int sampleCnt = 0, 192 int sampleCnt = 0,
193 GrSurfaceOrigin origin = kDefault_GrSur faceOrigin, 193 GrSurfaceOrigin origin = kDefault_GrSur faceOrigin,
194 const SkSurfaceProps* surfaceProps = nu llptr, 194 const SkSurfaceProps* surfaceProps = nu llptr,
195 SkBudgeted = SkBudgeted::kYes); 195 SkBudgeted = SkBudgeted::kYes);
196 196
197 /////////////////////////////////////////////////////////////////////////// 197 ///////////////////////////////////////////////////////////////////////////
198 // Misc. 198 // Misc.
199 199
200 /** 200 /**
201 * Flags that affect flush() behavior.
202 */
203 enum FlushBits {
204 /**
205 * A client may reach a point where it has partially rendered a frame
206 * through a GrContext that it knows the user will never see. This flag
207 * causes the flush to skip submission of deferred content to the 3D API
208 * during the flush.
209 */
210 kDiscard_FlushBit = 0x2,
211 };
212
213 /**
214 * Call to ensure all drawing to the context has been issued to the 201 * Call to ensure all drawing to the context has been issued to the
215 * underlying 3D API. 202 * underlying 3D API.
216 * @param flagsBitfield flags that control the flushing behavior. See
217 * FlushBits.
218 */ 203 */
219 void flush(int flagsBitfield = 0); 204 void flush();
220
221 void flushIfNecessary() {
222 if (fFlushToReduceCacheSize || this->caps()->immediateFlush()) {
223 this->flush();
224 }
225 }
226 205
227 /** 206 /**
228 * These flags can be used with the read/write pixels functions below. 207 * These flags can be used with the read/write pixels functions below.
229 */ 208 */
230 enum PixelOpsFlags { 209 enum PixelOpsFlags {
231 /** The GrContext will not be flushed before the surface read or write. This means that 210 /** The GrContext will not be flushed before the surface read or write. This means that
232 the read or write may occur before previous draws have executed. */ 211 the read or write may occur before previous draws have executed. */
233 kDontFlush_PixelOpsFlag = 0x1, 212 kDontFlush_PixelOpsFlag = 0x1,
234 /** Any surface writes should be flushed to the backend 3D API after the surface operation 213 /** Any surface writes should be flushed to the backend 3D API after the surface operation
235 is complete */ 214 is complete */
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 union { 365 union {
387 GrResourceProvider* fResourceProvider; 366 GrResourceProvider* fResourceProvider;
388 GrTextureProvider* fTextureProvider; 367 GrTextureProvider* fTextureProvider;
389 }; 368 };
390 369
391 SkAutoTUnref<GrContextThreadSafeProxy> fThreadSafeProxy; 370 SkAutoTUnref<GrContextThreadSafeProxy> fThreadSafeProxy;
392 371
393 GrBatchFontCache* fBatchFontCache; 372 GrBatchFontCache* fBatchFontCache;
394 SkAutoTDelete<GrTextBlobCache> fTextBlobCache; 373 SkAutoTDelete<GrTextBlobCache> fTextBlobCache;
395 374
396 // Set by OverbudgetCB() to request that GrContext flush before exiting a dr aw. 375 // Set by OverbudgetCB() to request that GrContext flush before exiting a dr aw.
robertphillips 2016/09/02 16:23:06 Can we remove this too ?
397 bool fFlushToReduceCacheSize; 376 bool fFlushToReduceCacheSize;
398 bool fDidTestPMConversions; 377 bool fDidTestPMConversions;
399 int fPMToUPMConversion; 378 int fPMToUPMConversion;
400 int fUPMToPMConversion; 379 int fUPMToPMConversion;
401 // The sw backend may call GrContext::readSurfacePixels on multiple threads 380 // The sw backend may call GrContext::readSurfacePixels on multiple threads
402 // We may transfer the responsibilty for using a mutex to the sw backend 381 // We may transfer the responsibilty for using a mutex to the sw backend
403 // when there are fewer code paths that lead to a readSurfacePixels call 382 // when there are fewer code paths that lead to a readSurfacePixels call
404 // from the sw backend. readSurfacePixels is reentrant in one case - when pe rforming 383 // from the sw backend. readSurfacePixels is reentrant in one case - when pe rforming
405 // the PM conversions test. To handle this we do the PM conversions test out side 384 // the PM conversions test. To handle this we do the PM conversions test out side
406 // of fReadPixelsMutex and use a separate mutex to guard it. When it re-ente rs 385 // of fReadPixelsMutex and use a separate mutex to guard it. When it re-ente rs
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 const SkMatrix&) const; 428 const SkMatrix&) const;
450 /** Called before either of the above two functions to determine the appropr iate fragment 429 /** Called before either of the above two functions to determine the appropr iate fragment
451 processors for conversions. This must be called by readSurfacePixels bef ore a mutex is 430 processors for conversions. This must be called by readSurfacePixels bef ore a mutex is
452 taken, since testingvPM conversions itself will call readSurfacePixels * / 431 taken, since testingvPM conversions itself will call readSurfacePixels * /
453 void testPMConversionsIfNecessary(uint32_t flags); 432 void testPMConversionsIfNecessary(uint32_t flags);
454 /** Returns true if we've already determined that createPMtoUPMEffect and cr eateUPMToPMEffect 433 /** Returns true if we've already determined that createPMtoUPMEffect and cr eateUPMToPMEffect
455 will fail. In such cases fall back to SW conversion. */ 434 will fail. In such cases fall back to SW conversion. */
456 bool didFailPMUPMConversionTest() const; 435 bool didFailPMUPMConversionTest() const;
457 436
458 /** 437 /**
459 * This callback allows the resource cache to callback into the GrContext
460 * when the cache is still over budget after a purge.
461 */
462 static void OverBudgetCB(void* data);
463
464 /**
465 * A callback similar to the above for use by the TextBlobCache 438 * A callback similar to the above for use by the TextBlobCache
466 * TODO move textblob draw calls below context so we can use the call above. 439 * TODO move textblob draw calls below context so we can use the call above.
467 */ 440 */
468 static void TextBlobCacheOverBudgetCB(void* data); 441 static void TextBlobCacheOverBudgetCB(void* data);
469 442
470 typedef SkRefCnt INHERITED; 443 typedef SkRefCnt INHERITED;
471 }; 444 };
472 445
473 /** 446 /**
474 * Can be used to perform actions related to the generating GrContext in a threa d safe manner. The 447 * Can be used to perform actions related to the generating GrContext in a threa d safe manner. The
475 * proxy does not access the 3D API (e.g. OpenGL) that backs the generating GrCo ntext. 448 * proxy does not access the 3D API (e.g. OpenGL) that backs the generating GrCo ntext.
476 */ 449 */
477 class GrContextThreadSafeProxy : public SkRefCnt { 450 class GrContextThreadSafeProxy : public SkRefCnt {
478 private: 451 private:
479 GrContextThreadSafeProxy(const GrCaps* caps, uint32_t uniqueID) 452 GrContextThreadSafeProxy(const GrCaps* caps, uint32_t uniqueID)
480 : fCaps(SkRef(caps)) 453 : fCaps(SkRef(caps))
481 , fContextUniqueID(uniqueID) {} 454 , fContextUniqueID(uniqueID) {}
482 455
483 SkAutoTUnref<const GrCaps> fCaps; 456 SkAutoTUnref<const GrCaps> fCaps;
484 uint32_t fContextUniqueID; 457 uint32_t fContextUniqueID;
485 458
486 friend class GrContext; 459 friend class GrContext;
487 friend class SkImage; 460 friend class SkImage;
488 461
489 typedef SkRefCnt INHERITED; 462 typedef SkRefCnt INHERITED;
490 }; 463 };
491 464
492 #endif 465 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrContext.cpp » ('j') | src/gpu/GrDrawingManager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698