1/*
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
8#ifndef GrMockBuffer_DEFINED
9#define GrMockBuffer_DEFINED
10
11#include "src/gpu/GrCaps.h"
12#include "src/gpu/GrGpuBuffer.h"
13#include "src/gpu/mock/GrMockGpu.h"
14
15class GrMockBuffer : public GrGpuBuffer {
16public:
17 GrMockBuffer(GrMockGpu* gpu, size_t sizeInBytes, GrGpuBufferType type,
18 GrAccessPattern accessPattern)
19 : INHERITED(gpu, sizeInBytes, type, accessPattern) {
20 this->registerWithCache(SkBudgeted::kYes);
21 }
22
23private:
24 void onMap() override {
25 if (GrCaps::kNone_MapFlags != this->getGpu()->caps()->mapBufferFlags()) {
26 fMapPtr = sk_malloc_throw(this->size());
27 }
28 }
29 void onUnmap() override { sk_free(fMapPtr); }
30 bool onUpdateData(const void* src, size_t srcSizeInBytes) override { return true; }
31
32 typedef GrGpuBuffer INHERITED;
33};
34
35#endif
36