blob: b6290b1826b222da016ab629aa392d91c47f2fb6 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2011 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.
reed@google.comac10a2d2010-12-22 21:39:39 +00006 */
7
reed@google.comac10a2d2010-12-22 21:39:39 +00008#include "GrGLIndexBuffer.h"
9#include "GrGpuGL.h"
10
bsalomon@google.come49ad452013-02-20 19:33:20 +000011GrGLIndexBuffer::GrGLIndexBuffer(GrGpuGL* gpu, const Desc& desc)
bsalomon@google.comee3bc3b2013-02-21 14:33:46 +000012 : INHERITED(gpu, desc.fIsWrapped, desc.fSizeInBytes, desc.fDynamic, 0 == desc.fID)
bsalomon@google.come49ad452013-02-20 19:33:20 +000013 , fImpl(gpu, desc, GR_GL_ELEMENT_ARRAY_BUFFER) {
reed@google.comac10a2d2010-12-22 21:39:39 +000014}
15
bsalomon@google.com8fe72472011-03-30 21:26:44 +000016void GrGLIndexBuffer::onRelease() {
bsalomon@google.come49ad452013-02-20 19:33:20 +000017 if (this->isValid()) {
18 fImpl.release(this->getGpuGL());
reed@google.comac10a2d2010-12-22 21:39:39 +000019 }
robertphillips@google.comd3645542012-09-05 18:37:39 +000020
21 INHERITED::onRelease();
reed@google.comac10a2d2010-12-22 21:39:39 +000022}
23
bsalomon@google.com8fe72472011-03-30 21:26:44 +000024void GrGLIndexBuffer::onAbandon() {
bsalomon@google.come49ad452013-02-20 19:33:20 +000025 fImpl.abandon();
robertphillips@google.comd3645542012-09-05 18:37:39 +000026 INHERITED::onAbandon();
bsalomon@google.com8fe72472011-03-30 21:26:44 +000027}
28
reed@google.comac10a2d2010-12-22 21:39:39 +000029void* GrGLIndexBuffer::lock() {
bsalomon@google.come49ad452013-02-20 19:33:20 +000030 if (this->isValid()) {
31 return fImpl.lock(this->getGpuGL());
32 } else {
33 return NULL;
reed@google.comac10a2d2010-12-22 21:39:39 +000034 }
reed@google.comac10a2d2010-12-22 21:39:39 +000035}
36
bsalomon@google.com1c13c962011-02-14 16:51:21 +000037void* GrGLIndexBuffer::lockPtr() const {
bsalomon@google.come49ad452013-02-20 19:33:20 +000038 return fImpl.lockPtr();
bsalomon@google.com1c13c962011-02-14 16:51:21 +000039}
40
reed@google.comac10a2d2010-12-22 21:39:39 +000041void GrGLIndexBuffer::unlock() {
bsalomon@google.come49ad452013-02-20 19:33:20 +000042 if (this->isValid()) {
43 fImpl.unlock(this->getGpuGL());
44 }
reed@google.comac10a2d2010-12-22 21:39:39 +000045}
46
47bool GrGLIndexBuffer::isLocked() const {
bsalomon@google.come49ad452013-02-20 19:33:20 +000048 return fImpl.isLocked();
reed@google.comac10a2d2010-12-22 21:39:39 +000049}
50
bsalomon@google.com1c13c962011-02-14 16:51:21 +000051bool GrGLIndexBuffer::updateData(const void* src, size_t srcSizeInBytes) {
bsalomon@google.come49ad452013-02-20 19:33:20 +000052 if (this->isValid()) {
53 return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes);
54 } else {
reed@google.comac10a2d2010-12-22 21:39:39 +000055 return false;
56 }
reed@google.comac10a2d2010-12-22 21:39:39 +000057}