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/. */
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#ifndef WEBGL_BUFFER_H_
|
|
|
|
#define WEBGL_BUFFER_H_
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2013-06-11 00:00:35 +04:00
|
|
|
#include "GLDefs.h"
|
2012-11-21 01:38:20 +04:00
|
|
|
#include "mozilla/LinkedList.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2014-03-17 18:52:56 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
|
2014-03-17 18:52:56 +04:00
|
|
|
#include "WebGLObjectModel.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "WebGLTypes.h"
|
2012-11-21 01:38:20 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2013-06-11 00:00:35 +04:00
|
|
|
class WebGLElementArrayCache;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class WebGLBuffer final
|
2013-08-29 19:39:17 +04:00
|
|
|
: public nsWrapperCache
|
2012-11-21 01:38:20 +04:00
|
|
|
, public WebGLRefCountedObject<WebGLBuffer>
|
|
|
|
, public LinkedListElement<WebGLBuffer>
|
|
|
|
, public WebGLContextBoundObject
|
|
|
|
{
|
|
|
|
public:
|
2015-05-21 02:59:14 +03:00
|
|
|
|
|
|
|
enum class Kind {
|
|
|
|
Undefined,
|
|
|
|
ElementArray,
|
|
|
|
OtherData
|
|
|
|
};
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
explicit WebGLBuffer(WebGLContext* webgl, GLuint buf);
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2015-05-21 02:59:14 +03:00
|
|
|
void BindTo(GLenum target);
|
|
|
|
Kind Content() const { return mContent; }
|
|
|
|
|
2012-11-21 01:38:20 +04:00
|
|
|
void Delete();
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2013-09-04 16:14:35 +04:00
|
|
|
WebGLsizeiptr ByteLength() const { return mByteLength; }
|
|
|
|
void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; }
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ElementArrayCacheBufferData(const void* ptr, size_t bufferSizeInBytes);
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void ElementArrayCacheBufferSubData(size_t pos, const void* ptr,
|
|
|
|
size_t updateSizeInBytes);
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2014-03-17 18:52:56 +04:00
|
|
|
bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count,
|
2014-11-14 07:03:50 +03:00
|
|
|
uint32_t* const out_upperBound);
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2014-06-03 00:30:00 +04:00
|
|
|
bool IsElementArrayUsedWithMultipleTypes() const;
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext* GetParentObject() const {
|
2012-11-21 01:38:20 +04:00
|
|
|
return Context();
|
2015-01-16 02:40:39 +03:00
|
|
|
}
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
|
2012-11-21 01:38:20 +04:00
|
|
|
|
2015-05-22 08:49:30 +03:00
|
|
|
const GLenum mGLName;
|
|
|
|
|
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
|
|
|
|
2015-05-21 02:59:14 +03:00
|
|
|
Kind mContent;
|
2013-09-04 16:14:35 +04:00
|
|
|
WebGLsizeiptr mByteLength;
|
2012-11-21 01:38:20 +04:00
|
|
|
nsAutoPtr<WebGLElementArrayCache> mCache;
|
|
|
|
};
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // WEBGL_BUFFER_H_
|