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 | const GrBackendFormat& format, |
| 202 | SkBackingFit fit, |
| 203 | int width, |
| 204 | int height, |
| 205 | GrPixelConfig config, |
| 206 | GrColorType colorType, |
| 207 | sk_sp<SkColorSpace> colorSpace, |
| 208 | int sampleCnt, |
| 209 | GrMipMapped mipMapped, |
| 210 | GrSurfaceOrigin origin, |
| 211 | const SkSurfaceProps* surfaceProps, |
| 212 | SkBudgeted budgeted, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 213 | GrProtected isProtected) { |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 214 | SkASSERT(sampleCnt > 0); |
| 215 | if (this->abandoned()) { |
| 216 | return nullptr; |
| 217 | } |
| 218 | |
| 219 | GrSurfaceDesc desc; |
| 220 | desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 221 | desc.fWidth = width; |
| 222 | desc.fHeight = height; |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 223 | desc.fIsProtected = isProtected; |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 224 | desc.fConfig = config; |
| 225 | desc.fSampleCnt = sampleCnt; |
| 226 | |
| 227 | sk_sp<GrTextureProxy> rtp; |
| 228 | if (GrMipMapped::kNo == mipMapped) { |
| 229 | rtp = this->proxyProvider()->createProxy(format, desc, origin, fit, budgeted); |
| 230 | } else { |
| 231 | rtp = this->proxyProvider()->createMipMapProxy(format, desc, origin, budgeted); |
| 232 | } |
| 233 | if (!rtp) { |
| 234 | return nullptr; |
| 235 | } |
| 236 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 237 | auto drawingManager = this->drawingManager(); |
| 238 | |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 239 | sk_sp<GrRenderTargetContext> renderTargetContext = drawingManager->makeRenderTargetContext( |
| 240 | std::move(rtp), colorType, std::move(colorSpace), surfaceProps); |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 241 | if (!renderTargetContext) { |
| 242 | return nullptr; |
| 243 | } |
| 244 | |
| 245 | renderTargetContext->discard(); |
| 246 | |
| 247 | return renderTargetContext; |
| 248 | } |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 249 | |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 250 | static inline bool color_type_and_config_fallback(GrColorType* ct, GrPixelConfig* config) { |
| 251 | switch (*ct) { |
| 252 | case GrColorType::kAlpha_8: |
| 253 | if (*config != kAlpha_8_GrPixelConfig && *config != kAlpha_8_as_Red_GrPixelConfig && |
| 254 | *config != kAlpha_8_as_Alpha_GrPixelConfig) { |
| 255 | return false; |
| 256 | } |
| 257 | *config = kRGBA_8888_GrPixelConfig; |
| 258 | *ct = GrColorType::kRGBA_8888; |
| 259 | return true; |
| 260 | case GrColorType::kBGR_565: |
| 261 | if (*config != kRGB_565_GrPixelConfig) { |
| 262 | return false; |
| 263 | } |
| 264 | *config = kRGBA_8888_GrPixelConfig; |
| 265 | *ct = GrColorType::kRGBA_8888; |
| 266 | return true; |
| 267 | case GrColorType::kABGR_4444: |
| 268 | if (*config != kRGBA_4444_GrPixelConfig) { |
| 269 | return false; |
| 270 | } |
| 271 | *config = kRGBA_8888_GrPixelConfig; |
| 272 | *ct = GrColorType::kRGBA_8888; |
| 273 | return true; |
| 274 | case GrColorType::kBGRA_8888: |
| 275 | if (*config != kBGRA_8888_GrPixelConfig && *config != kSBGRA_8888_GrPixelConfig) { |
| 276 | return false; |
| 277 | } |
| 278 | *config = (*config == kSBGRA_8888_GrPixelConfig) ? kSRGBA_8888_GrPixelConfig |
| 279 | : kRGBA_8888_GrPixelConfig; |
| 280 | *ct = GrColorType::kRGBA_8888; |
| 281 | return true; |
| 282 | case GrColorType::kRGBA_1010102: |
| 283 | if (*config != kRGBA_1010102_GrPixelConfig) { |
| 284 | return false; |
| 285 | } |
| 286 | *config = kRGBA_8888_GrPixelConfig; |
| 287 | *ct = GrColorType::kRGBA_8888; |
| 288 | return true; |
| 289 | case GrColorType::kRGBA_F16: |
| 290 | if (*config != kRGBA_half_GrPixelConfig) { |
| 291 | return false; |
| 292 | } |
| 293 | *config = kRGBA_8888_GrPixelConfig; |
| 294 | *ct = GrColorType::kRGBA_8888; |
| 295 | return true; |
| 296 | case GrColorType::kRGBA_F16_Clamped: |
| 297 | if (*config != kRGBA_half_Clamped_GrPixelConfig) { |
| 298 | return false; |
| 299 | } |
| 300 | *config = kRGBA_8888_GrPixelConfig; |
| 301 | *ct = GrColorType::kRGBA_8888; |
| 302 | return true; |
| 303 | case GrColorType::kAlpha_F16: |
| 304 | if (*config != kAlpha_half_GrPixelConfig && |
| 305 | *config != kAlpha_half_as_Red_GrPixelConfig) { |
| 306 | return false; |
| 307 | } |
| 308 | *config = kRGBA_half_GrPixelConfig; |
| 309 | *ct = GrColorType::kRGBA_F16; |
| 310 | return true; |
| 311 | case GrColorType::kGray_8: |
| 312 | if (*config != kGray_8_GrPixelConfig && *config != kGray_8_as_Red_GrPixelConfig && |
| 313 | *config != kGray_8_as_Lum_GrPixelConfig) { |
| 314 | return false; |
| 315 | } |
| 316 | *config = kRGB_888_GrPixelConfig; |
| 317 | *ct = GrColorType::kRGB_888x; |
| 318 | return true; |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 319 | default: |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 320 | return false; |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | |
| 324 | sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContextWithFallback( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 325 | const GrBackendFormat& format, |
| 326 | SkBackingFit fit, |
| 327 | int width, |
| 328 | int height, |
| 329 | GrPixelConfig config, |
| 330 | GrColorType colorType, |
| 331 | sk_sp<SkColorSpace> colorSpace, |
| 332 | int sampleCnt, |
| 333 | GrMipMapped mipMapped, |
| 334 | GrSurfaceOrigin origin, |
| 335 | const SkSurfaceProps* surfaceProps, |
| 336 | SkBudgeted budgeted, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 337 | GrProtected isProtected) { |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 338 | GrBackendFormat localFormat = format; |
| 339 | SkASSERT(sampleCnt > 0); |
| 340 | if (0 == this->caps()->getRenderTargetSampleCount(sampleCnt, config)) { |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 341 | // TODO: Make the fallback part of GrCaps? |
| 342 | if (!color_type_and_config_fallback(&colorType, &config)) { |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 343 | return nullptr; |
| 344 | } |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 345 | // Figure out what the new backend format should be for the new color type. |
| 346 | auto srgb = GrPixelConfigIsSRGBEncoded(config); |
| 347 | localFormat = this->caps()->getBackendFormatFromGrColorType(colorType, srgb); |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 348 | } |
| 349 | |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 350 | return this->makeDeferredRenderTargetContext(localFormat, fit, width, height, config, colorType, |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 351 | std::move(colorSpace), sampleCnt, mipMapped, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 352 | origin, surfaceProps, budgeted, isProtected); |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 353 | } |
| 354 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 355 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 356 | sk_sp<const GrCaps> GrRecordingContextPriv::refCaps() const { |
| 357 | return fContext->refCaps(); |
| 358 | } |
| 359 | |
| 360 | sk_sp<GrSkSLFPFactoryCache> GrRecordingContextPriv::fpFactoryCache() { |
| 361 | return fContext->fpFactoryCache(); |
| 362 | } |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 363 | |
| 364 | sk_sp<GrOpMemoryPool> GrRecordingContextPriv::refOpMemoryPool() { |
| 365 | return fContext->refOpMemoryPool(); |
| 366 | } |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 367 | |
Robert Phillips | c5058a6 | 2019-02-15 12:52:59 -0500 | [diff] [blame] | 368 | void GrRecordingContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBObject) { |
| 369 | fContext->addOnFlushCallbackObject(onFlushCBObject); |
| 370 | } |
| 371 | |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 372 | sk_sp<GrSurfaceContext> GrRecordingContextPriv::makeWrappedSurfaceContext( |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 373 | sk_sp<GrSurfaceProxy> proxy, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 374 | GrColorType colorType, |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 375 | SkAlphaType alphaType, |
| 376 | sk_sp<SkColorSpace> colorSpace, |
| 377 | const SkSurfaceProps* props) { |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 378 | return fContext->makeWrappedSurfaceContext(std::move(proxy), colorType, alphaType, |
| 379 | std::move(colorSpace), props); |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | sk_sp<GrSurfaceContext> GrRecordingContextPriv::makeDeferredSurfaceContext( |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 383 | const GrBackendFormat& format, |
| 384 | const GrSurfaceDesc& dstDesc, |
| 385 | GrSurfaceOrigin origin, |
| 386 | GrMipMapped mipMapped, |
| 387 | SkBackingFit fit, |
| 388 | SkBudgeted isDstBudgeted, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 389 | GrColorType colorType, |
Brian Salomon | e7499c7 | 2019-06-24 12:12:36 -0400 | [diff] [blame] | 390 | SkAlphaType alphaType, |
| 391 | sk_sp<SkColorSpace> colorSpace, |
| 392 | const SkSurfaceProps* props) { |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 393 | return fContext->makeDeferredSurfaceContext(format, dstDesc, origin, mipMapped, fit, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 394 | isDstBudgeted, colorType, alphaType, |
| 395 | std::move(colorSpace), props); |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 396 | } |
| 397 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 398 | sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 399 | const GrBackendFormat& format, |
| 400 | SkBackingFit fit, |
| 401 | int width, |
| 402 | int height, |
| 403 | GrPixelConfig config, |
| 404 | GrColorType colorType, |
| 405 | sk_sp<SkColorSpace> colorSpace, |
| 406 | int sampleCnt, |
| 407 | GrMipMapped mipMapped, |
| 408 | GrSurfaceOrigin origin, |
| 409 | const SkSurfaceProps* surfaceProps, |
| 410 | SkBudgeted budgeted, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 411 | GrProtected isProtected) { |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 412 | return fContext->makeDeferredRenderTargetContext(format, fit, width, height, config, colorType, |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 413 | std::move(colorSpace), sampleCnt, mipMapped, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 414 | origin, surfaceProps, budgeted, isProtected); |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 415 | } |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 416 | |
| 417 | sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContextWithFallback( |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 418 | const GrBackendFormat& format, |
| 419 | SkBackingFit fit, |
| 420 | int width, |
| 421 | int height, |
| 422 | GrPixelConfig config, |
| 423 | GrColorType colorType, |
| 424 | sk_sp<SkColorSpace> colorSpace, |
| 425 | int sampleCnt, |
| 426 | GrMipMapped mipMapped, |
| 427 | GrSurfaceOrigin origin, |
| 428 | const SkSurfaceProps* surfaceProps, |
| 429 | SkBudgeted budgeted, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 430 | GrProtected isProtected) { |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame^] | 431 | return fContext->makeDeferredRenderTargetContextWithFallback(format, |
| 432 | fit, |
| 433 | width, |
| 434 | height, |
| 435 | config, |
| 436 | colorType, |
| 437 | std::move(colorSpace), |
| 438 | sampleCnt, |
| 439 | mipMapped, |
| 440 | origin, |
| 441 | surfaceProps, |
| 442 | budgeted, |
| 443 | isProtected); |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 444 | } |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 445 | |
| 446 | GrContext* GrRecordingContextPriv::backdoor() { |
| 447 | return (GrContext*) fContext; |
| 448 | } |