Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 "src/gpu/GrTextureContext.h" |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 9 | |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 10 | #include "src/gpu/GrAuditTrail.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/GrContextPriv.h" |
| 12 | #include "src/gpu/GrDrawingManager.h" |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 13 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 14 | #define ASSERT_SINGLE_OWNER \ |
Robert Phillips | a90aa2b | 2017-04-10 08:19:26 -0400 | [diff] [blame] | 15 | SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());) |
Robert Phillips | 7215283 | 2017-01-25 17:31:35 -0500 | [diff] [blame] | 16 | #define RETURN_FALSE_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) { return false; } |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 17 | |
Robert Phillips | 6989370 | 2019-02-22 11:16:30 -0500 | [diff] [blame] | 18 | GrTextureContext::GrTextureContext(GrRecordingContext* context, |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 19 | sk_sp<GrTextureProxy> textureProxy, |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 20 | GrColorType colorType, |
| 21 | SkAlphaType alphaType, |
Robert Phillips | 0d075de | 2019-03-04 11:08:13 -0500 | [diff] [blame] | 22 | sk_sp<SkColorSpace> colorSpace) |
Brian Salomon | bd3d8d3 | 2019-07-02 09:16:28 -0400 | [diff] [blame] | 23 | : GrSurfaceContext(context, colorType, alphaType, std::move(colorSpace)) |
Greg Daniel | 5abfff2 | 2019-08-22 10:35:14 -0400 | [diff] [blame] | 24 | , fTextureProxy(std::move(textureProxy)) { |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 25 | SkDEBUGCODE(this->validate();) |
| 26 | } |
| 27 | |
| 28 | #ifdef SK_DEBUG |
| 29 | void GrTextureContext::validate() const { |
| 30 | SkASSERT(fTextureProxy); |
| 31 | fTextureProxy->validate(fContext); |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 32 | } |
| 33 | #endif |
| 34 | |
| 35 | GrTextureContext::~GrTextureContext() { |
| 36 | ASSERT_SINGLE_OWNER |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 37 | } |
| 38 | |
Robert Phillips | f200a90 | 2017-01-30 13:27:37 -0500 | [diff] [blame] | 39 | GrRenderTargetProxy* GrTextureContext::asRenderTargetProxy() { |
| 40 | // If the proxy can return an RTProxy it should've been wrapped in a RTContext |
| 41 | SkASSERT(!fTextureProxy->asRenderTargetProxy()); |
| 42 | return nullptr; |
| 43 | } |
| 44 | |
| 45 | sk_sp<GrRenderTargetProxy> GrTextureContext::asRenderTargetProxyRef() { |
Robert Phillips | 2734136 | 2016-12-14 08:46:47 -0500 | [diff] [blame] | 46 | // If the proxy can return an RTProxy it should've been wrapped in a RTContext |
| 47 | SkASSERT(!fTextureProxy->asRenderTargetProxy()); |
| 48 | return nullptr; |
| 49 | } |