diff options
author | 2017-07-06 18:21:25 +0000 | |
---|---|---|
committer | 2017-07-06 18:21:37 +0000 | |
commit | c867a89b012c07e7e5cb719a31ed90e61f4a4901 (patch) | |
tree | c024d294fbe22508c65c686ad3771691d4ca5e1e /src/gpu | |
parent | 3276f9a4ffc0ea8aa2b6dc222b89ef794678123b (diff) |
Revert "Make mock GrContext unit testable."
This reverts commit 993e7e25217df05d63c3354c817e8bd18ea3738b.
Reason for revert: Seeing if this fixes the NexusPlayer bots
Original change's description:
> Make mock GrContext unit testable.
>
> Bug: skia:
> Change-Id: I959122f1f2c390832ab1033bcdbdd2ca6cfc0419
> Reviewed-on: https://skia-review.googlesource.com/20699
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
TBR=egdaniel@google.com,bsalomon@google.com
Change-Id: I25ed9329962d930fe38108f779ff7083e0e4847e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/21731
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrTexturePriv.h | 4 | ||||
-rw-r--r-- | src/gpu/mock/GrMockBuffer.h | 30 | ||||
-rw-r--r-- | src/gpu/mock/GrMockCaps.h | 41 | ||||
-rw-r--r-- | src/gpu/mock/GrMockGpu.cpp | 62 | ||||
-rw-r--r-- | src/gpu/mock/GrMockGpu.h | 68 | ||||
-rw-r--r-- | src/gpu/mock/GrMockGpuCommandBuffer.h | 41 | ||||
-rw-r--r-- | src/gpu/mock/GrMockStencilAttachment.h | 29 | ||||
-rw-r--r-- | src/gpu/mock/GrMockTexture.h | 90 |
8 files changed, 49 insertions, 316 deletions
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h index 8a256a4b40..67631fc2c4 100644 --- a/src/gpu/GrTexturePriv.h +++ b/src/gpu/GrTexturePriv.h @@ -56,12 +56,12 @@ public: SkDestinationSurfaceColorMode mipColorMode() const { return fTexture->fMipColorMode; } static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*); + +private: static void ComputeScratchKey(GrPixelConfig config, int width, int height, GrSurfaceOrigin origin, bool isRenderTarget, int sampleCnt, bool isMipMapped, GrScratchKey* key); - -private: GrTexturePriv(GrTexture* texture) : fTexture(texture) { } GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { } GrTexturePriv& operator=(const GrTexturePriv&); // unimpl diff --git a/src/gpu/mock/GrMockBuffer.h b/src/gpu/mock/GrMockBuffer.h deleted file mode 100644 index fdb812d30d..0000000000 --- a/src/gpu/mock/GrMockBuffer.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrMockBuffer_DEFINED -#define GrMockBuffer_DEFINED - -#include "GrBuffer.h" -#include "GrMockGpu.h" - -class GrMockBuffer : public GrBuffer { -public: - GrMockBuffer(GrMockGpu* gpu, size_t sizeInBytes, GrBufferType type, - GrAccessPattern accessPattern) - : INHERITED(gpu, sizeInBytes, type, accessPattern) { - this->registerWithCache(SkBudgeted::kYes); - } - -private: - void onMap() override {} - void onUnmap() override {} - bool onUpdateData(const void* src, size_t srcSizeInBytes) override { return true; } - - typedef GrBuffer INHERITED; -}; - -#endif diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h deleted file mode 100644 index 7190ad7d61..0000000000 --- a/src/gpu/mock/GrMockCaps.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrMockCaps_DEFINED -#define GrMockCaps_DEFINED - -#include "GrCaps.h" -#include "mock/GrMockOptions.h" - -class GrMockCaps : public GrCaps { -public: - GrMockCaps(const GrContextOptions& contextOptions, const GrMockOptions& options) - : INHERITED(contextOptions), fOptions(options) { - fBufferMapThreshold = SK_MaxS32; - fMaxTextureSize = options.fMaxTextureSize; - fMaxRenderTargetSize = SkTMin(options.fMaxRenderTargetSize, fMaxTextureSize); - fMaxVertexAttributes = options.fMaxVertexAttributes; - fShaderCaps.reset(new GrShaderCaps(contextOptions)); - } - bool isConfigTexturable(GrPixelConfig config) const override { - return fOptions.fConfigOptions[config].fTexturable; - } - bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { - return fOptions.fConfigOptions[config].fRenderable[withMSAA]; - } - bool canConfigBeImageStorage(GrPixelConfig) const override { return false; } - bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, - bool* rectsMustMatch, bool* disallowSubrect) const override { - return false; - } - -private: - GrMockOptions fOptions; - typedef GrCaps INHERITED; -}; - -#endif diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp deleted file mode 100644 index 70568e6ac3..0000000000 --- a/src/gpu/mock/GrMockGpu.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "GrMockGpu.h" -#include "GrMockBuffer.h" -#include "GrMockCaps.h" -#include "GrMockGpuCommandBuffer.h" -#include "GrMockStencilAttachment.h" -#include "GrMockTexture.h" - -GrGpu* GrMockGpu::Create(GrBackendContext backendContext, const GrContextOptions& contextOptions, - GrContext* context) { - static const GrMockOptions kDefaultOptions = GrMockOptions(); - const GrMockOptions* options = reinterpret_cast<const GrMockOptions*>(backendContext); - if (!options) { - options = &kDefaultOptions; - } - return new GrMockGpu(context, *options, contextOptions); -} - -GrGpuCommandBuffer* GrMockGpu::createCommandBuffer(const GrGpuCommandBuffer::LoadAndStoreInfo&, - const GrGpuCommandBuffer::LoadAndStoreInfo&) { - return new GrMockGpuCommandBuffer(this); -} - -void GrMockGpu::submitCommandBuffer(const GrMockGpuCommandBuffer* cmdBuffer) { - for (int i = 0; i < cmdBuffer->numDraws(); ++i) { - fStats.incNumDraws(); - } -} - -GrMockGpu::GrMockGpu(GrContext* context, const GrMockOptions& options, - const GrContextOptions& contextOptions) - : INHERITED(context) { - fCaps.reset(new GrMockCaps(contextOptions, options)); -} - -sk_sp<GrTexture> GrMockGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, - const SkTArray<GrMipLevel>& texels) { - bool hasMipLevels = texels.count() > 1; - if (desc.fFlags & kRenderTarget_GrSurfaceFlag) { - return sk_sp<GrTexture>(new GrMockTextureRenderTarget(this, budgeted, desc, hasMipLevels)); - } - return sk_sp<GrTexture>(new GrMockTexture(this, budgeted, desc, hasMipLevels)); -} - -GrBuffer* GrMockGpu::onCreateBuffer(size_t sizeInBytes, GrBufferType type, - GrAccessPattern accessPattern, const void*) { - return new GrMockBuffer(this, sizeInBytes, type, accessPattern); -} - -GrStencilAttachment* GrMockGpu::createStencilAttachmentForRenderTarget(const GrRenderTarget* rt, - int width, - int height) { - static constexpr int kBits = 8; - fStats.incStencilAttachmentCreates(); - return new GrMockStencilAttachment(this, width, height, kBits, rt->numColorSamples()); -} diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h index d54158ba1f..e5d97ce700 100644 --- a/src/gpu/mock/GrMockGpu.h +++ b/src/gpu/mock/GrMockGpu.h @@ -4,36 +4,55 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - #ifndef GrMockGpu_DEFINED #define GrMockGpu_DEFINED +#include "GrCaps.h" #include "GrGpu.h" #include "GrSemaphore.h" #include "GrTexture.h" -class GrMockGpuCommandBuffer; -struct GrMockOptions; class GrPipeline; +class GrMockCaps : public GrCaps { +public: + explicit GrMockCaps(const GrContextOptions& options) : INHERITED(options) { + fBufferMapThreshold = SK_MaxS32; + } + bool isConfigTexturable(GrPixelConfig) const override { return false; } + bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { return false; } + bool canConfigBeImageStorage(GrPixelConfig) const override { return false; } + bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, + bool* rectsMustMatch, bool* disallowSubrect) const override { + return false; + } + +private: + typedef GrCaps INHERITED; +}; + class GrMockGpu : public GrGpu { public: - static GrGpu* Create(GrBackendContext, const GrContextOptions&, GrContext*); + static GrGpu* Create(GrBackendContext backendContext, const GrContextOptions& options, + GrContext* context) { + SkASSERT((void*)backendContext == nullptr); + return new GrMockGpu(context, options); + } ~GrMockGpu() override {} bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, size_t rowBytes, GrPixelConfig readConfig, DrawPreference*, - ReadPixelTempDrawInfo*) override { return true; } + ReadPixelTempDrawInfo*) override { return false; } bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, GrPixelConfig srcConfig, DrawPreference*, - WritePixelTempDrawInfo*) override { return true; } + WritePixelTempDrawInfo*) override { return false; } bool onCopySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, - const SkIPoint& dstPoint) override { return true; } + const SkIPoint& dstPoint) override { return false; } void onQueryMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings&, int* effectiveSampleCnt, SamplePattern*) override { @@ -41,7 +60,9 @@ public: } GrGpuCommandBuffer* createCommandBuffer(const GrGpuCommandBuffer::LoadAndStoreInfo&, - const GrGpuCommandBuffer::LoadAndStoreInfo&) override; + const GrGpuCommandBuffer::LoadAndStoreInfo&) override { + return nullptr; + } GrFence SK_WARN_UNUSED_RESULT insertFence() override { return 0; } bool waitFence(GrFence, uint64_t) override { return true; } @@ -56,17 +77,19 @@ public: void waitSemaphore(sk_sp<GrSemaphore> semaphore) override {} sk_sp<GrSemaphore> prepareTextureForCrossContextUsage(GrTexture*) override { return nullptr; } - void submitCommandBuffer(const GrMockGpuCommandBuffer*); - private: - GrMockGpu(GrContext* context, const GrMockOptions&, const GrContextOptions&); + GrMockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(context) { + fCaps.reset(new GrMockCaps(options)); + } void onResetContext(uint32_t resetBits) override {} void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {} - sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&, SkBudgeted, - const SkTArray<GrMipLevel>&) override; + sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, + const SkTArray<GrMipLevel>& texels) override { + return nullptr; + } sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrSurfaceOrigin, @@ -87,8 +110,9 @@ private: return nullptr; } - GrBuffer* onCreateBuffer(size_t sizeInBytes, GrBufferType, GrAccessPattern, - const void*) override; + GrBuffer* onCreateBuffer(size_t, GrBufferType, GrAccessPattern, const void*) override { + return nullptr; + } gr_instanced::InstancedRendering* onCreateInstancedRendering() override { return nullptr; } @@ -97,27 +121,30 @@ private: GrPixelConfig, void* buffer, size_t rowBytes) override { - return true; + return false; } bool onWritePixels(GrSurface* surface, int left, int top, int width, int height, GrPixelConfig config, const SkTArray<GrMipLevel>& texels) override { - return true; + return false; } bool onTransferPixels(GrTexture* texture, int left, int top, int width, int height, GrPixelConfig config, GrBuffer* transferBuffer, size_t offset, size_t rowBytes) override { - return true; + return false; } void onResolveRenderTarget(GrRenderTarget* target) override { return; } GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*, int width, - int height) override; + int height) override { + return nullptr; + } + void clearStencil(GrRenderTarget* target) override {} GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h, @@ -129,5 +156,4 @@ private: typedef GrGpu INHERITED; }; - -#endif +#endif // GrMockGpu_DEFINED diff --git a/src/gpu/mock/GrMockGpuCommandBuffer.h b/src/gpu/mock/GrMockGpuCommandBuffer.h deleted file mode 100644 index c5719a5170..0000000000 --- a/src/gpu/mock/GrMockGpuCommandBuffer.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrMockGpuCommandBuffer_DEFINED -#define GrMockGpuCommandBuffer_DEFINED - -#include "GrGpuCommandBuffer.h" -#include "GrMockGpu.h" - -class GrMockGpuCommandBuffer : public GrGpuCommandBuffer { -public: - GrMockGpuCommandBuffer(GrMockGpu* gpu) : fGpu(gpu) {} - - GrGpu* gpu() override { return fGpu; } - void inlineUpload(GrOpFlushState*, GrDrawOp::DeferredUploadFn&, GrRenderTarget*) override {} - void discard(GrRenderTarget*) override {} - void end() override {} - - int numDraws() const { return fNumDraws; } - -private: - void onSubmit() override { fGpu->submitCommandBuffer(this); } - void onDraw(const GrPipeline&, const GrPrimitiveProcessor&, const GrMesh[], - const GrPipeline::DynamicState[], int meshCount, const SkRect& bounds) override { - ++fNumDraws; - } - void onClear(GrRenderTarget*, const GrFixedClip&, GrColor) override {} - void onClearStencilClip(GrRenderTarget*, const GrFixedClip&, bool insideStencilMask) override {} - GrRenderTarget* renderTarget() override { return nullptr; } - - GrMockGpu* fGpu; - int fNumDraws = 0; - - typedef GrGpuCommandBuffer INHERITED; -}; - -#endif diff --git a/src/gpu/mock/GrMockStencilAttachment.h b/src/gpu/mock/GrMockStencilAttachment.h deleted file mode 100644 index 697e44498d..0000000000 --- a/src/gpu/mock/GrMockStencilAttachment.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrMockStencilAttachment_DEFINED -#define GrMockStencilAttachment_DEFINED - -#include "GrMockGpu.h" -#include "GrStencilAttachment.h" - -class GrMockStencilAttachment : public GrStencilAttachment { -public: - GrMockStencilAttachment(GrMockGpu* gpu, int width, int height, int bits, int sampleCnt) - : INHERITED(gpu, width, height, bits, sampleCnt) { - this->registerWithCache(SkBudgeted::kYes); - } - -private: - size_t onGpuMemorySize() const override { - return SkTMax(1, (int)(this->bits() / sizeof(char))) * this->width() * this->height(); - } - - typedef GrStencilAttachment INHERITED; -}; - -#endif diff --git a/src/gpu/mock/GrMockTexture.h b/src/gpu/mock/GrMockTexture.h deleted file mode 100644 index 41474c27f0..0000000000 --- a/src/gpu/mock/GrMockTexture.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2017 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#ifndef GrMockTexture_DEFINED -#define GrMockTexture_DEFINED - -#include "GrMockGpu.h" -#include "GrTexture.h" -#include "GrTexturePriv.h" - -class GrMockTexture : public GrTexture { -public: - GrMockTexture(GrMockGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc, bool hasMipLevels) - : GrMockTexture(gpu, desc, hasMipLevels) { - this->registerWithCache(budgeted); - } - ~GrMockTexture() override { - if (fReleaseProc) { - fReleaseProc(fReleaseCtx); - } - } - GrBackendObject getTextureHandle() const override { return 0; } - void textureParamsModified() override {} - void setRelease(ReleaseProc proc, ReleaseCtx ctx) override { - fReleaseProc = proc; - fReleaseCtx = ctx; - } - -protected: - // constructor for subclasses - GrMockTexture(GrMockGpu* gpu, const GrSurfaceDesc& desc, bool hasMipLevels) - : GrSurface(gpu, desc) - , INHERITED(gpu, desc, kITexture2DSampler_GrSLType, GrSamplerParams::kMipMap_FilterMode, - hasMipLevels) - , fReleaseProc(nullptr) - , fReleaseCtx(nullptr) {} - -private: - ReleaseProc fReleaseProc; - ReleaseCtx fReleaseCtx; - - typedef GrTexture INHERITED; -}; - -class GrMockTextureRenderTarget : public GrMockTexture, public GrRenderTarget { -public: - GrMockTextureRenderTarget(GrMockGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc, - bool hasMipLevels) - : GrSurface(gpu, desc) - , GrMockTexture(gpu, desc, hasMipLevels) - , GrRenderTarget(gpu, desc) { - this->registerWithCache(budgeted); - } - ResolveType getResolveType() const override { return kCanResolve_ResolveType; } - GrBackendObject getRenderTargetHandle() const override { return 0; } - bool canAttemptStencilAttachment() const override { return true; } - bool completeStencilAttachment() override { return true; } - GrTexture* asTexture() override { return this; } - GrRenderTarget* asRenderTarget() override { return this; } - const GrTexture* asTexture() const override { return this; } - const GrRenderTarget* asRenderTarget() const override { return this; } - -private: - void onAbandon() override { - GrRenderTarget::onAbandon(); - GrMockTexture::onAbandon(); - } - - void onRelease() override { - GrRenderTarget::onRelease(); - GrMockTexture::onRelease(); - } - - size_t onGpuMemorySize() const override { - return GrSurface::ComputeSize(this->config(), this->width(), this->height(), - this->numStencilSamples(), - this->texturePriv().hasMipMaps()); - } - - void computeScratchKey(GrScratchKey* key) const override { - GrTexturePriv::ComputeScratchKey(this->config(), this->width(), this->height(), - this->origin(), true, this->numStencilSamples(), - this->texturePriv().hasMipMaps(), key); - } -}; - -#endif |