robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [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 | |
| 8 | // This is a GPU-backend specific test. |
| 9 | |
| 10 | #include "Test.h" |
| 11 | |
| 12 | #if SK_SUPPORT_GPU |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 13 | #include "GrRenderTargetPriv.h" |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 14 | #include "GrRenderTargetProxy.h" |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 15 | #include "GrResourceProvider.h" |
| 16 | #include "GrSurfaceProxy.h" |
| 17 | #include "GrTextureProxy.h" |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 18 | |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 19 | // Check that the surface proxy's member vars are set as expected |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 20 | static void check_surface(skiatest::Reporter* reporter, |
| 21 | GrSurfaceProxy* proxy, |
| 22 | GrSurfaceOrigin origin, |
| 23 | int width, int height, |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 24 | GrPixelConfig config, |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 25 | const GrGpuResource::UniqueID& uniqueID, |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 26 | SkBudgeted budgeted) { |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 27 | REPORTER_ASSERT(reporter, proxy->origin() == origin); |
| 28 | REPORTER_ASSERT(reporter, proxy->width() == width); |
| 29 | REPORTER_ASSERT(reporter, proxy->height() == height); |
| 30 | REPORTER_ASSERT(reporter, proxy->config() == config); |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 31 | if (!uniqueID.isInvalid()) { |
| 32 | REPORTER_ASSERT(reporter, proxy->uniqueID().asUInt() == uniqueID.asUInt()); |
| 33 | } else { |
| 34 | REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid()); |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 35 | } |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 36 | REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | static void check_rendertarget(skiatest::Reporter* reporter, |
Robert Phillips | ec2249f | 2016-11-09 08:54:35 -0500 | [diff] [blame] | 40 | const GrCaps& caps, |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 41 | GrResourceProvider* provider, |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 42 | GrRenderTargetProxy* rtProxy, |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 43 | int numSamples, |
Robert Phillips | ec2249f | 2016-11-09 08:54:35 -0500 | [diff] [blame] | 44 | SkBackingFit fit, |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 45 | int expectedMaxWindowRects, |
| 46 | bool wasWrapped) { |
Robert Phillips | ec2249f | 2016-11-09 08:54:35 -0500 | [diff] [blame] | 47 | REPORTER_ASSERT(reporter, rtProxy->maxWindowRectangles(caps) == expectedMaxWindowRects); |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 48 | REPORTER_ASSERT(reporter, rtProxy->numStencilSamples() == numSamples); |
| 49 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 50 | GrSurfaceProxy::UniqueID idBefore = rtProxy->uniqueID(); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 51 | GrRenderTarget* rt = rtProxy->instantiate(provider); |
| 52 | REPORTER_ASSERT(reporter, rt); |
| 53 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 54 | REPORTER_ASSERT(reporter, rtProxy->uniqueID() == idBefore); |
| 55 | if (wasWrapped) { |
| 56 | // Wrapped resources share their uniqueID with the wrapping RenderTargetProxy |
| 57 | REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() == rt->uniqueID().asUInt()); |
| 58 | } else { |
| 59 | // Deferred resources should always have a different ID from their instantiated rendertarget |
| 60 | REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt()); |
| 61 | } |
| 62 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 63 | REPORTER_ASSERT(reporter, rt->origin() == rtProxy->origin()); |
| 64 | if (SkBackingFit::kExact == fit) { |
| 65 | REPORTER_ASSERT(reporter, rt->width() == rtProxy->width()); |
| 66 | REPORTER_ASSERT(reporter, rt->height() == rtProxy->height()); |
| 67 | } else { |
| 68 | REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width()); |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 69 | REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height()); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 70 | } |
| 71 | REPORTER_ASSERT(reporter, rt->config() == rtProxy->config()); |
| 72 | |
| 73 | REPORTER_ASSERT(reporter, rt->isUnifiedMultisampled() == rtProxy->isUnifiedMultisampled()); |
| 74 | REPORTER_ASSERT(reporter, rt->isStencilBufferMultisampled() == |
| 75 | rtProxy->isStencilBufferMultisampled()); |
| 76 | REPORTER_ASSERT(reporter, rt->numColorSamples() == rtProxy->numColorSamples()); |
| 77 | REPORTER_ASSERT(reporter, rt->numStencilSamples() == rtProxy->numStencilSamples()); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 78 | REPORTER_ASSERT(reporter, rt->isMixedSampled() == rtProxy->isMixedSampled()); |
| 79 | REPORTER_ASSERT(reporter, rt->renderTargetPriv().flags() == rtProxy->testingOnly_getFlags()); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | static void check_texture(skiatest::Reporter* reporter, |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 83 | GrResourceProvider* provider, |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 84 | GrTextureProxy* texProxy, |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 85 | SkBackingFit fit, |
| 86 | bool wasWrapped) { |
| 87 | GrSurfaceProxy::UniqueID idBefore = texProxy->uniqueID(); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 88 | GrTexture* tex = texProxy->instantiate(provider); |
| 89 | REPORTER_ASSERT(reporter, tex); |
| 90 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 91 | REPORTER_ASSERT(reporter, texProxy->uniqueID() == idBefore); |
| 92 | if (wasWrapped) { |
| 93 | // Wrapped resources share their uniqueID with the wrapping TextureProxy |
| 94 | REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() == tex->uniqueID().asUInt()); |
| 95 | } else { |
| 96 | // Deferred resources should always have a different ID from their instantiated texture |
| 97 | REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt()); |
| 98 | } |
| 99 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 100 | REPORTER_ASSERT(reporter, tex->origin() == texProxy->origin()); |
| 101 | if (SkBackingFit::kExact == fit) { |
| 102 | REPORTER_ASSERT(reporter, tex->width() == texProxy->width()); |
| 103 | REPORTER_ASSERT(reporter, tex->height() == texProxy->height()); |
| 104 | } else { |
| 105 | REPORTER_ASSERT(reporter, tex->width() >= texProxy->width()); |
| 106 | REPORTER_ASSERT(reporter, tex->height() >= texProxy->height()); |
| 107 | } |
| 108 | REPORTER_ASSERT(reporter, tex->config() == texProxy->config()); |
| 109 | } |
| 110 | |
| 111 | |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 112 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 113 | GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider(); |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 114 | const GrCaps& caps = *ctxInfo.grContext()->caps(); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 115 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 116 | const GrGpuResource::UniqueID kInvalidResourceID = GrGpuResource::UniqueID::InvalidID(); |
| 117 | |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 118 | int attempt = 0; // useful for debugging |
| 119 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 120 | for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) { |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 121 | for (auto widthHeight : { 100, 128, 1048576 }) { |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 122 | for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig, |
| 123 | kETC1_GrPixelConfig, kRGBA_8888_GrPixelConfig }) { |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 124 | for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) { |
| 125 | for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) { |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 126 | for (auto numSamples : { 0, 4, 16, 128 }) { |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 127 | GrSurfaceDesc desc; |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 128 | desc.fFlags = kRenderTarget_GrSurfaceFlag; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 129 | desc.fOrigin = origin; |
| 130 | desc.fWidth = widthHeight; |
| 131 | desc.fHeight = widthHeight; |
| 132 | desc.fConfig = config; |
| 133 | desc.fSampleCnt = numSamples; |
| 134 | |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 135 | { |
| 136 | sk_sp<GrTexture> tex; |
| 137 | if (SkBackingFit::kApprox == fit) { |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 138 | tex.reset(provider->createApproxTexture(desc, 0)); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 139 | } else { |
Robert Phillips | 5c44657 | 2017-02-01 10:53:20 -0500 | [diff] [blame] | 140 | tex.reset(provider->createTexture(desc, budgeted)); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 141 | } |
| 142 | |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 143 | sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred( |
Robert Phillips | 7928e76 | 2017-02-28 16:30:28 -0500 | [diff] [blame] | 144 | provider, |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 145 | caps, desc, |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 146 | fit, budgeted)); |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 147 | REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy)); |
| 148 | if (proxy) { |
| 149 | REPORTER_ASSERT(reporter, proxy->asRenderTargetProxy()); |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 150 | // This forces the proxy to compute and cache its |
| 151 | // pre-instantiation size guess. Later, when it is actually |
| 152 | // instantiated, it checks that the instantiated size is <= to |
| 153 | // the pre-computation. If the proxy never computed its |
| 154 | // pre-instantiation size then the check is skipped. |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 155 | proxy->gpuMemorySize(); |
Robert Phillips | b446088 | 2016-11-17 14:43:51 -0500 | [diff] [blame] | 156 | |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 157 | check_surface(reporter, proxy.get(), origin, |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 158 | widthHeight, widthHeight, config, |
| 159 | kInvalidResourceID, budgeted); |
| 160 | check_rendertarget(reporter, caps, provider, |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 161 | proxy->asRenderTargetProxy(), |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 162 | SkTMin(numSamples, caps.maxSampleCount()), |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 163 | fit, caps.maxWindowRectangles(), false); |
| 164 | } |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 167 | desc.fFlags = kNone_GrSurfaceFlags; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 168 | |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 169 | { |
| 170 | sk_sp<GrTexture> tex; |
| 171 | if (SkBackingFit::kApprox == fit) { |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 172 | tex.reset(provider->createApproxTexture(desc, 0)); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 173 | } else { |
Robert Phillips | 5c44657 | 2017-02-01 10:53:20 -0500 | [diff] [blame] | 174 | tex.reset(provider->createTexture(desc, budgeted)); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 175 | } |
Robert Phillips | b446088 | 2016-11-17 14:43:51 -0500 | [diff] [blame] | 176 | |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 177 | sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(provider, |
Robert Phillips | 7928e76 | 2017-02-28 16:30:28 -0500 | [diff] [blame] | 178 | caps, |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 179 | desc, |
| 180 | fit, |
| 181 | budgeted)); |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 182 | REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy)); |
| 183 | if (proxy) { |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 184 | // This forces the proxy to compute and cache its pre-instantiation |
| 185 | // size guess. Later, when it is actually instantiated, it checks |
| 186 | // that the instantiated size is <= to the pre-computation. |
| 187 | // If the proxy never computed its pre-instantiation size then the |
| 188 | // check is skipped. |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 189 | proxy->gpuMemorySize(); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 190 | |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 191 | check_surface(reporter, proxy.get(), origin, |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 192 | widthHeight, widthHeight, config, |
| 193 | kInvalidResourceID, budgeted); |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 194 | check_texture(reporter, provider, proxy->asTextureProxy(), |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 195 | fit, false); |
| 196 | } |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 197 | } |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 198 | |
| 199 | attempt++; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 200 | } |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
egdaniel | ab527a5 | 2016-06-28 08:07:26 -0700 | [diff] [blame] | 208 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 209 | GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider(); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 210 | const GrCaps& caps = *ctxInfo.grContext()->caps(); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 211 | |
| 212 | static const int kWidthHeight = 100; |
| 213 | |
| 214 | for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) { |
| 215 | for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig }) { |
| 216 | for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) { |
| 217 | for (auto numSamples: { 0, 4}) { |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 218 | bool renderable = caps.isConfigRenderable(config, numSamples > 0); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 219 | |
| 220 | GrSurfaceDesc desc; |
| 221 | desc.fOrigin = origin; |
| 222 | desc.fWidth = kWidthHeight; |
| 223 | desc.fHeight = kWidthHeight; |
| 224 | desc.fConfig = config; |
| 225 | desc.fSampleCnt = numSamples; |
| 226 | |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 227 | // External on-screen render target. |
| 228 | if (renderable && kOpenGL_GrBackend == ctxInfo.backend()) { |
| 229 | GrBackendRenderTargetDesc backendDesc; |
| 230 | backendDesc.fWidth = kWidthHeight; |
| 231 | backendDesc.fHeight = kWidthHeight; |
| 232 | backendDesc.fConfig = config; |
| 233 | backendDesc.fOrigin = origin; |
| 234 | backendDesc.fSampleCnt = numSamples; |
| 235 | backendDesc.fStencilBits = 8; |
| 236 | backendDesc.fRenderTargetHandle = 0; |
| 237 | |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 238 | sk_sp<GrRenderTarget> defaultFBO( |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 239 | provider->wrapBackendRenderTarget(backendDesc)); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 240 | |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 241 | sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(defaultFBO)); |
| 242 | check_surface(reporter, sProxy.get(), origin, |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 243 | kWidthHeight, kWidthHeight, config, |
| 244 | defaultFBO->uniqueID(), SkBudgeted::kNo); |
Robert Phillips | ec2249f | 2016-11-09 08:54:35 -0500 | [diff] [blame] | 245 | check_rendertarget(reporter, caps, provider, sProxy->asRenderTargetProxy(), |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 246 | numSamples, SkBackingFit::kExact, 0, true); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 247 | } |
| 248 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 249 | sk_sp<GrTexture> tex; |
| 250 | |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 251 | // Internal offscreen render target. |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 252 | if (renderable) { |
| 253 | desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 254 | tex.reset(provider->createTexture(desc, budgeted)); |
| 255 | sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget())); |
| 256 | |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 257 | sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(rt)); |
| 258 | check_surface(reporter, sProxy.get(), origin, |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 259 | kWidthHeight, kWidthHeight, config, |
| 260 | rt->uniqueID(), budgeted); |
Robert Phillips | ec2249f | 2016-11-09 08:54:35 -0500 | [diff] [blame] | 261 | check_rendertarget(reporter, caps, provider, sProxy->asRenderTargetProxy(), |
| 262 | numSamples, SkBackingFit::kExact, |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 263 | caps.maxWindowRectangles(), true); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | if (!tex) { |
| 267 | SkASSERT(kNone_GrSurfaceFlags == desc.fFlags ); |
| 268 | desc.fSampleCnt = 0; |
| 269 | tex.reset(provider->createTexture(desc, budgeted)); |
| 270 | } |
| 271 | |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 272 | sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(tex)); |
| 273 | check_surface(reporter, sProxy.get(), origin, |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 274 | kWidthHeight, kWidthHeight, config, tex->uniqueID(), budgeted); |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 275 | check_texture(reporter, provider, sProxy->asTextureProxy(), |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 276 | SkBackingFit::kExact, true); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 277 | } |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | #endif |