Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrRecordingContext.h" |
| 9 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 10 | #include "GrCaps.h" |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 11 | #include "GrMemoryPool.h" |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 12 | #include "GrRecordingContextPriv.h" |
| 13 | #include "GrSkSLFPFactoryCache.h" |
| 14 | |
Robert Phillips | c1541ae | 2019-02-04 12:05:37 -0500 | [diff] [blame] | 15 | GrRecordingContext::GrRecordingContext(GrBackendApi backend, |
| 16 | const GrContextOptions& options, |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 17 | uint32_t contextID) |
| 18 | : INHERITED(backend, options, contextID) { |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | GrRecordingContext::~GrRecordingContext() { } |
| 22 | |
Robert Phillips | a9162df | 2019-02-11 14:12:03 -0500 | [diff] [blame^] | 23 | void GrRecordingContext::abandonContext() { |
| 24 | INHERITED::abandonContext(); |
| 25 | } |
| 26 | |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 27 | sk_sp<GrOpMemoryPool> GrRecordingContext::refOpMemoryPool() { |
| 28 | if (!fOpMemoryPool) { |
| 29 | // DDL TODO: should the size of the memory pool be decreased in DDL mode? CPU-side memory |
| 30 | // consumed in DDL mode vs. normal mode for a single skp might be a good metric of wasted |
| 31 | // memory. |
| 32 | fOpMemoryPool = sk_sp<GrOpMemoryPool>(new GrOpMemoryPool(16384, 16384)); |
| 33 | } |
| 34 | |
| 35 | SkASSERT(fOpMemoryPool); |
| 36 | return fOpMemoryPool; |
| 37 | } |
| 38 | |
| 39 | GrOpMemoryPool* GrRecordingContext::opMemoryPool() { |
| 40 | return this->refOpMemoryPool().get(); |
| 41 | } |
| 42 | |
| 43 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 44 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 45 | sk_sp<const GrCaps> GrRecordingContextPriv::refCaps() const { |
| 46 | return fContext->refCaps(); |
| 47 | } |
| 48 | |
| 49 | sk_sp<GrSkSLFPFactoryCache> GrRecordingContextPriv::fpFactoryCache() { |
| 50 | return fContext->fpFactoryCache(); |
| 51 | } |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 52 | |
| 53 | sk_sp<GrOpMemoryPool> GrRecordingContextPriv::refOpMemoryPool() { |
| 54 | return fContext->refOpMemoryPool(); |
| 55 | } |