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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "include/private/GrRecordingContext.h" |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/gpu/GrContext.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 11 | #include "src/gpu/GrAuditTrail.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "src/gpu/GrCaps.h" |
| 13 | #include "src/gpu/GrDrawingManager.h" |
| 14 | #include "src/gpu/GrMemoryPool.h" |
| 15 | #include "src/gpu/GrProxyProvider.h" |
| 16 | #include "src/gpu/GrRecordingContextPriv.h" |
| 17 | #include "src/gpu/GrRenderTargetContext.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 18 | #include "src/gpu/GrSkSLFPFactoryCache.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 19 | #include "src/gpu/GrTextureContext.h" |
| 20 | #include "src/gpu/SkGr.h" |
| 21 | #include "src/gpu/text/GrTextBlobCache.h" |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 22 | |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 23 | #define ASSERT_SINGLE_OWNER_PRIV \ |
| 24 | SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());) |
| 25 | |
Robert Phillips | c1541ae | 2019-02-04 12:05:37 -0500 | [diff] [blame] | 26 | GrRecordingContext::GrRecordingContext(GrBackendApi backend, |
| 27 | const GrContextOptions& options, |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 28 | uint32_t contextID) |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 29 | : INHERITED(backend, options, contextID) |
| 30 | , fAuditTrail(new GrAuditTrail()) { |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | GrRecordingContext::~GrRecordingContext() { } |
| 34 | |
Robert Phillips | 2184fb7 | 2019-02-21 16:11:41 -0500 | [diff] [blame] | 35 | /** |
| 36 | * TODO: move textblob draw calls below context (see comment below) |
| 37 | */ |
| 38 | static void textblobcache_overbudget_CB(void* data) { |
| 39 | SkASSERT(data); |
| 40 | GrRecordingContext* context = reinterpret_cast<GrRecordingContext*>(data); |
| 41 | |
| 42 | GrContext* direct = context->priv().asDirectContext(); |
| 43 | if (!direct) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | // TextBlobs are drawn at the SkGpuDevice level, therefore they cannot rely on |
| 48 | // GrRenderTargetContext to perform a necessary flush. The solution is to move drawText calls |
| 49 | // to below the GrContext level, but this is not trivial because they call drawPath on |
| 50 | // SkGpuDevice. |
| 51 | direct->flush(); |
| 52 | } |
| 53 | |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 54 | bool GrRecordingContext::init(sk_sp<const GrCaps> caps, sk_sp<GrSkSLFPFactoryCache> cache) { |
| 55 | |
| 56 | if (!INHERITED::init(std::move(caps), std::move(cache))) { |
| 57 | return false; |
| 58 | } |
| 59 | |
Herb Derby | a00da61 | 2019-03-04 17:10:01 -0500 | [diff] [blame] | 60 | fStrikeCache.reset(new GrStrikeCache(this->caps(), |
Robert Phillips | 2184fb7 | 2019-02-21 16:11:41 -0500 | [diff] [blame] | 61 | this->options().fGlyphCacheTextureMaximumBytes)); |
| 62 | |
| 63 | fTextBlobCache.reset(new GrTextBlobCache(textblobcache_overbudget_CB, this, |
| 64 | this->contextID())); |
| 65 | |
Robert Phillips | 56181ba | 2019-03-08 12:00:45 -0500 | [diff] [blame] | 66 | return true; |
| 67 | } |
| 68 | |
Robert Phillips | 6db27c2 | 2019-05-01 10:43:56 -0400 | [diff] [blame] | 69 | void GrRecordingContext::setupDrawingManager(bool sortOpLists, bool reduceOpListSplitting) { |
Robert Phillips | 6989370 | 2019-02-22 11:16:30 -0500 | [diff] [blame] | 70 | GrPathRendererChain::Options prcOptions; |
| 71 | prcOptions.fAllowPathMaskCaching = this->options().fAllowPathMaskCaching; |
| 72 | #if GR_TEST_UTILS |
| 73 | prcOptions.fGpuPathRenderers = this->options().fGpuPathRenderers; |
| 74 | #endif |
Chris Dalton | f774818 | 2019-03-18 16:22:30 +0000 | [diff] [blame] | 75 | // FIXME: Once this is removed from Chrome and Android, rename to fEnable"". |
| 76 | if (!this->options().fDisableCoverageCountingPaths) { |
| 77 | prcOptions.fGpuPathRenderers |= GpuPathRenderers::kCoverageCounting; |
Robert Phillips | 6989370 | 2019-02-22 11:16:30 -0500 | [diff] [blame] | 78 | } |
| 79 | if (this->options().fDisableDistanceFieldPaths) { |
| 80 | prcOptions.fGpuPathRenderers &= ~GpuPathRenderers::kSmall; |
| 81 | } |
| 82 | |
| 83 | if (!this->proxyProvider()->renderingDirectly()) { |
| 84 | // DDL TODO: remove this crippling of the path renderer chain |
| 85 | // Disable the small path renderer bc of the proxies in the atlas. They need to be |
| 86 | // unified when the opLists are added back to the destination drawing manager. |
| 87 | prcOptions.fGpuPathRenderers &= ~GpuPathRenderers::kSmall; |
| 88 | } |
| 89 | |
| 90 | GrTextContext::Options textContextOptions; |
| 91 | textContextOptions.fMaxDistanceFieldFontSize = this->options().fGlyphsAsPathsFontSize; |
| 92 | textContextOptions.fMinDistanceFieldFontSize = this->options().fMinDistanceFieldFontSize; |
| 93 | textContextOptions.fDistanceFieldVerticesAlwaysHaveW = false; |
| 94 | #if SK_SUPPORT_ATLAS_TEXT |
| 95 | if (GrContextOptions::Enable::kYes == this->options().fDistanceFieldGlyphVerticesAlwaysHaveW) { |
| 96 | textContextOptions.fDistanceFieldVerticesAlwaysHaveW = true; |
| 97 | } |
| 98 | #endif |
| 99 | |
| 100 | fDrawingManager.reset(new GrDrawingManager(this, |
Robert Phillips | 12c4629 | 2019-04-23 07:36:17 -0400 | [diff] [blame] | 101 | prcOptions, |
| 102 | textContextOptions, |
| 103 | sortOpLists, |
Robert Phillips | 6db27c2 | 2019-05-01 10:43:56 -0400 | [diff] [blame] | 104 | reduceOpListSplitting)); |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 105 | } |
| 106 | |
Robert Phillips | a9162df | 2019-02-11 14:12:03 -0500 | [diff] [blame] | 107 | void GrRecordingContext::abandonContext() { |
| 108 | INHERITED::abandonContext(); |
Robert Phillips | 2184fb7 | 2019-02-21 16:11:41 -0500 | [diff] [blame] | 109 | |
Herb Derby | a00da61 | 2019-03-04 17:10:01 -0500 | [diff] [blame] | 110 | fStrikeCache->freeAll(); |
Robert Phillips | 2184fb7 | 2019-02-21 16:11:41 -0500 | [diff] [blame] | 111 | fTextBlobCache->freeAll(); |
Robert Phillips | a9162df | 2019-02-11 14:12:03 -0500 | [diff] [blame] | 112 | } |
| 113 | |
Robert Phillips | 6989370 | 2019-02-22 11:16:30 -0500 | [diff] [blame] | 114 | GrDrawingManager* GrRecordingContext::drawingManager() { |
| 115 | return fDrawingManager.get(); |
| 116 | } |
| 117 | |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 118 | sk_sp<GrOpMemoryPool> GrRecordingContext::refOpMemoryPool() { |
| 119 | if (!fOpMemoryPool) { |
| 120 | // DDL TODO: should the size of the memory pool be decreased in DDL mode? CPU-side memory |
| 121 | // consumed in DDL mode vs. normal mode for a single skp might be a good metric of wasted |
| 122 | // memory. |
| 123 | fOpMemoryPool = sk_sp<GrOpMemoryPool>(new GrOpMemoryPool(16384, 16384)); |
| 124 | } |
| 125 | |
| 126 | SkASSERT(fOpMemoryPool); |
| 127 | return fOpMemoryPool; |
| 128 | } |
| 129 | |
| 130 | GrOpMemoryPool* GrRecordingContext::opMemoryPool() { |
| 131 | return this->refOpMemoryPool().get(); |
| 132 | } |
| 133 | |
Robert Phillips | 2184fb7 | 2019-02-21 16:11:41 -0500 | [diff] [blame] | 134 | GrTextBlobCache* GrRecordingContext::getTextBlobCache() { |
| 135 | return fTextBlobCache.get(); |
| 136 | } |
| 137 | |
| 138 | const GrTextBlobCache* GrRecordingContext::getTextBlobCache() const { |
| 139 | return fTextBlobCache.get(); |
| 140 | } |
| 141 | |
Robert Phillips | c5058a6 | 2019-02-15 12:52:59 -0500 | [diff] [blame] | 142 | void GrRecordingContext::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBObject) { |
| 143 | this->drawingManager()->addOnFlushCallbackObject(onFlushCBObject); |
| 144 | } |
| 145 | |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 146 | sk_sp<GrSurfaceContext> GrRecordingContext::makeWrappedSurfaceContext( |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 147 | sk_sp<GrSurfaceProxy> proxy, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 148 | GrColorType colorType, |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 149 | SkAlphaType alphaType, |
| 150 | sk_sp<SkColorSpace> colorSpace, |
| 151 | const SkSurfaceProps* props) { |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 152 | ASSERT_SINGLE_OWNER_PRIV |
| 153 | |
| 154 | if (proxy->asRenderTargetProxy()) { |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 155 | SkASSERT(kPremul_SkAlphaType == alphaType || kOpaque_SkAlphaType == alphaType); |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 156 | return this->drawingManager()->makeRenderTargetContext(std::move(proxy), colorType, |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 157 | std::move(colorSpace), props); |
| 158 | } else { |
| 159 | SkASSERT(proxy->asTextureProxy()); |
| 160 | SkASSERT(!props); |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 161 | return this->drawingManager()->makeTextureContext(std::move(proxy), colorType, alphaType, |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 162 | std::move(colorSpace)); |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 163 | } |
| 164 | } |
| 165 | |
| 166 | sk_sp<GrSurfaceContext> GrRecordingContext::makeDeferredSurfaceContext( |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 167 | const GrBackendFormat& format, |
| 168 | const GrSurfaceDesc& dstDesc, |
| 169 | GrSurfaceOrigin origin, |
| 170 | GrMipMapped mipMapped, |
| 171 | SkBackingFit fit, |
| 172 | SkBudgeted isDstBudgeted, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 173 | GrColorType colorType, |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 174 | SkAlphaType alphaType, |
| 175 | sk_sp<SkColorSpace> colorSpace, |
| 176 | const SkSurfaceProps* props) { |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 177 | sk_sp<GrTextureProxy> proxy; |
| 178 | if (GrMipMapped::kNo == mipMapped) { |
| 179 | proxy = this->proxyProvider()->createProxy(format, dstDesc, origin, fit, isDstBudgeted); |
| 180 | } else { |
| 181 | SkASSERT(SkBackingFit::kExact == fit); |
| 182 | proxy = this->proxyProvider()->createMipMapProxy(format, dstDesc, origin, isDstBudgeted); |
| 183 | } |
| 184 | if (!proxy) { |
| 185 | return nullptr; |
| 186 | } |
| 187 | |
| 188 | sk_sp<GrSurfaceContext> sContext = this->makeWrappedSurfaceContext(std::move(proxy), |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 189 | colorType, |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 190 | alphaType, |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 191 | std::move(colorSpace), |
| 192 | props); |
| 193 | if (sContext && sContext->asRenderTargetContext()) { |
| 194 | sContext->asRenderTargetContext()->discard(); |
| 195 | } |
| 196 | |
| 197 | return sContext; |
| 198 | } |
| 199 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 200 | sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 201 | SkBackingFit fit, |
| 202 | int width, |
| 203 | int height, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 204 | GrColorType colorType, |
| 205 | sk_sp<SkColorSpace> colorSpace, |
| 206 | int sampleCnt, |
| 207 | GrMipMapped mipMapped, |
| 208 | GrSurfaceOrigin origin, |
| 209 | const SkSurfaceProps* surfaceProps, |
| 210 | SkBudgeted budgeted, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 211 | GrProtected isProtected) { |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 212 | SkASSERT(sampleCnt > 0); |
| 213 | if (this->abandoned()) { |
| 214 | return nullptr; |
| 215 | } |
| 216 | |
Brian Salomon | 27ae52c | 2019-07-03 11:27:44 -0400 | [diff] [blame^] | 217 | auto format = this->caps()->getBackendFormatFromGrColorType(colorType, GrSRGBEncoded::kNo); |
| 218 | if (!format.isValid()) { |
| 219 | return nullptr; |
| 220 | } |
| 221 | auto config = this->caps()->getConfigFromBackendFormat(format, colorType); |
| 222 | if (config == kUnknown_GrPixelConfig) { |
| 223 | return nullptr; |
| 224 | } |
| 225 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 226 | GrSurfaceDesc desc; |
| 227 | desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 228 | desc.fWidth = width; |
| 229 | desc.fHeight = height; |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 230 | desc.fIsProtected = isProtected; |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 231 | desc.fConfig = config; |
| 232 | desc.fSampleCnt = sampleCnt; |
| 233 | |
| 234 | sk_sp<GrTextureProxy> rtp; |
| 235 | if (GrMipMapped::kNo == mipMapped) { |
| 236 | rtp = this->proxyProvider()->createProxy(format, desc, origin, fit, budgeted); |
| 237 | } else { |
| 238 | rtp = this->proxyProvider()->createMipMapProxy(format, desc, origin, budgeted); |
| 239 | } |
| 240 | if (!rtp) { |
| 241 | return nullptr; |
| 242 | } |
| 243 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 244 | auto drawingManager = this->drawingManager(); |
| 245 | |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 246 | sk_sp<GrRenderTargetContext> renderTargetContext = drawingManager->makeRenderTargetContext( |
| 247 | std::move(rtp), colorType, std::move(colorSpace), surfaceProps); |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 248 | if (!renderTargetContext) { |
| 249 | return nullptr; |
| 250 | } |
| 251 | |
| 252 | renderTargetContext->discard(); |
| 253 | |
| 254 | return renderTargetContext; |
| 255 | } |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 256 | |
Brian Salomon | 27ae52c | 2019-07-03 11:27:44 -0400 | [diff] [blame^] | 257 | static inline GrColorType color_type_fallback(GrColorType ct) { |
| 258 | switch (ct) { |
| 259 | // kRGBA_8888 is our default fallback for many color types that may not have renderable |
| 260 | // backend formats. |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 261 | case GrColorType::kAlpha_8: |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 262 | case GrColorType::kBGR_565: |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 263 | case GrColorType::kABGR_4444: |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 264 | case GrColorType::kBGRA_8888: |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 265 | case GrColorType::kRGBA_1010102: |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 266 | case GrColorType::kRGBA_F16: |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 267 | case GrColorType::kRGBA_F16_Clamped: |
Brian Salomon | 27ae52c | 2019-07-03 11:27:44 -0400 | [diff] [blame^] | 268 | return GrColorType::kRGBA_8888; |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 269 | case GrColorType::kAlpha_F16: |
Brian Salomon | 27ae52c | 2019-07-03 11:27:44 -0400 | [diff] [blame^] | 270 | return GrColorType::kRGBA_F16; |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 271 | case GrColorType::kGray_8: |
Brian Salomon | 27ae52c | 2019-07-03 11:27:44 -0400 | [diff] [blame^] | 272 | return GrColorType::kRGB_888x; |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 273 | default: |
Brian Salomon | 27ae52c | 2019-07-03 11:27:44 -0400 | [diff] [blame^] | 274 | return GrColorType::kUnknown; |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 275 | } |
| 276 | } |
| 277 | |
| 278 | sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContextWithFallback( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 279 | SkBackingFit fit, |
| 280 | int width, |
| 281 | int height, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 282 | GrColorType colorType, |
| 283 | sk_sp<SkColorSpace> colorSpace, |
| 284 | int sampleCnt, |
| 285 | GrMipMapped mipMapped, |
| 286 | GrSurfaceOrigin origin, |
| 287 | const SkSurfaceProps* surfaceProps, |
| 288 | SkBudgeted budgeted, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 289 | GrProtected isProtected) { |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 290 | SkASSERT(sampleCnt > 0); |
Brian Salomon | 27ae52c | 2019-07-03 11:27:44 -0400 | [diff] [blame^] | 291 | sk_sp<GrRenderTargetContext> rtc; |
| 292 | do { |
| 293 | rtc = this->makeDeferredRenderTargetContext(fit, width, height, colorType, colorSpace, |
| 294 | sampleCnt, mipMapped, origin, surfaceProps, |
| 295 | budgeted, isProtected); |
| 296 | colorType = color_type_fallback(colorType); |
| 297 | } while (!rtc && colorType != GrColorType::kUnknown); |
| 298 | return rtc; |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 299 | } |
| 300 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 301 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 302 | sk_sp<const GrCaps> GrRecordingContextPriv::refCaps() const { |
| 303 | return fContext->refCaps(); |
| 304 | } |
| 305 | |
| 306 | sk_sp<GrSkSLFPFactoryCache> GrRecordingContextPriv::fpFactoryCache() { |
| 307 | return fContext->fpFactoryCache(); |
| 308 | } |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 309 | |
| 310 | sk_sp<GrOpMemoryPool> GrRecordingContextPriv::refOpMemoryPool() { |
| 311 | return fContext->refOpMemoryPool(); |
| 312 | } |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 313 | |
Robert Phillips | c5058a6 | 2019-02-15 12:52:59 -0500 | [diff] [blame] | 314 | void GrRecordingContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBObject) { |
| 315 | fContext->addOnFlushCallbackObject(onFlushCBObject); |
| 316 | } |
| 317 | |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 318 | sk_sp<GrSurfaceContext> GrRecordingContextPriv::makeWrappedSurfaceContext( |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 319 | sk_sp<GrSurfaceProxy> proxy, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 320 | GrColorType colorType, |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 321 | SkAlphaType alphaType, |
| 322 | sk_sp<SkColorSpace> colorSpace, |
| 323 | const SkSurfaceProps* props) { |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 324 | return fContext->makeWrappedSurfaceContext(std::move(proxy), colorType, alphaType, |
| 325 | std::move(colorSpace), props); |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | sk_sp<GrSurfaceContext> GrRecordingContextPriv::makeDeferredSurfaceContext( |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 329 | const GrBackendFormat& format, |
| 330 | const GrSurfaceDesc& dstDesc, |
| 331 | GrSurfaceOrigin origin, |
| 332 | GrMipMapped mipMapped, |
| 333 | SkBackingFit fit, |
| 334 | SkBudgeted isDstBudgeted, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 335 | GrColorType colorType, |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 336 | SkAlphaType alphaType, |
| 337 | sk_sp<SkColorSpace> colorSpace, |
| 338 | const SkSurfaceProps* props) { |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 339 | return fContext->makeDeferredSurfaceContext(format, dstDesc, origin, mipMapped, fit, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 340 | isDstBudgeted, colorType, alphaType, |
| 341 | std::move(colorSpace), props); |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 342 | } |
| 343 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 344 | sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 345 | SkBackingFit fit, |
| 346 | int width, |
| 347 | int height, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 348 | GrColorType colorType, |
| 349 | sk_sp<SkColorSpace> colorSpace, |
| 350 | int sampleCnt, |
| 351 | GrMipMapped mipMapped, |
| 352 | GrSurfaceOrigin origin, |
| 353 | const SkSurfaceProps* surfaceProps, |
| 354 | SkBudgeted budgeted, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 355 | GrProtected isProtected) { |
Brian Salomon | 27ae52c | 2019-07-03 11:27:44 -0400 | [diff] [blame^] | 356 | return fContext->makeDeferredRenderTargetContext(fit, width, height, colorType, |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 357 | std::move(colorSpace), sampleCnt, mipMapped, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 358 | origin, surfaceProps, budgeted, isProtected); |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 359 | } |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 360 | |
| 361 | sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContextWithFallback( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 362 | SkBackingFit fit, |
| 363 | int width, |
| 364 | int height, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 365 | GrColorType colorType, |
| 366 | sk_sp<SkColorSpace> colorSpace, |
| 367 | int sampleCnt, |
| 368 | GrMipMapped mipMapped, |
| 369 | GrSurfaceOrigin origin, |
| 370 | const SkSurfaceProps* surfaceProps, |
| 371 | SkBudgeted budgeted, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 372 | GrProtected isProtected) { |
Brian Salomon | 27ae52c | 2019-07-03 11:27:44 -0400 | [diff] [blame^] | 373 | return fContext->makeDeferredRenderTargetContextWithFallback(fit, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 374 | width, |
| 375 | height, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 376 | colorType, |
| 377 | std::move(colorSpace), |
| 378 | sampleCnt, |
| 379 | mipMapped, |
| 380 | origin, |
| 381 | surfaceProps, |
| 382 | budgeted, |
| 383 | isProtected); |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 384 | } |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 385 | |
| 386 | GrContext* GrRecordingContextPriv::backdoor() { |
| 387 | return (GrContext*) fContext; |
| 388 | } |