summaryrefslogtreecommitdiff
path: root/gpu/gl/GrGLVertexBuffer.cpp
blob: 8bfe1f0c96341dfd9628db6619eefc1f07c19482 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "GrGLVertexBuffer.h"
#include "GrGpuGL.h"

GrGLVertexBuffer::GrGLVertexBuffer(GrGpuGL* gpu, const Desc& desc)
    : INHERITED(gpu, desc.fIsWrapped, desc.fSizeInBytes, desc.fDynamic, 0 == desc.fID)
    , fImpl(gpu, desc, GR_GL_ARRAY_BUFFER) {
}

void GrGLVertexBuffer::onRelease() {
    if (!this->wasDestroyed()) {
        fImpl.release(this->getGpuGL());
    }

    INHERITED::onRelease();
}


void GrGLVertexBuffer::onAbandon() {
    fImpl.abandon();
    INHERITED::onAbandon();
}

void* GrGLVertexBuffer::lock() {
    if (!this->wasDestroyed()) {
        return fImpl.lock(this->getGpuGL());
    } else {
        return NULL;
    }
}

void* GrGLVertexBuffer::lockPtr() const {
    return fImpl.lockPtr();
}

void GrGLVertexBuffer::unlock() {
    if (!this->wasDestroyed()) {
        fImpl.unlock(this->getGpuGL());
    }
}

bool GrGLVertexBuffer::isLocked() const {
    return fImpl.isLocked();
}

bool GrGLVertexBuffer::updateData(const void* src, size_t srcSizeInBytes) {
    if (!this->wasDestroyed()) {
        return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes);
    } else {
        return false;
    }
}