aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/mock
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/mock')
-rw-r--r--src/gpu/mock/GrMockGpu.h154
1 files changed, 154 insertions, 0 deletions
diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h
new file mode 100644
index 0000000000..eb0a74a7f3
--- /dev/null
+++ b/src/gpu/mock/GrMockGpu.h
@@ -0,0 +1,154 @@
+/*
+ * 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 "GrGpu.h"
+#include "GrSemaphore.h"
+
+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 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 false; }
+
+ bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height,
+ GrPixelConfig srcConfig, DrawPreference*,
+ WritePixelTempDrawInfo*) override { return false; }
+
+ bool onCopySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint) override { return false; }
+
+ void onQueryMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings&,
+ int* effectiveSampleCnt, SamplePattern*) override {
+ *effectiveSampleCnt = rt->numStencilSamples();
+ }
+
+ GrGpuCommandBuffer* createCommandBuffer(const GrGpuCommandBuffer::LoadAndStoreInfo&,
+ const GrGpuCommandBuffer::LoadAndStoreInfo&) override {
+ return nullptr;
+ }
+
+ GrFence SK_WARN_UNUSED_RESULT insertFence() override { return 0; }
+ bool waitFence(GrFence, uint64_t) override { return true; }
+ void deleteFence(GrFence) const override {}
+
+ sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore(bool isOwned) override {
+ return nullptr;
+ }
+ sk_sp<GrSemaphore> wrapBackendSemaphore(const GrBackendSemaphore& semaphore,
+ GrWrapOwnership ownership) override { return nullptr; }
+ void insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) override {}
+ void waitSemaphore(sk_sp<GrSemaphore> semaphore) override {}
+ sk_sp<GrSemaphore> prepareTextureForCrossContextUsage(GrTexture*) override { return nullptr; }
+
+private:
+ 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& desc, SkBudgeted budgeted,
+ const SkTArray<GrMipLevel>& texels) override {
+ return nullptr;
+ }
+
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
+ GrSurfaceOrigin,
+ GrBackendTextureFlags,
+ int sampleCnt,
+ GrWrapOwnership) override {
+ return nullptr;
+ }
+
+ sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
+ GrSurfaceOrigin) override {
+ return nullptr;
+ }
+
+ sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
+ GrSurfaceOrigin,
+ int sampleCnt) override {
+ return nullptr;
+ }
+
+ GrBuffer* onCreateBuffer(size_t, GrBufferType, GrAccessPattern, const void*) override {
+ return nullptr;
+ }
+
+ gr_instanced::InstancedRendering* onCreateInstancedRendering() override { return nullptr; }
+
+ bool onReadPixels(GrSurface* surface,
+ int left, int top, int width, int height,
+ GrPixelConfig,
+ void* buffer,
+ size_t rowBytes) override {
+ return false;
+ }
+
+ bool onWritePixels(GrSurface* surface,
+ int left, int top, int width, int height,
+ GrPixelConfig config, const SkTArray<GrMipLevel>& texels) override {
+ 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 false;
+ }
+
+ void onResolveRenderTarget(GrRenderTarget* target) override { return; }
+
+ GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*,
+ int width,
+ int height) override {
+ return nullptr;
+ }
+
+ void clearStencil(GrRenderTarget* target) override {}
+
+ GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
+ GrPixelConfig config, bool isRT) override {
+ return 0;
+ }
+ bool isTestingOnlyBackendTexture(GrBackendObject ) const override { return false; }
+ void deleteTestingOnlyBackendTexture(GrBackendObject, bool abandonTexture) override {}
+
+ typedef GrGpu INHERITED;
+};