aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/mock/GrMockBuffer.h
blob: fa3e712c6df2abeca21b5dcfb9e0bd5ec4286859 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * 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 "GrCaps.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 {
        if (GrCaps::kNone_MapFlags != this->getGpu()->caps()->mapBufferFlags()) {
            fMapPtr = sk_malloc_throw(this->sizeInBytes());
        }
    }
    void onUnmap() override { sk_free(fMapPtr); }
    bool onUpdateData(const void* src, size_t srcSizeInBytes) override { return true; }

    typedef GrBuffer INHERITED;
};

#endif