2012-11-20 13:38:20 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef WEBGLBUFFER_H_
|
|
|
|
#define WEBGLBUFFER_H_
|
|
|
|
|
2013-06-10 13:00:35 -07:00
|
|
|
#include "GLDefs.h"
|
2012-11-20 13:38:20 -08:00
|
|
|
#include "mozilla/LinkedList.h"
|
2013-06-23 05:03:39 -07:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2014-03-17 07:52:56 -07:00
|
|
|
#include "nsWrapperCache.h"
|
2014-05-06 20:11:18 -07:00
|
|
|
#include "WebGLBindableName.h"
|
2014-03-17 07:52:56 -07:00
|
|
|
#include "WebGLObjectModel.h"
|
|
|
|
#include "WebGLTypes.h"
|
2014-09-26 13:11:51 -07:00
|
|
|
#include "WebGLStrongTypes.h"
|
2012-11-20 13:38:20 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2013-06-10 13:00:35 -07:00
|
|
|
class WebGLElementArrayCache;
|
|
|
|
|
2012-11-20 13:38:20 -08:00
|
|
|
class WebGLBuffer MOZ_FINAL
|
2013-08-29 08:39:17 -07:00
|
|
|
: public nsWrapperCache
|
2014-09-26 13:11:51 -07:00
|
|
|
, public WebGLBindableName<BufferBinding>
|
2012-11-20 13:38:20 -08:00
|
|
|
, public WebGLRefCountedObject<WebGLBuffer>
|
|
|
|
, public LinkedListElement<WebGLBuffer>
|
|
|
|
, public WebGLContextBoundObject
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 15:26:43 -07:00
|
|
|
explicit WebGLBuffer(WebGLContext* aContext);
|
2012-11-20 13:38:20 -08:00
|
|
|
|
|
|
|
void Delete();
|
|
|
|
|
2014-03-17 07:52:56 -07:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2013-09-04 05:14:35 -07:00
|
|
|
WebGLsizeiptr ByteLength() const { return mByteLength; }
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2013-09-04 05:14:35 -07:00
|
|
|
void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; }
|
2012-11-20 13:38:20 -08:00
|
|
|
|
|
|
|
bool ElementArrayCacheBufferData(const void* ptr, size_t buffer_size_in_bytes);
|
|
|
|
|
|
|
|
void ElementArrayCacheBufferSubData(size_t pos, const void* ptr, size_t update_size_in_bytes);
|
|
|
|
|
2014-03-17 07:52:56 -07:00
|
|
|
bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count,
|
|
|
|
uint32_t* out_upperBound);
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2014-06-02 13:30:00 -07:00
|
|
|
bool IsElementArrayUsedWithMultipleTypes() const;
|
|
|
|
|
2012-11-20 13:38:20 -08:00
|
|
|
WebGLContext *GetParentObject() const {
|
|
|
|
return Context();
|
|
|
|
}
|
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2013-08-29 08:39:17 -07:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLBuffer)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer)
|
2012-11-20 13:38:20 -08:00
|
|
|
|
|
|
|
protected:
|
2014-06-26 06:30:49 -07:00
|
|
|
~WebGLBuffer();
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2014-05-06 20:11:18 -07:00
|
|
|
virtual void OnTargetChanged() MOZ_OVERRIDE;
|
|
|
|
|
2013-09-04 05:14:35 -07:00
|
|
|
WebGLsizeiptr mByteLength;
|
2012-11-20 13:38:20 -08:00
|
|
|
|
|
|
|
nsAutoPtr<WebGLElementArrayCache> mCache;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif //WEBGLBUFFER_H_
|