2012-11-21 01:38:20 +04: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-11 00:00:35 +04:00
|
|
|
#include "GLDefs.h"
|
2012-11-21 01:38:20 +04:00
|
|
|
#include "mozilla/LinkedList.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2014-03-17 18:52:56 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2014-05-07 07:11:18 +04:00
|
|
|
#include "WebGLBindableName.h"
|
2014-03-17 18:52:56 +04:00
|
|
|
#include "WebGLObjectModel.h"
|
|
|
|
#include "WebGLTypes.h"
|
2012-11-21 01:38:20 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2013-06-11 00:00:35 +04:00
|
|
|
class WebGLElementArrayCache;
|
|
|
|
|
2012-11-21 01:38:20 +04:00
|
|
|
class WebGLBuffer MOZ_FINAL
|
2013-08-29 19:39:17 +04:00
|
|
|
: public nsWrapperCache
|
2014-09-19 03:14:22 +04:00
|
|
|
, public WebGLBindableName<GLenum>
|
2012-11-21 01:38:20 +04:00
|
|
|
, public WebGLRefCountedObject<WebGLBuffer>
|
|
|
|
, public LinkedListElement<WebGLBuffer>
|
|
|
|
, public WebGLContextBoundObject
|
|
|
|
{
|
|
|
|
public:
|
2014-09-02 02:26:43 +04:00
|
|
|
explicit WebGLBuffer(WebGLContext* aContext);
|
2012-11-21 01:38:20 +04:00
|
|
|
|
|
|
|
void Delete();
|
|
|
|
|
2014-03-17 18:52:56 +04:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2013-09-04 16:14:35 +04:00
|
|
|
WebGLsizeiptr ByteLength() const { return mByteLength; }
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2013-09-04 16:14:35 +04:00
|
|
|
void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; }
|
2012-11-21 01:38:20 +04: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 18:52:56 +04:00
|
|
|
bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count,
|
|
|
|
uint32_t* out_upperBound);
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2014-06-03 00:30:00 +04:00
|
|
|
bool IsElementArrayUsedWithMultipleTypes() const;
|
|
|
|
|
2012-11-21 01:38:20 +04:00
|
|
|
WebGLContext *GetParentObject() const {
|
|
|
|
return Context();
|
|
|
|
}
|
|
|
|
|
2014-04-09 02:27:18 +04:00
|
|
|
virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2013-08-29 19:39:17 +04:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLBuffer)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer)
|
2012-11-21 01:38:20 +04:00
|
|
|
|
|
|
|
protected:
|
2014-06-26 17:30:49 +04:00
|
|
|
~WebGLBuffer();
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2014-05-07 07:11:18 +04:00
|
|
|
virtual void OnTargetChanged() MOZ_OVERRIDE;
|
|
|
|
|
2013-09-04 16:14:35 +04:00
|
|
|
WebGLsizeiptr mByteLength;
|
2012-11-21 01:38:20 +04:00
|
|
|
|
|
|
|
nsAutoPtr<WebGLElementArrayCache> mCache;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif //WEBGLBUFFER_H_
|