diff options
author | Robert Phillips <robertphillips@google.com> | 2017-02-22 15:28:38 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-23 15:01:42 +0000 |
commit | 30f9bc69cfc506075e1fce8e7934f941c0203023 (patch) | |
tree | f15f11bcb790206acaff8bfe6bb881eb254bec39 /tests/ProcessorTest.cpp | |
parent | bcfb8f639e516b673b6dbda41900efac69be2daf (diff) |
Switch GrTextureStripAtlas over to GrTextureProxies
This is split out of: https://skia-review.googlesource.com/c/8823/ (Remove GrFragmentProcessor-derived class' GrTexture-based ctors)
Change-Id: I9f602985b6010fc58b595e2be6d4e67e50179747
Reviewed-on: https://skia-review.googlesource.com/8881
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/ProcessorTest.cpp')
-rw-r--r-- | tests/ProcessorTest.cpp | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index 8801a34b22..bb9a3daaee 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -50,10 +50,11 @@ public: static sk_sp<GrFragmentProcessor> Make(sk_sp<GrFragmentProcessor> child) { return sk_sp<GrFragmentProcessor>(new TestFP(std::move(child))); } - static sk_sp<GrFragmentProcessor> Make(const SkTArray<sk_sp<GrTexture>>& textures, + static sk_sp<GrFragmentProcessor> Make(GrContext* context, + const SkTArray<sk_sp<GrTextureProxy>>& proxies, const SkTArray<sk_sp<GrBuffer>>& buffers, const SkTArray<Image>& images) { - return sk_sp<GrFragmentProcessor>(new TestFP(textures, buffers, images)); + return sk_sp<GrFragmentProcessor>(new TestFP(context, proxies, buffers, images)); } const char* name() const override { return "test"; } @@ -65,11 +66,13 @@ public: } private: - TestFP(const SkTArray<sk_sp<GrTexture>>& textures, const SkTArray<sk_sp<GrBuffer>>& buffers, + TestFP(GrContext* context, + const SkTArray<sk_sp<GrTextureProxy>>& proxies, + const SkTArray<sk_sp<GrBuffer>>& buffers, const SkTArray<Image>& images) : INHERITED(kNone_OptimizationFlags), fSamplers(4), fBuffers(4), fImages(4) { - for (const auto& texture : textures) { - this->addTextureSampler(&fSamplers.emplace_back(texture.get())); + for (const auto& proxy : proxies) { + this->addTextureSampler(&fSamplers.emplace_back(context->textureProvider(), proxy)); } for (const auto& buffer : buffers) { this->addBufferAccess(&fBuffers.emplace_back(kRGBA_8888_GrPixelConfig, buffer.get())); @@ -115,6 +118,12 @@ inline void testingOnly_getIORefCnts(const T* resource, int* refCnt, int* readCn *writeCnt = resource->fPendingWrites; } +void testingOnly_getIORefCnts(GrSurfaceProxy* proxy, int* refCnt, int* readCnt, int* writeCnt) { + *refCnt = proxy->getBackingRefCnt_TestOnly(); + *readCnt = proxy->getPendingReadCnt_TestOnly(); + *writeCnt = proxy->getPendingWriteCnt_TestOnly(); +} + DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); @@ -129,8 +138,9 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { { bool texelBufferSupport = context->caps()->shaderCaps()->texelBufferSupport(); bool imageLoadStoreSupport = context->caps()->shaderCaps()->imageLoadStoreSupport(); - sk_sp<GrTexture> texture1( - context->resourceProvider()->createTexture(desc, SkBudgeted::kYes)); + sk_sp<GrSurfaceProxy> proxy1(GrSurfaceProxy::MakeDeferred(*context->caps(), desc, + SkBackingFit::kExact, + SkBudgeted::kYes)); sk_sp<GrTexture> texture2( context->resourceProvider()->createTexture(desc, SkBudgeted::kYes)); sk_sp<GrTexture> texture3( @@ -143,10 +153,10 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { GrAccessPattern::kStatic_GrAccessPattern, 0) : nullptr); { - SkTArray<sk_sp<GrTexture>> textures; + SkTArray<sk_sp<GrTextureProxy>> proxies; SkTArray<sk_sp<GrBuffer>> buffers; SkTArray<TestFP::Image> images; - textures.push_back(texture1); + proxies.push_back(sk_ref_sp(proxy1->asTextureProxy())); if (texelBufferSupport) { buffers.push_back(buffer); } @@ -157,7 +167,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { } std::unique_ptr<GrDrawOp> op(TestOp::Make()); GrPaint paint; - auto fp = TestFP::Make(std::move(textures), std::move(buffers), std::move(images)); + auto fp = TestFP::Make(context, + std::move(proxies), std::move(buffers), std::move(images)); for (int i = 0; i < parentCnt; ++i) { fp = TestFP::Make(std::move(fp)); } @@ -167,7 +178,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { } int refCnt, readCnt, writeCnt; - testingOnly_getIORefCnts(texture1.get(), &refCnt, &readCnt, &writeCnt); + testingOnly_getIORefCnts(proxy1.get(), &refCnt, &readCnt, &writeCnt); REPORTER_ASSERT(reporter, 1 == refCnt); REPORTER_ASSERT(reporter, 1 == readCnt); REPORTER_ASSERT(reporter, 0 == writeCnt); @@ -198,7 +209,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { context->flush(); - testingOnly_getIORefCnts(texture1.get(), &refCnt, &readCnt, &writeCnt); + testingOnly_getIORefCnts(proxy1.get(), &refCnt, &readCnt, &writeCnt); REPORTER_ASSERT(reporter, 1 == refCnt); REPORTER_ASSERT(reporter, 0 == readCnt); REPORTER_ASSERT(reporter, 0 == writeCnt); @@ -241,10 +252,10 @@ static GrColor texel_color(int i, int j) { static GrColor4f texel_color4f(int i, int j) { return GrColor4f::FromGrColor(texel_color(i, j)); } -void test_draw_op(GrRenderTargetContext* rtc, sk_sp<GrFragmentProcessor> fp, - GrTexture* inputDataTexture) { +void test_draw_op(GrContext* context, GrRenderTargetContext* rtc, sk_sp<GrFragmentProcessor> fp, + sk_sp<GrTextureProxy> inputDataProxy) { GrPaint paint; - paint.addColorTextureProcessor(inputDataTexture, nullptr, SkMatrix::I()); + paint.addColorTextureProcessor(context, std::move(inputDataProxy), nullptr, SkMatrix::I()); paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); GrPipelineBuilder pb(std::move(paint), GrAAType::kNone); @@ -299,8 +310,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor } } desc.fConfig = kRGBA_8888_GrPixelConfig; - sk_sp<GrTexture> dataTexture(context->textureProvider()->createTexture( - desc, SkBudgeted::kYes, rgbaData.get(), 256 * sizeof(GrColor))); + + sk_sp<GrSurfaceProxy> dataProxy = GrSurfaceProxy::MakeDeferred(*context->caps(), + context->textureProvider(), + desc, SkBudgeted::kYes, + rgbaData.get(), + 256 * sizeof(GrColor)); // Because processors factories configure themselves in random ways, this is not exhaustive. for (int i = 0; i < FPFactory::Count(); ++i) { @@ -319,7 +334,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor !fp->compatibleWithCoverageAsAlpha()) { continue; } - test_draw_op(rtc.get(), fp, dataTexture.get()); + test_draw_op(context, rtc.get(), fp, sk_ref_sp(dataProxy->asTextureProxy())); memset(rgbaData.get(), 0x0, sizeof(GrColor) * 256 * 256); rtc->readPixels( SkImageInfo::Make(256, 256, kRGBA_8888_SkColorType, kPremul_SkAlphaType), |