Flutter Engine
The Flutter Engine
GrMockBuffer.h
Go to the documentation of this file.
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
18
19#include <cstddef>
20#include <string_view>
21
22class GrMockBuffer : public GrGpuBuffer {
23public:
24 GrMockBuffer(GrMockGpu* gpu, size_t sizeInBytes, GrGpuBufferType type,
26 std::string_view label)
27 : INHERITED(gpu, sizeInBytes, type, accessPattern, label) {
29 }
30
31private:
32 void onMap(MapType) override {
33 if (GrCaps::kNone_MapFlags != this->getGpu()->caps()->mapBufferFlags()) {
34 fMapPtr = sk_malloc_throw(this->size());
35 }
36 }
37 void onUnmap(MapType) override { sk_free(fMapPtr); }
38 bool onClearToZero() override { return true; }
39 bool onUpdateData(const void* src, size_t offset, size_t size, bool preserve) override {
40 return true;
41 }
42
43 using INHERITED = GrGpuBuffer;
44};
45
46#endif
GrGpuBufferType
Definition: GrTypesPriv.h:411
GrAccessPattern
Definition: GrTypesPriv.h:424
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
Definition: SkMalloc.h:67
GLenum type
@ kNone_MapFlags
Definition: GrCaps.h:197
size_t size() const final
Definition: GrGpuBuffer.h:34
GrGpuBuffer(GrGpu *, size_t sizeInBytes, GrGpuBufferType, GrAccessPattern, std::string_view label)
Definition: GrGpuBuffer.cpp:19
void * fMapPtr
Definition: GrGpuBuffer.h:119
GrAccessPattern accessPattern() const
Definition: GrGpuBuffer.h:32
GrGpu * getGpu() const
void registerWithCache(skgpu::Budgeted)
GrMockBuffer(GrMockGpu *gpu, size_t sizeInBytes, GrGpuBufferType type, GrAccessPattern accessPattern, std::string_view label)
Definition: GrMockBuffer.h:24
SeparatedVector2 offset