blob: c322ce531d301f664220644996bb6ea09a32d583 [file] [log] [blame]
Brian Salomoncfe910d2017-07-06 16:40:18 -04001/*
2 * Copyright 2017 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 Kleinc0bd9f92019-04-23 12:05:21 -05008#include "src/gpu/mock/GrMockBuffer.h"
9#include "src/gpu/mock/GrMockCaps.h"
Jim Van Verth99b1a8b2020-10-08 22:51:32 +000010#include "src/gpu/mock/GrMockGpu.h"
Greg Daniel2d41d0d2019-08-26 11:08:51 -040011#include "src/gpu/mock/GrMockOpsRenderPass.h"
Jim Van Verth99b1a8b2020-10-08 22:51:32 +000012#include "src/gpu/mock/GrMockStencilAttachment.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/gpu/mock/GrMockTexture.h"
Mike Kleinde2244c2018-12-04 11:16:08 -050014#include <atomic>
Brian Salomoncfe910d2017-07-06 16:40:18 -040015
Brian Salomon8fe24272017-07-07 12:56:11 -040016int GrMockGpu::NextInternalTextureID() {
Mike Kleinde2244c2018-12-04 11:16:08 -050017 static std::atomic<int> nextID{1};
Chris Dalton351e80c2019-01-06 22:51:00 -070018 int id;
19 do {
20 id = nextID.fetch_add(1);
21 } while (0 == id); // Reserve 0 for an invalid ID.
22 return id;
Brian Salomon8fe24272017-07-07 12:56:11 -040023}
24
25int GrMockGpu::NextExternalTextureID() {
26 // We use negative ints for the "testing only external textures" so they can easily be
27 // identified when debugging.
Mike Kleinde2244c2018-12-04 11:16:08 -050028 static std::atomic<int> nextID{-1};
29 return nextID--;
Brian Salomon8fe24272017-07-07 12:56:11 -040030}
31
Brian Salomon0c51eea2018-03-09 17:02:09 -050032int GrMockGpu::NextInternalRenderTargetID() {
Mike Kleinde2244c2018-12-04 11:16:08 -050033 // We start off with large numbers to differentiate from texture IDs, even though they're
Brian Salomon0c51eea2018-03-09 17:02:09 -050034 // technically in a different space.
Mike Kleinde2244c2018-12-04 11:16:08 -050035 static std::atomic<int> nextID{SK_MaxS32};
36 return nextID--;
Brian Salomon0c51eea2018-03-09 17:02:09 -050037}
38
39int GrMockGpu::NextExternalRenderTargetID() {
40 // We use large negative ints for the "testing only external render targets" so they can easily
41 // be identified when debugging.
Mike Kleinde2244c2018-12-04 11:16:08 -050042 static std::atomic<int> nextID{SK_MinS32};
43 return nextID++;
Brian Salomon0c51eea2018-03-09 17:02:09 -050044}
45
Brian Salomon384fab42017-12-07 12:33:05 -050046sk_sp<GrGpu> GrMockGpu::Make(const GrMockOptions* mockOptions,
Adlai Holler3d0359a2020-07-09 15:35:55 -040047 const GrContextOptions& contextOptions, GrDirectContext* direct) {
Greg Daniel02611d92017-07-25 10:05:01 -040048 static const GrMockOptions kDefaultOptions = GrMockOptions();
49 if (!mockOptions) {
50 mockOptions = &kDefaultOptions;
51 }
Adlai Holler3d0359a2020-07-09 15:35:55 -040052 return sk_sp<GrGpu>(new GrMockGpu(direct, *mockOptions, contextOptions));
Greg Daniel02611d92017-07-25 10:05:01 -040053}
54
Jim Van Verth99b1a8b2020-10-08 22:51:32 +000055GrOpsRenderPass* GrMockGpu::getOpsRenderPass(
56 GrRenderTarget* rt, GrStencilAttachment*,
57 GrSurfaceOrigin origin, const SkIRect& bounds,
58 const GrOpsRenderPass::LoadAndStoreInfo& colorInfo,
59 const GrOpsRenderPass::StencilLoadAndStoreInfo&,
60 const SkTArray<GrSurfaceProxy*, true>& sampledProxies,
61 GrXferBarrierFlags renderPassXferBarriers) {
Greg Daniel2d41d0d2019-08-26 11:08:51 -040062 return new GrMockOpsRenderPass(this, rt, origin, colorInfo);
Brian Salomoncfe910d2017-07-06 16:40:18 -040063}
64
Greg Daniel2d41d0d2019-08-26 11:08:51 -040065void GrMockGpu::submit(GrOpsRenderPass* renderPass) {
66 for (int i = 0; i < static_cast<GrMockOpsRenderPass*>(renderPass)->numDraws(); ++i) {
Brian Salomoncfe910d2017-07-06 16:40:18 -040067 fStats.incNumDraws();
68 }
Greg Daniel2d41d0d2019-08-26 11:08:51 -040069 delete renderPass;
Brian Salomoncfe910d2017-07-06 16:40:18 -040070}
71
Adlai Holler3d0359a2020-07-09 15:35:55 -040072GrMockGpu::GrMockGpu(GrDirectContext* direct, const GrMockOptions& options,
Brian Salomoncfe910d2017-07-06 16:40:18 -040073 const GrContextOptions& contextOptions)
Adlai Holler3d0359a2020-07-09 15:35:55 -040074 : INHERITED(direct)
Chris Dalton91ab1552018-04-18 13:24:25 -060075 , fMockOptions(options) {
Brian Salomoncfe910d2017-07-06 16:40:18 -040076 fCaps.reset(new GrMockCaps(contextOptions, options));
77}
78
Chris Daltonc3318f02019-07-19 14:20:53 -060079void GrMockGpu::querySampleLocations(GrRenderTarget* rt, SkTArray<SkPoint>* sampleLocations) {
80 sampleLocations->reset();
81 int numRemainingSamples = rt->numSamples();
82 while (numRemainingSamples > 0) {
83 // Use standard D3D sample locations.
84 switch (numRemainingSamples) {
85 case 0:
86 case 1:
87 sampleLocations->push_back().set(.5, .5);
88 break;
89 case 2:
90 sampleLocations->push_back().set(.75, .75);
91 sampleLocations->push_back().set(.25, .25);
92 break;
93 case 3:
94 case 4:
95 sampleLocations->push_back().set(.375, .125);
96 sampleLocations->push_back().set(.875, .375);
97 sampleLocations->push_back().set(.125, .625);
98 sampleLocations->push_back().set(.625, .875);
99 break;
100 case 5:
101 case 6:
102 case 7:
103 case 8:
104 sampleLocations->push_back().set(.5625, .3125);
105 sampleLocations->push_back().set(.4375, .6875);
106 sampleLocations->push_back().set(.8125, .5625);
107 sampleLocations->push_back().set(.3125, .1875);
108 sampleLocations->push_back().set(.1875, .8125);
109 sampleLocations->push_back().set(.0625, .4375);
110 sampleLocations->push_back().set(.6875, .4375);
111 sampleLocations->push_back().set(.4375, .0625);
112 break;
113 default:
114 sampleLocations->push_back().set(.5625, .5625);
115 sampleLocations->push_back().set(.4375, .3125);
116 sampleLocations->push_back().set(.3125, .6250);
117 sampleLocations->push_back().set(.2500, .4375);
118 sampleLocations->push_back().set(.1875, .3750);
119 sampleLocations->push_back().set(.6250, .8125);
120 sampleLocations->push_back().set(.8125, .6875);
121 sampleLocations->push_back().set(.6875, .1875);
122 sampleLocations->push_back().set(.3750, .8750);
123 sampleLocations->push_back().set(.5000, .0625);
124 sampleLocations->push_back().set(.2500, .1250);
125 sampleLocations->push_back().set(.1250, .2500);
126 sampleLocations->push_back().set(.0000, .5000);
127 sampleLocations->push_back().set(.4375, .2500);
128 sampleLocations->push_back().set(.8750, .4375);
129 sampleLocations->push_back().set(.0625, .0000);
130 break;
131 }
132 numRemainingSamples = rt->numSamples() - sampleLocations->count();
133 }
134}
135
Brian Salomona56a7462020-02-07 14:17:25 -0500136sk_sp<GrTexture> GrMockGpu::onCreateTexture(SkISize dimensions,
Brian Salomon81536f22019-08-08 16:30:49 -0400137 const GrBackendFormat& format,
138 GrRenderable renderable,
139 int renderTargetSampleCnt,
140 SkBudgeted budgeted,
141 GrProtected isProtected,
Brian Salomond2a8ae22019-09-10 16:03:59 -0400142 int mipLevelCount,
143 uint32_t levelClearMask) {
Chris Dalton91ab1552018-04-18 13:24:25 -0600144 if (fMockOptions.fFailTextureAllocations) {
145 return nullptr;
146 }
147
Robert Phillipsa27d6252019-12-10 14:48:36 -0500148 // Compressed formats should go through onCreateCompressedTexture
149 SkASSERT(format.asMockCompressionType() == SkImage::CompressionType::kNone);
150
Brian Salomon81536f22019-08-08 16:30:49 -0400151 GrColorType ct = format.asMockColorType();
152 SkASSERT(ct != GrColorType::kUnknown);
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400153
Brian Salomona6db5102020-07-21 09:56:23 -0400154 GrMipmapStatus mipmapStatus =
155 mipLevelCount > 1 ? GrMipmapStatus::kDirty : GrMipmapStatus::kNotAllocated;
Robert Phillipsa27d6252019-12-10 14:48:36 -0500156 GrMockTextureInfo texInfo(ct, SkImage::CompressionType::kNone, NextInternalTextureID());
Brian Salomonf2c2ba92019-07-17 09:59:59 -0400157 if (renderable == GrRenderable::kYes) {
Greg Daniele877dce2019-07-11 10:52:43 -0400158 GrMockRenderTargetInfo rtInfo(ct, NextInternalRenderTargetID());
Brian Salomona56a7462020-02-07 14:17:25 -0500159 return sk_sp<GrTexture>(new GrMockTextureRenderTarget(this, budgeted, dimensions,
Brian Salomon27b4d8d2019-07-22 14:23:45 -0400160 renderTargetSampleCnt, isProtected,
Brian Salomona6db5102020-07-21 09:56:23 -0400161 mipmapStatus, texInfo, rtInfo));
Brian Salomoncfe910d2017-07-06 16:40:18 -0400162 }
Brian Salomone8a766b2019-07-19 14:24:36 -0400163 return sk_sp<GrTexture>(
Brian Salomona6db5102020-07-21 09:56:23 -0400164 new GrMockTexture(this, budgeted, dimensions, isProtected, mipmapStatus, texInfo));
Brian Salomoncfe910d2017-07-06 16:40:18 -0400165}
166
Robert Phillipsa27d6252019-12-10 14:48:36 -0500167// TODO: why no 'isProtected' ?!
Robert Phillips9f744f72019-12-19 19:14:33 -0500168sk_sp<GrTexture> GrMockGpu::onCreateCompressedTexture(SkISize dimensions,
Robert Phillipsa27d6252019-12-10 14:48:36 -0500169 const GrBackendFormat& format,
Robert Phillips3a833922020-01-21 15:25:58 -0500170 SkBudgeted budgeted,
Brian Salomon7e67dca2020-07-21 09:27:25 -0400171 GrMipmapped mipMapped,
Robert Phillips3a833922020-01-21 15:25:58 -0500172 GrProtected isProtected,
Robert Phillips9f744f72019-12-19 19:14:33 -0500173 const void* data, size_t dataSize) {
Robert Phillipsa27d6252019-12-10 14:48:36 -0500174 if (fMockOptions.fFailTextureAllocations) {
175 return nullptr;
176 }
177
Greg Danielb58a3c72020-01-23 10:05:14 -0500178#ifdef SK_DEBUG
Robert Phillipsa27d6252019-12-10 14:48:36 -0500179 // Uncompressed formats should go through onCreateTexture
180 SkImage::CompressionType compression = format.asMockCompressionType();
181 SkASSERT(compression != SkImage::CompressionType::kNone);
Greg Danielb58a3c72020-01-23 10:05:14 -0500182#endif
Robert Phillipsa27d6252019-12-10 14:48:36 -0500183
Brian Salomona6db5102020-07-21 09:56:23 -0400184 GrMipmapStatus mipmapStatus = (mipMapped == GrMipmapped::kYes)
185 ? GrMipmapStatus::kValid
186 : GrMipmapStatus::kNotAllocated;
Robert Phillipsa27d6252019-12-10 14:48:36 -0500187 GrMockTextureInfo texInfo(GrColorType::kUnknown,
188 format.asMockCompressionType(),
189 NextInternalTextureID());
190
Brian Salomona56a7462020-02-07 14:17:25 -0500191 return sk_sp<GrTexture>(
Brian Salomona6db5102020-07-21 09:56:23 -0400192 new GrMockTexture(this, budgeted, dimensions, isProtected, mipmapStatus, texInfo));
Brian Salomonbb8dde82019-06-27 10:52:13 -0400193}
194
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400195sk_sp<GrTexture> GrMockGpu::onWrapBackendTexture(const GrBackendTexture& tex,
Brian Salomonfa2ebea2019-01-24 15:58:58 -0500196 GrWrapOwnership ownership,
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400197 GrWrapCacheable wrapType,
198 GrIOType ioType) {
Robert Phillipsc80b0e92019-07-23 10:27:09 -0400199 GrMockTextureInfo texInfo;
200 SkAssertResult(tex.getMockTextureInfo(&texInfo));
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400201
Robert Phillipsa27d6252019-12-10 14:48:36 -0500202 SkImage::CompressionType compression = texInfo.compressionType();
Robert Phillipsb915c942019-12-17 14:44:37 -0500203 if (compression != SkImage::CompressionType::kNone) {
204 return nullptr;
Robert Phillipsa27d6252019-12-10 14:48:36 -0500205 }
206
Brian Salomon40a40622020-07-21 10:32:07 -0400207 GrMipmapStatus mipmapStatus = tex.hasMipmaps() ? GrMipmapStatus::kValid
Brian Salomona6db5102020-07-21 09:56:23 -0400208 : GrMipmapStatus::kNotAllocated;
Brian Salomone8a766b2019-07-19 14:24:36 -0400209 auto isProtected = GrProtected(tex.isProtected());
Brian Salomona6db5102020-07-21 09:56:23 -0400210 return sk_sp<GrTexture>(new GrMockTexture(this, tex.dimensions(), isProtected, mipmapStatus,
Brian Salomona56a7462020-02-07 14:17:25 -0500211 texInfo, wrapType, ioType));
Greg Daniel4684f822018-03-08 15:27:36 -0500212}
213
Robert Phillipsb915c942019-12-17 14:44:37 -0500214sk_sp<GrTexture> GrMockGpu::onWrapCompressedBackendTexture(const GrBackendTexture& tex,
215 GrWrapOwnership ownership,
216 GrWrapCacheable wrapType) {
217 return nullptr;
218}
219
Brian Salomon0c51eea2018-03-09 17:02:09 -0500220sk_sp<GrTexture> GrMockGpu::onWrapRenderableBackendTexture(const GrBackendTexture& tex,
221 int sampleCnt,
Brian Salomonaa6ca0a2019-01-24 16:03:07 -0500222 GrWrapOwnership ownership,
223 GrWrapCacheable cacheable) {
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400224 GrMockTextureInfo texInfo;
225 SkAssertResult(tex.getMockTextureInfo(&texInfo));
Robert Phillipsa27d6252019-12-10 14:48:36 -0500226 SkASSERT(texInfo.compressionType() == SkImage::CompressionType::kNone);
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400227
Brian Salomona6db5102020-07-21 09:56:23 -0400228 GrMipmapStatus mipmapStatus =
Brian Salomon40a40622020-07-21 10:32:07 -0400229 tex.hasMipmaps() ? GrMipmapStatus::kValid : GrMipmapStatus::kNotAllocated;
Brian Salomon0c51eea2018-03-09 17:02:09 -0500230
Brian Salomon0c51eea2018-03-09 17:02:09 -0500231 // The client gave us the texture ID but we supply the render target ID.
Robert Phillipsa27d6252019-12-10 14:48:36 -0500232 GrMockRenderTargetInfo rtInfo(texInfo.colorType(), NextInternalRenderTargetID());
Brian Salomon0c51eea2018-03-09 17:02:09 -0500233
Brian Salomone8a766b2019-07-19 14:24:36 -0400234 auto isProtected = GrProtected(tex.isProtected());
Brian Salomona56a7462020-02-07 14:17:25 -0500235 return sk_sp<GrTexture>(new GrMockTextureRenderTarget(this, tex.dimensions(), sampleCnt,
Brian Salomona6db5102020-07-21 09:56:23 -0400236 isProtected, mipmapStatus, texInfo,
Brian Salomona56a7462020-02-07 14:17:25 -0500237 rtInfo, cacheable));
Brian Salomon0c51eea2018-03-09 17:02:09 -0500238}
239
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400240sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt) {
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400241 GrMockRenderTargetInfo info;
242 SkAssertResult(rt.getMockRenderTargetInfo(&info));
243
Brian Salomone8a766b2019-07-19 14:24:36 -0400244 auto isProtected = GrProtected(rt.isProtected());
Brian Salomona56a7462020-02-07 14:17:25 -0500245 return sk_sp<GrRenderTarget>(new GrMockRenderTarget(this, GrMockRenderTarget::kWrapped,
246 rt.dimensions(), rt.sampleCnt(),
247 isProtected, info));
Brian Salomon0c51eea2018-03-09 17:02:09 -0500248}
249
250sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400251 int sampleCnt) {
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400252 GrMockTextureInfo texInfo;
253 SkAssertResult(tex.getMockTextureInfo(&texInfo));
Robert Phillipsa27d6252019-12-10 14:48:36 -0500254 SkASSERT(texInfo.compressionType() == SkImage::CompressionType::kNone);
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400255
Brian Salomon0c51eea2018-03-09 17:02:09 -0500256 // The client gave us the texture ID but we supply the render target ID.
Robert Phillipsa27d6252019-12-10 14:48:36 -0500257 GrMockRenderTargetInfo rtInfo(texInfo.colorType(), NextInternalRenderTargetID());
Brian Salomon0c51eea2018-03-09 17:02:09 -0500258
Brian Salomone8a766b2019-07-19 14:24:36 -0400259 auto isProtected = GrProtected(tex.isProtected());
Brian Salomona56a7462020-02-07 14:17:25 -0500260 return sk_sp<GrRenderTarget>(new GrMockRenderTarget(
261 this, GrMockRenderTarget::kWrapped, tex.dimensions(), sampleCnt, isProtected, rtInfo));
Brian Salomon0c51eea2018-03-09 17:02:09 -0500262}
263
Brian Salomondbf70722019-02-07 11:31:24 -0500264sk_sp<GrGpuBuffer> GrMockGpu::onCreateBuffer(size_t sizeInBytes, GrGpuBufferType type,
265 GrAccessPattern accessPattern, const void*) {
266 return sk_sp<GrGpuBuffer>(new GrMockBuffer(this, sizeInBytes, type, accessPattern));
Brian Salomoncfe910d2017-07-06 16:40:18 -0400267}
268
Jim Van Verth99b1a8b2020-10-08 22:51:32 +0000269GrStencilAttachment* GrMockGpu::createStencilAttachmentForRenderTarget(
270 const GrRenderTarget* rt, SkISize dimensions, int numStencilSamples) {
Chris Daltoneffee202019-07-01 22:28:03 -0600271 SkASSERT(numStencilSamples == rt->numSamples());
Brian Salomoncfe910d2017-07-06 16:40:18 -0400272 fStats.incStencilAttachmentCreates();
Jim Van Verth99b1a8b2020-10-08 22:51:32 +0000273 return new GrMockStencilAttachment(this, dimensions, rt->numSamples());
Brian Salomoncfe910d2017-07-06 16:40:18 -0400274}
Brian Salomon8fe24272017-07-07 12:56:11 -0400275
Brian Salomon85c3d682019-11-04 15:04:54 -0500276GrBackendTexture GrMockGpu::onCreateBackendTexture(SkISize dimensions,
Robert Phillips57ef6802019-09-23 10:12:47 -0400277 const GrBackendFormat& format,
Brian Salomon85c3d682019-11-04 15:04:54 -0500278 GrRenderable,
Brian Salomon7e67dca2020-07-21 09:27:25 -0400279 GrMipmapped mipMapped,
Greg Daniel16032b32020-05-06 15:31:10 -0400280 GrProtected) {
Robert Phillipsa27d6252019-12-10 14:48:36 -0500281 SkImage::CompressionType compression = format.asMockCompressionType();
282 if (compression != SkImage::CompressionType::kNone) {
283 return {}; // should go through onCreateCompressedBackendTexture
284 }
285
Brian Salomond4764a12019-08-08 12:08:24 -0400286 auto colorType = format.asMockColorType();
Greg Daniel7bfc9132019-08-14 14:23:53 -0400287 if (!this->caps()->isFormatTexturable(format)) {
Robert Phillips9dbcdcc2019-05-13 10:40:06 -0400288 return GrBackendTexture(); // invalid
289 }
290
Robert Phillipsa27d6252019-12-10 14:48:36 -0500291 GrMockTextureInfo info(colorType, SkImage::CompressionType::kNone, NextExternalTextureID());
Robert Phillips646f6372018-09-25 09:31:10 -0400292
Robert Phillipsa27d6252019-12-10 14:48:36 -0500293 fOutstandingTestingOnlyTextureIDs.add(info.id());
Brian Salomon85c3d682019-11-04 15:04:54 -0500294 return GrBackendTexture(dimensions.width(), dimensions.height(), mipMapped, info);
Robert Phillipsd21b2a52017-12-12 13:01:25 -0500295}
296
Greg Danielc1ad77c2020-05-06 11:40:03 -0400297GrBackendTexture GrMockGpu::onCreateCompressedBackendTexture(
Brian Salomon7e67dca2020-07-21 09:27:25 -0400298 SkISize dimensions, const GrBackendFormat& format, GrMipmapped mipMapped,
Greg Danielaaf738c2020-07-10 09:30:33 -0400299 GrProtected) {
Robert Phillipsb915c942019-12-17 14:44:37 -0500300 SkImage::CompressionType compression = format.asMockCompressionType();
301 if (compression == SkImage::CompressionType::kNone) {
302 return {}; // should go through onCreateBackendTexture
303 }
304
305 if (!this->caps()->isFormatTexturable(format)) {
306 return {};
307 }
308
309 GrMockTextureInfo info(GrColorType::kUnknown, compression, NextExternalTextureID());
310
311 fOutstandingTestingOnlyTextureIDs.add(info.id());
312 return GrBackendTexture(dimensions.width(), dimensions.height(), mipMapped, info);
313}
314
Robert Phillipsf0313ee2019-05-21 13:51:11 -0400315void GrMockGpu::deleteBackendTexture(const GrBackendTexture& tex) {
Robert Phillipsf0ced622019-05-16 09:06:25 -0400316 SkASSERT(GrBackendApi::kMock == tex.backend());
317
318 GrMockTextureInfo info;
319 if (tex.getMockTextureInfo(&info)) {
Robert Phillipsa27d6252019-12-10 14:48:36 -0500320 fOutstandingTestingOnlyTextureIDs.remove(info.id());
Robert Phillipsf0ced622019-05-16 09:06:25 -0400321 }
322}
323
324#if GR_TEST_UTILS
Robert Phillipsd21b2a52017-12-12 13:01:25 -0500325bool GrMockGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
Greg Danielbdf12ad2018-10-12 09:31:11 -0400326 SkASSERT(GrBackendApi::kMock == tex.backend());
Robert Phillipsd21b2a52017-12-12 13:01:25 -0500327
Greg Daniel52e16d92018-04-10 09:34:07 -0400328 GrMockTextureInfo info;
329 if (!tex.getMockTextureInfo(&info)) {
Robert Phillipsd21b2a52017-12-12 13:01:25 -0500330 return false;
331 }
332
Robert Phillipsa27d6252019-12-10 14:48:36 -0500333 return fOutstandingTestingOnlyTextureIDs.contains(info.id());
Robert Phillipsd21b2a52017-12-12 13:01:25 -0500334}
335
Brian Salomon72c7b982020-10-06 10:07:38 -0400336GrBackendRenderTarget GrMockGpu::createTestingOnlyBackendRenderTarget(SkISize dimensions,
337 GrColorType colorType,
Brian Salomonf9b00422020-10-08 16:00:14 -0400338 int sampleCnt,
339 GrProtected) {
Greg Daniele877dce2019-07-11 10:52:43 -0400340 GrMockRenderTargetInfo info(colorType, NextExternalRenderTargetID());
Brian Salomon0c51eea2018-03-09 17:02:09 -0500341 static constexpr int kStencilBits = 8;
Brian Salomon72c7b982020-10-06 10:07:38 -0400342 return GrBackendRenderTarget(dimensions.width(), dimensions.height(), sampleCnt, kStencilBits,
343 info);
Brian Salomonf865b052018-03-09 09:01:53 -0500344}
345
346void GrMockGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) {}
347#endif