• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/ganesh/GrCaps.h"
12 #include "src/gpu/ganesh/GrGpuBuffer.h"
13 #include "src/gpu/ganesh/mock/GrMockGpu.h"
14 
15 class GrMockBuffer : public GrGpuBuffer {
16 public:
GrMockBuffer(GrMockGpu * gpu,size_t sizeInBytes,GrGpuBufferType type,GrAccessPattern accessPattern,std::string_view label)17     GrMockBuffer(GrMockGpu* gpu, size_t sizeInBytes, GrGpuBufferType type,
18                  GrAccessPattern accessPattern,
19                  std::string_view label)
20             : INHERITED(gpu, sizeInBytes, type, accessPattern, label) {
21         this->registerWithCache(skgpu::Budgeted::kYes);
22     }
23 
24 private:
onMap(MapType)25     void onMap(MapType) override {
26         if (GrCaps::kNone_MapFlags != this->getGpu()->caps()->mapBufferFlags()) {
27             fMapPtr = sk_malloc_throw(this->size());
28         }
29     }
onUnmap(MapType)30     void onUnmap(MapType) override { sk_free(fMapPtr); }
onClearToZero()31     bool onClearToZero() override { return true; }
onUpdateData(const void * src,size_t offset,size_t size,bool preserve)32     bool onUpdateData(const void* src, size_t offset, size_t size, bool preserve) override {
33         return true;
34     }
35 
36     using INHERITED = GrGpuBuffer;
37 };
38 
39 #endif
40