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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions
& options); | 53 static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions
& options); |
54 static GrContext* Create(GrBackend, GrBackendContext); | 54 static GrContext* Create(GrBackend, GrBackendContext); |
55 | 55 |
56 /** | 56 /** |
57 * Only defined in test apps. | 57 * Only defined in test apps. |
58 */ | 58 */ |
59 static GrContext* CreateMockContext(); | 59 static GrContext* CreateMockContext(); |
60 | 60 |
61 virtual ~GrContext(); | 61 virtual ~GrContext(); |
62 | 62 |
63 GrContextThreadSafeProxy* threadSafeProxy(); | 63 sk_sp<GrContextThreadSafeProxy> threadSafeProxy(); |
64 | 64 |
65 /** | 65 /** |
66 * The GrContext normally assumes that no outsider is setting state | 66 * The GrContext normally assumes that no outsider is setting state |
67 * within the underlying 3D API's context/device/whatever. This call informs | 67 * within the underlying 3D API's context/device/whatever. This call informs |
68 * the context that the state was modified and it should resend. Shouldn't | 68 * the context that the state was modified and it should resend. Shouldn't |
69 * be called frequently for good performance. | 69 * be called frequently for good performance. |
70 * The flag bits, state, is dpendent on which backend is used by the | 70 * The flag bits, state, is dpendent on which backend is used by the |
71 * context, either GL or D3D (possible in future). | 71 * context, either GL or D3D (possible in future). |
72 */ | 72 */ |
73 void resetContext(uint32_t state = kAll_GrBackendState); | 73 void resetContext(uint32_t state = kAll_GrBackendState); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 /** | 320 /** |
321 * An ID associated with this context, guaranteed to be unique. | 321 * An ID associated with this context, guaranteed to be unique. |
322 */ | 322 */ |
323 uint32_t uniqueID() { return fUniqueID; } | 323 uint32_t uniqueID() { return fUniqueID; } |
324 | 324 |
325 /////////////////////////////////////////////////////////////////////////// | 325 /////////////////////////////////////////////////////////////////////////// |
326 // Functions intended for internal use only. | 326 // Functions intended for internal use only. |
327 GrGpu* getGpu() { return fGpu; } | 327 GrGpu* getGpu() { return fGpu; } |
328 const GrGpu* getGpu() const { return fGpu; } | 328 const GrGpu* getGpu() const { return fGpu; } |
329 GrBatchFontCache* getBatchFontCache() { return fBatchFontCache; } | 329 GrBatchFontCache* getBatchFontCache() { return fBatchFontCache; } |
330 GrTextBlobCache* getTextBlobCache() { return fTextBlobCache; } | 330 GrTextBlobCache* getTextBlobCache() { return fTextBlobCache.get(); } |
331 bool abandoned() const; | 331 bool abandoned() const; |
332 GrResourceProvider* resourceProvider() { return fResourceProvider; } | 332 GrResourceProvider* resourceProvider() { return fResourceProvider; } |
333 const GrResourceProvider* resourceProvider() const { return fResourceProvide
r; } | 333 const GrResourceProvider* resourceProvider() const { return fResourceProvide
r; } |
334 GrResourceCache* getResourceCache() { return fResourceCache; } | 334 GrResourceCache* getResourceCache() { return fResourceCache; } |
335 | 335 |
336 // Called by tests that draw directly to the context via GrDrawContext | 336 // Called by tests that draw directly to the context via GrDrawContext |
337 void getTestTarget(GrTestTarget*, sk_sp<GrDrawContext>); | 337 void getTestTarget(GrTestTarget*, sk_sp<GrDrawContext>); |
338 | 338 |
339 /** Reset GPU stats */ | 339 /** Reset GPU stats */ |
340 void resetGpuStats() const ; | 340 void resetGpuStats() const ; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 GrGpu* fGpu; | 376 GrGpu* fGpu; |
377 const GrCaps* fCaps; | 377 const GrCaps* fCaps; |
378 GrResourceCache* fResourceCache; | 378 GrResourceCache* fResourceCache; |
379 // this union exists because the inheritance of GrTextureProvider->GrResourc
eProvider | 379 // this union exists because the inheritance of GrTextureProvider->GrResourc
eProvider |
380 // is in a private header. | 380 // is in a private header. |
381 union { | 381 union { |
382 GrResourceProvider* fResourceProvider; | 382 GrResourceProvider* fResourceProvider; |
383 GrTextureProvider* fTextureProvider; | 383 GrTextureProvider* fTextureProvider; |
384 }; | 384 }; |
385 | 385 |
386 SkAutoTUnref<GrContextThreadSafeProxy> fThreadSafeProxy; | 386 sk_sp<GrContextThreadSafeProxy> fThreadSafeProxy; |
387 | 387 |
388 GrBatchFontCache* fBatchFontCache; | 388 GrBatchFontCache* fBatchFontCache; |
389 SkAutoTDelete<GrTextBlobCache> fTextBlobCache; | 389 std::unique_ptr<GrTextBlobCache> fTextBlobCache; |
390 | 390 |
391 bool fDidTestPMConversions; | 391 bool fDidTestPMConversions; |
392 int fPMToUPMConversion; | 392 int fPMToUPMConversion; |
393 int fUPMToPMConversion; | 393 int fUPMToPMConversion; |
394 // The sw backend may call GrContext::readSurfacePixels on multiple threads | 394 // The sw backend may call GrContext::readSurfacePixels on multiple threads |
395 // 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 |
396 // 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 |
397 // 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 |
398 // 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 |
399 // 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 |
(...skipping 11 matching lines...) Expand all Loading... |
411 | 411 |
412 struct CleanUpData { | 412 struct CleanUpData { |
413 PFCleanUpFunc fFunc; | 413 PFCleanUpFunc fFunc; |
414 void* fInfo; | 414 void* fInfo; |
415 }; | 415 }; |
416 | 416 |
417 SkTDArray<CleanUpData> fCleanUpData; | 417 SkTDArray<CleanUpData> fCleanUpData; |
418 | 418 |
419 const uint32_t fUniqueID; | 419 const uint32_t fUniqueID; |
420 | 420 |
421 SkAutoTDelete<GrDrawingManager> fDrawingManager; | 421 std::unique_ptr<GrDrawingManager> fDrawingManager; |
422 | 422 |
423 GrAuditTrail fAuditTrail; | 423 GrAuditTrail fAuditTrail; |
424 | 424 |
425 // TODO: have the GrClipStackClip use drawContexts and rm this friending | 425 // TODO: have the GrClipStackClip use drawContexts and rm this friending |
426 friend class GrContextPriv; | 426 friend class GrContextPriv; |
427 | 427 |
428 GrContext(); // init must be called after the constructor. | 428 GrContext(); // init must be called after the constructor. |
429 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); | 429 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); |
430 | 430 |
431 void initMockContext(); | 431 void initMockContext(); |
(...skipping 24 matching lines...) Expand all Loading... |
456 | 456 |
457 typedef SkRefCnt INHERITED; | 457 typedef SkRefCnt INHERITED; |
458 }; | 458 }; |
459 | 459 |
460 /** | 460 /** |
461 * 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 |
462 * 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. |
463 */ | 463 */ |
464 class GrContextThreadSafeProxy : public SkRefCnt { | 464 class GrContextThreadSafeProxy : public SkRefCnt { |
465 private: | 465 private: |
466 GrContextThreadSafeProxy(const GrCaps* caps, uint32_t uniqueID) | 466 GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t uniqueID) |
467 : fCaps(SkRef(caps)) | 467 : fCaps(std::move(caps)) |
468 , fContextUniqueID(uniqueID) {} | 468 , fContextUniqueID(uniqueID) {} |
469 | 469 |
470 SkAutoTUnref<const GrCaps> fCaps; | 470 sk_sp<const GrCaps> fCaps; |
471 uint32_t fContextUniqueID; | 471 uint32_t fContextUniqueID; |
472 | 472 |
473 friend class GrContext; | 473 friend class GrContext; |
474 friend class SkImage; | 474 friend class SkImage; |
475 | 475 |
476 typedef SkRefCnt INHERITED; | 476 typedef SkRefCnt INHERITED; |
477 }; | 477 }; |
478 | 478 |
479 #endif | 479 #endif |
OLD | NEW |