blob: 1927b1823487c45578d69f55b2d57db25bdb0220 [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
Greg Danielc0d69152020-10-08 14:59:00 -04008#include "src/gpu/mock/GrMockGpu.h"
9
Robert Phillipsae67c522021-03-03 11:03:38 -050010#include "src/gpu/GrThreadSafePipelineBuilder.h"
Greg Danielc0d69152020-10-08 14:59:00 -040011#include "src/gpu/mock/GrMockAttachment.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "src/gpu/mock/GrMockBuffer.h"
13#include "src/gpu/mock/GrMockCaps.h"
Greg Daniel2d41d0d2019-08-26 11:08:51 -040014#include "src/gpu/mock/GrMockOpsRenderPass.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050015#include "src/gpu/mock/GrMockTexture.h"
Greg Danielc0d69152020-10-08 14:59:00 -040016
Mike Kleinde2244c2018-12-04 11:16:08 -050017#include <atomic>
Brian Salomoncfe910d2017-07-06 16:40:18 -040018
Brian Salomon8fe24272017-07-07 12:56:11 -040019int GrMockGpu::NextInternalTextureID() {
Mike Kleinde2244c2018-12-04 11:16:08 -050020 static std::atomic<int> nextID{1};
Chris Dalton351e80c2019-01-06 22:51:00 -070021 int id;
22 do {
Adlai Holler4888cda2020-11-06 16:37:37 -050023 id = nextID.fetch_add(1, std::memory_order_relaxed);
Chris Dalton351e80c2019-01-06 22:51:00 -070024 } while (0 == id); // Reserve 0 for an invalid ID.
25 return id;
Brian Salomon8fe24272017-07-07 12:56:11 -040026}
27
28int GrMockGpu::NextExternalTextureID() {
29 // We use negative ints for the "testing only external textures" so they can easily be
30 // identified when debugging.
Mike Kleinde2244c2018-12-04 11:16:08 -050031 static std::atomic<int> nextID{-1};
Adlai Holler4888cda2020-11-06 16:37:37 -050032 return nextID.fetch_add(-1, std::memory_order_relaxed);
Brian Salomon8fe24272017-07-07 12:56:11 -040033}
34
Brian Salomon0c51eea2018-03-09 17:02:09 -050035int GrMockGpu::NextInternalRenderTargetID() {
Mike Kleinde2244c2018-12-04 11:16:08 -050036 // We start off with large numbers to differentiate from texture IDs, even though they're
Brian Salomon0c51eea2018-03-09 17:02:09 -050037 // technically in a different space.
Mike Kleinde2244c2018-12-04 11:16:08 -050038 static std::atomic<int> nextID{SK_MaxS32};
Adlai Holler4888cda2020-11-06 16:37:37 -050039 return nextID.fetch_add(-1, std::memory_order_relaxed);
Brian Salomon0c51eea2018-03-09 17:02:09 -050040}
41
42int GrMockGpu::NextExternalRenderTargetID() {
43 // We use large negative ints for the "testing only external render targets" so they can easily
44 // be identified when debugging.
Mike Kleinde2244c2018-12-04 11:16:08 -050045 static std::atomic<int> nextID{SK_MinS32};
Adlai Holler4888cda2020-11-06 16:37:37 -050046 return nextID.fetch_add(1, std::memory_order_relaxed);
Brian Salomon0c51eea2018-03-09 17:02:09 -050047}
48
Brian Salomon384fab42017-12-07 12:33:05 -050049sk_sp<GrGpu> GrMockGpu::Make(const GrMockOptions* mockOptions,
Adlai Holler3d0359a2020-07-09 15:35:55 -040050 const GrContextOptions& contextOptions, GrDirectContext* direct) {
Greg Daniel02611d92017-07-25 10:05:01 -040051 static const GrMockOptions kDefaultOptions = GrMockOptions();
52 if (!mockOptions) {
53 mockOptions = &kDefaultOptions;
54 }
Adlai Holler3d0359a2020-07-09 15:35:55 -040055 return sk_sp<GrGpu>(new GrMockGpu(direct, *mockOptions, contextOptions));
Greg Daniel02611d92017-07-25 10:05:01 -040056}
57
Greg Daniel65476e02020-10-27 09:20:20 -040058GrOpsRenderPass* GrMockGpu::onGetOpsRenderPass(GrRenderTarget* rt,
Greg Danielc0d69152020-10-08 14:59:00 -040059 GrAttachment*,
60 GrSurfaceOrigin origin,
61 const SkIRect& bounds,
62 const GrOpsRenderPass::LoadAndStoreInfo& colorInfo,
63 const GrOpsRenderPass::StencilLoadAndStoreInfo&,
64 const SkTArray<GrSurfaceProxy*, true>& sampledProxies,
65 GrXferBarrierFlags renderPassXferBarriers) {
Greg Daniel2d41d0d2019-08-26 11:08:51 -040066 return new GrMockOpsRenderPass(this, rt, origin, colorInfo);
Brian Salomoncfe910d2017-07-06 16:40:18 -040067}
68
Greg Daniel2d41d0d2019-08-26 11:08:51 -040069void GrMockGpu::submit(GrOpsRenderPass* renderPass) {
70 for (int i = 0; i < static_cast<GrMockOpsRenderPass*>(renderPass)->numDraws(); ++i) {
Brian Salomoncfe910d2017-07-06 16:40:18 -040071 fStats.incNumDraws();
72 }
Greg Daniel2d41d0d2019-08-26 11:08:51 -040073 delete renderPass;
Brian Salomoncfe910d2017-07-06 16:40:18 -040074}
75
Adlai Holler3d0359a2020-07-09 15:35:55 -040076GrMockGpu::GrMockGpu(GrDirectContext* direct, const GrMockOptions& options,
Brian Salomoncfe910d2017-07-06 16:40:18 -040077 const GrContextOptions& contextOptions)
Adlai Holler3d0359a2020-07-09 15:35:55 -040078 : INHERITED(direct)
Chris Dalton91ab1552018-04-18 13:24:25 -060079 , fMockOptions(options) {
Brian Osmancbdc2612020-11-23 15:30:48 -050080 this->initCapsAndCompiler(sk_make_sp<GrMockCaps>(contextOptions, options));
Brian Salomoncfe910d2017-07-06 16:40:18 -040081}
82
Robert Phillipsae67c522021-03-03 11:03:38 -050083GrMockGpu::~GrMockGpu() {}
84
85GrThreadSafePipelineBuilder* GrMockGpu::pipelineBuilder() {
86 return nullptr;
87}
88
89sk_sp<GrThreadSafePipelineBuilder> GrMockGpu::refPipelineBuilder() {
90 return nullptr;
91}
92
Chris Daltonc3318f02019-07-19 14:20:53 -060093void GrMockGpu::querySampleLocations(GrRenderTarget* rt, SkTArray<SkPoint>* sampleLocations) {
94 sampleLocations->reset();
95 int numRemainingSamples = rt->numSamples();
96 while (numRemainingSamples > 0) {
97 // Use standard D3D sample locations.
98 switch (numRemainingSamples) {
99 case 0:
100 case 1:
101 sampleLocations->push_back().set(.5, .5);
102 break;
103 case 2:
104 sampleLocations->push_back().set(.75, .75);
105 sampleLocations->push_back().set(.25, .25);
106 break;
107 case 3:
108 case 4:
109 sampleLocations->push_back().set(.375, .125);
110 sampleLocations->push_back().set(.875, .375);
111 sampleLocations->push_back().set(.125, .625);
112 sampleLocations->push_back().set(.625, .875);
113 break;
114 case 5:
115 case 6:
116 case 7:
117 case 8:
118 sampleLocations->push_back().set(.5625, .3125);
119 sampleLocations->push_back().set(.4375, .6875);
120 sampleLocations->push_back().set(.8125, .5625);
121 sampleLocations->push_back().set(.3125, .1875);
122 sampleLocations->push_back().set(.1875, .8125);
123 sampleLocations->push_back().set(.0625, .4375);
124 sampleLocations->push_back().set(.6875, .4375);
125 sampleLocations->push_back().set(.4375, .0625);
126 break;
127 default:
128 sampleLocations->push_back().set(.5625, .5625);
129 sampleLocations->push_back().set(.4375, .3125);
130 sampleLocations->push_back().set(.3125, .6250);
131 sampleLocations->push_back().set(.2500, .4375);
132 sampleLocations->push_back().set(.1875, .3750);
133 sampleLocations->push_back().set(.6250, .8125);
134 sampleLocations->push_back().set(.8125, .6875);
135 sampleLocations->push_back().set(.6875, .1875);
136 sampleLocations->push_back().set(.3750, .8750);
137 sampleLocations->push_back().set(.5000, .0625);
138 sampleLocations->push_back().set(.2500, .1250);
139 sampleLocations->push_back().set(.1250, .2500);
140 sampleLocations->push_back().set(.0000, .5000);
141 sampleLocations->push_back().set(.4375, .2500);
142 sampleLocations->push_back().set(.8750, .4375);
143 sampleLocations->push_back().set(.0625, .0000);
144 break;
145 }
146 numRemainingSamples = rt->numSamples() - sampleLocations->count();
147 }
148}
149
Brian Salomona56a7462020-02-07 14:17:25 -0500150sk_sp<GrTexture> GrMockGpu::onCreateTexture(SkISize dimensions,
Brian Salomon81536f22019-08-08 16:30:49 -0400151 const GrBackendFormat& format,
152 GrRenderable renderable,
153 int renderTargetSampleCnt,
154 SkBudgeted budgeted,
155 GrProtected isProtected,
Brian Salomond2a8ae22019-09-10 16:03:59 -0400156 int mipLevelCount,
157 uint32_t levelClearMask) {
Chris Dalton91ab1552018-04-18 13:24:25 -0600158 if (fMockOptions.fFailTextureAllocations) {
159 return nullptr;
160 }
161
Robert Phillipsa27d6252019-12-10 14:48:36 -0500162 // Compressed formats should go through onCreateCompressedTexture
163 SkASSERT(format.asMockCompressionType() == SkImage::CompressionType::kNone);
164
Brian Salomon81536f22019-08-08 16:30:49 -0400165 GrColorType ct = format.asMockColorType();
166 SkASSERT(ct != GrColorType::kUnknown);
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400167
Brian Salomona6db5102020-07-21 09:56:23 -0400168 GrMipmapStatus mipmapStatus =
169 mipLevelCount > 1 ? GrMipmapStatus::kDirty : GrMipmapStatus::kNotAllocated;
Robert Phillipsa27d6252019-12-10 14:48:36 -0500170 GrMockTextureInfo texInfo(ct, SkImage::CompressionType::kNone, NextInternalTextureID());
Brian Salomonf2c2ba92019-07-17 09:59:59 -0400171 if (renderable == GrRenderable::kYes) {
Greg Daniele877dce2019-07-11 10:52:43 -0400172 GrMockRenderTargetInfo rtInfo(ct, NextInternalRenderTargetID());
Brian Salomona56a7462020-02-07 14:17:25 -0500173 return sk_sp<GrTexture>(new GrMockTextureRenderTarget(this, budgeted, dimensions,
Brian Salomon27b4d8d2019-07-22 14:23:45 -0400174 renderTargetSampleCnt, isProtected,
Brian Salomona6db5102020-07-21 09:56:23 -0400175 mipmapStatus, texInfo, rtInfo));
Brian Salomoncfe910d2017-07-06 16:40:18 -0400176 }
Brian Salomone8a766b2019-07-19 14:24:36 -0400177 return sk_sp<GrTexture>(
Brian Salomona6db5102020-07-21 09:56:23 -0400178 new GrMockTexture(this, budgeted, dimensions, isProtected, mipmapStatus, texInfo));
Brian Salomoncfe910d2017-07-06 16:40:18 -0400179}
180
Robert Phillipsa27d6252019-12-10 14:48:36 -0500181// TODO: why no 'isProtected' ?!
Robert Phillips9f744f72019-12-19 19:14:33 -0500182sk_sp<GrTexture> GrMockGpu::onCreateCompressedTexture(SkISize dimensions,
Robert Phillipsa27d6252019-12-10 14:48:36 -0500183 const GrBackendFormat& format,
Robert Phillips3a833922020-01-21 15:25:58 -0500184 SkBudgeted budgeted,
Brian Salomon7e67dca2020-07-21 09:27:25 -0400185 GrMipmapped mipMapped,
Robert Phillips3a833922020-01-21 15:25:58 -0500186 GrProtected isProtected,
Robert Phillips9f744f72019-12-19 19:14:33 -0500187 const void* data, size_t dataSize) {
Robert Phillipsa27d6252019-12-10 14:48:36 -0500188 if (fMockOptions.fFailTextureAllocations) {
189 return nullptr;
190 }
191
Greg Danielb58a3c72020-01-23 10:05:14 -0500192#ifdef SK_DEBUG
Robert Phillipsa27d6252019-12-10 14:48:36 -0500193 // Uncompressed formats should go through onCreateTexture
194 SkImage::CompressionType compression = format.asMockCompressionType();
195 SkASSERT(compression != SkImage::CompressionType::kNone);
Greg Danielb58a3c72020-01-23 10:05:14 -0500196#endif
Robert Phillipsa27d6252019-12-10 14:48:36 -0500197
Brian Salomona6db5102020-07-21 09:56:23 -0400198 GrMipmapStatus mipmapStatus = (mipMapped == GrMipmapped::kYes)
199 ? GrMipmapStatus::kValid
200 : GrMipmapStatus::kNotAllocated;
Robert Phillipsa27d6252019-12-10 14:48:36 -0500201 GrMockTextureInfo texInfo(GrColorType::kUnknown,
202 format.asMockCompressionType(),
203 NextInternalTextureID());
204
Brian Salomona56a7462020-02-07 14:17:25 -0500205 return sk_sp<GrTexture>(
Brian Salomona6db5102020-07-21 09:56:23 -0400206 new GrMockTexture(this, budgeted, dimensions, isProtected, mipmapStatus, texInfo));
Brian Salomonbb8dde82019-06-27 10:52:13 -0400207}
208
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400209sk_sp<GrTexture> GrMockGpu::onWrapBackendTexture(const GrBackendTexture& tex,
Brian Salomonfa2ebea2019-01-24 15:58:58 -0500210 GrWrapOwnership ownership,
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400211 GrWrapCacheable wrapType,
212 GrIOType ioType) {
Robert Phillipsc80b0e92019-07-23 10:27:09 -0400213 GrMockTextureInfo texInfo;
214 SkAssertResult(tex.getMockTextureInfo(&texInfo));
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400215
Robert Phillipsa27d6252019-12-10 14:48:36 -0500216 SkImage::CompressionType compression = texInfo.compressionType();
Robert Phillipsb915c942019-12-17 14:44:37 -0500217 if (compression != SkImage::CompressionType::kNone) {
218 return nullptr;
Robert Phillipsa27d6252019-12-10 14:48:36 -0500219 }
220
Brian Salomon40a40622020-07-21 10:32:07 -0400221 GrMipmapStatus mipmapStatus = tex.hasMipmaps() ? GrMipmapStatus::kValid
Brian Salomona6db5102020-07-21 09:56:23 -0400222 : GrMipmapStatus::kNotAllocated;
Brian Salomone8a766b2019-07-19 14:24:36 -0400223 auto isProtected = GrProtected(tex.isProtected());
Brian Salomona6db5102020-07-21 09:56:23 -0400224 return sk_sp<GrTexture>(new GrMockTexture(this, tex.dimensions(), isProtected, mipmapStatus,
Brian Salomona56a7462020-02-07 14:17:25 -0500225 texInfo, wrapType, ioType));
Greg Daniel4684f822018-03-08 15:27:36 -0500226}
227
Robert Phillipsb915c942019-12-17 14:44:37 -0500228sk_sp<GrTexture> GrMockGpu::onWrapCompressedBackendTexture(const GrBackendTexture& tex,
229 GrWrapOwnership ownership,
230 GrWrapCacheable wrapType) {
231 return nullptr;
232}
233
Brian Salomon0c51eea2018-03-09 17:02:09 -0500234sk_sp<GrTexture> GrMockGpu::onWrapRenderableBackendTexture(const GrBackendTexture& tex,
235 int sampleCnt,
Brian Salomonaa6ca0a2019-01-24 16:03:07 -0500236 GrWrapOwnership ownership,
237 GrWrapCacheable cacheable) {
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400238 GrMockTextureInfo texInfo;
239 SkAssertResult(tex.getMockTextureInfo(&texInfo));
Robert Phillipsa27d6252019-12-10 14:48:36 -0500240 SkASSERT(texInfo.compressionType() == SkImage::CompressionType::kNone);
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400241
Brian Salomona6db5102020-07-21 09:56:23 -0400242 GrMipmapStatus mipmapStatus =
Brian Salomon40a40622020-07-21 10:32:07 -0400243 tex.hasMipmaps() ? GrMipmapStatus::kValid : GrMipmapStatus::kNotAllocated;
Brian Salomon0c51eea2018-03-09 17:02:09 -0500244
Brian Salomon0c51eea2018-03-09 17:02:09 -0500245 // The client gave us the texture ID but we supply the render target ID.
Robert Phillipsa27d6252019-12-10 14:48:36 -0500246 GrMockRenderTargetInfo rtInfo(texInfo.colorType(), NextInternalRenderTargetID());
Brian Salomon0c51eea2018-03-09 17:02:09 -0500247
Brian Salomone8a766b2019-07-19 14:24:36 -0400248 auto isProtected = GrProtected(tex.isProtected());
Brian Salomona56a7462020-02-07 14:17:25 -0500249 return sk_sp<GrTexture>(new GrMockTextureRenderTarget(this, tex.dimensions(), sampleCnt,
Brian Salomona6db5102020-07-21 09:56:23 -0400250 isProtected, mipmapStatus, texInfo,
Brian Salomona56a7462020-02-07 14:17:25 -0500251 rtInfo, cacheable));
Brian Salomon0c51eea2018-03-09 17:02:09 -0500252}
253
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400254sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt) {
Robert Phillipsa5e78be2019-07-09 12:34:38 -0400255 GrMockRenderTargetInfo info;
256 SkAssertResult(rt.getMockRenderTargetInfo(&info));
257
Brian Salomone8a766b2019-07-19 14:24:36 -0400258 auto isProtected = GrProtected(rt.isProtected());
Brian Salomona56a7462020-02-07 14:17:25 -0500259 return sk_sp<GrRenderTarget>(new GrMockRenderTarget(this, GrMockRenderTarget::kWrapped,
260 rt.dimensions(), rt.sampleCnt(),
261 isProtected, info));
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
Greg Danielc0d69152020-10-08 14:59:00 -0400269sk_sp<GrAttachment> GrMockGpu::makeStencilAttachmentForRenderTarget(const GrRenderTarget* rt,
270 SkISize dimensions,
271 int numStencilSamples) {
Chris Daltoneffee202019-07-01 22:28:03 -0600272 SkASSERT(numStencilSamples == rt->numSamples());
Brian Salomoncfe910d2017-07-06 16:40:18 -0400273 fStats.incStencilAttachmentCreates();
Greg Danielc0d69152020-10-08 14:59:00 -0400274 return sk_sp<GrAttachment>(
Greg Daniel25ebd952020-11-03 11:17:05 -0500275 new GrMockAttachment(this, dimensions, GrAttachment::UsageFlags::kStencilAttachment,
Greg Danielc0d69152020-10-08 14:59:00 -0400276 rt->numSamples()));
Brian Salomoncfe910d2017-07-06 16:40:18 -0400277}
Brian Salomon8fe24272017-07-07 12:56:11 -0400278
Brian Salomon85c3d682019-11-04 15:04:54 -0500279GrBackendTexture GrMockGpu::onCreateBackendTexture(SkISize dimensions,
Robert Phillips57ef6802019-09-23 10:12:47 -0400280 const GrBackendFormat& format,
Brian Salomon85c3d682019-11-04 15:04:54 -0500281 GrRenderable,
Brian Salomon7e67dca2020-07-21 09:27:25 -0400282 GrMipmapped mipMapped,
Greg Daniel16032b32020-05-06 15:31:10 -0400283 GrProtected) {
Robert Phillipsa27d6252019-12-10 14:48:36 -0500284 SkImage::CompressionType compression = format.asMockCompressionType();
285 if (compression != SkImage::CompressionType::kNone) {
286 return {}; // should go through onCreateCompressedBackendTexture
287 }
288
Brian Salomond4764a12019-08-08 12:08:24 -0400289 auto colorType = format.asMockColorType();
Greg Daniel7bfc9132019-08-14 14:23:53 -0400290 if (!this->caps()->isFormatTexturable(format)) {
Robert Phillips9dbcdcc2019-05-13 10:40:06 -0400291 return GrBackendTexture(); // invalid
292 }
293
Robert Phillipsa27d6252019-12-10 14:48:36 -0500294 GrMockTextureInfo info(colorType, SkImage::CompressionType::kNone, NextExternalTextureID());
Robert Phillips646f6372018-09-25 09:31:10 -0400295
Robert Phillipsa27d6252019-12-10 14:48:36 -0500296 fOutstandingTestingOnlyTextureIDs.add(info.id());
Brian Salomon85c3d682019-11-04 15:04:54 -0500297 return GrBackendTexture(dimensions.width(), dimensions.height(), mipMapped, info);
Robert Phillipsd21b2a52017-12-12 13:01:25 -0500298}
299
Greg Danielc1ad77c2020-05-06 11:40:03 -0400300GrBackendTexture GrMockGpu::onCreateCompressedBackendTexture(
Brian Salomon7e67dca2020-07-21 09:27:25 -0400301 SkISize dimensions, const GrBackendFormat& format, GrMipmapped mipMapped,
Greg Danielaaf738c2020-07-10 09:30:33 -0400302 GrProtected) {
Robert Phillipsb915c942019-12-17 14:44:37 -0500303 SkImage::CompressionType compression = format.asMockCompressionType();
304 if (compression == SkImage::CompressionType::kNone) {
305 return {}; // should go through onCreateBackendTexture
306 }
307
308 if (!this->caps()->isFormatTexturable(format)) {
309 return {};
310 }
311
312 GrMockTextureInfo info(GrColorType::kUnknown, compression, NextExternalTextureID());
313
314 fOutstandingTestingOnlyTextureIDs.add(info.id());
315 return GrBackendTexture(dimensions.width(), dimensions.height(), mipMapped, info);
316}
317
Robert Phillipsf0313ee2019-05-21 13:51:11 -0400318void GrMockGpu::deleteBackendTexture(const GrBackendTexture& tex) {
Robert Phillipsf0ced622019-05-16 09:06:25 -0400319 SkASSERT(GrBackendApi::kMock == tex.backend());
320
321 GrMockTextureInfo info;
322 if (tex.getMockTextureInfo(&info)) {
Robert Phillipsa27d6252019-12-10 14:48:36 -0500323 fOutstandingTestingOnlyTextureIDs.remove(info.id());
Robert Phillipsf0ced622019-05-16 09:06:25 -0400324 }
325}
326
327#if GR_TEST_UTILS
Robert Phillipsd21b2a52017-12-12 13:01:25 -0500328bool GrMockGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
Greg Danielbdf12ad2018-10-12 09:31:11 -0400329 SkASSERT(GrBackendApi::kMock == tex.backend());
Robert Phillipsd21b2a52017-12-12 13:01:25 -0500330
Greg Daniel52e16d92018-04-10 09:34:07 -0400331 GrMockTextureInfo info;
332 if (!tex.getMockTextureInfo(&info)) {
Robert Phillipsd21b2a52017-12-12 13:01:25 -0500333 return false;
334 }
335
Robert Phillipsa27d6252019-12-10 14:48:36 -0500336 return fOutstandingTestingOnlyTextureIDs.contains(info.id());
Robert Phillipsd21b2a52017-12-12 13:01:25 -0500337}
338
Brian Salomon72c7b982020-10-06 10:07:38 -0400339GrBackendRenderTarget GrMockGpu::createTestingOnlyBackendRenderTarget(SkISize dimensions,
340 GrColorType colorType,
Brian Salomonf9b00422020-10-08 16:00:14 -0400341 int sampleCnt,
342 GrProtected) {
Greg Daniele877dce2019-07-11 10:52:43 -0400343 GrMockRenderTargetInfo info(colorType, NextExternalRenderTargetID());
Brian Salomon0c51eea2018-03-09 17:02:09 -0500344 static constexpr int kStencilBits = 8;
Brian Salomon72c7b982020-10-06 10:07:38 -0400345 return GrBackendRenderTarget(dimensions.width(), dimensions.height(), sampleCnt, kStencilBits,
346 info);
Brian Salomonf865b052018-03-09 09:01:53 -0500347}
348
349void GrMockGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) {}
350#endif