content/canvas/src/WebGLBuffer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/src/WebGLBuffer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef WEBGLBUFFER_H_
    1.10 +#define WEBGLBUFFER_H_
    1.11 +
    1.12 +#include "GLDefs.h"
    1.13 +#include "mozilla/LinkedList.h"
    1.14 +#include "mozilla/MemoryReporting.h"
    1.15 +#include "nsWrapperCache.h"
    1.16 +#include "WebGLObjectModel.h"
    1.17 +#include "WebGLTypes.h"
    1.18 +
    1.19 +namespace mozilla {
    1.20 +
    1.21 +class WebGLElementArrayCache;
    1.22 +
    1.23 +class WebGLBuffer MOZ_FINAL
    1.24 +    : public nsWrapperCache
    1.25 +    , public WebGLRefCountedObject<WebGLBuffer>
    1.26 +    , public LinkedListElement<WebGLBuffer>
    1.27 +    , public WebGLContextBoundObject
    1.28 +{
    1.29 +public:
    1.30 +    WebGLBuffer(WebGLContext *context);
    1.31 +
    1.32 +    ~WebGLBuffer();
    1.33 +
    1.34 +    void Delete();
    1.35 +
    1.36 +    size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
    1.37 +
    1.38 +    bool HasEverBeenBound() { return mHasEverBeenBound; }
    1.39 +    void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
    1.40 +    GLuint GLName() const { return mGLName; }
    1.41 +    WebGLsizeiptr ByteLength() const { return mByteLength; }
    1.42 +    GLenum Target() const { return mTarget; }
    1.43 +
    1.44 +    void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; }
    1.45 +
    1.46 +    void SetTarget(GLenum target);
    1.47 +
    1.48 +    bool ElementArrayCacheBufferData(const void* ptr, size_t buffer_size_in_bytes);
    1.49 +
    1.50 +    void ElementArrayCacheBufferSubData(size_t pos, const void* ptr, size_t update_size_in_bytes);
    1.51 +
    1.52 +    bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count,
    1.53 +                  uint32_t* out_upperBound);
    1.54 +
    1.55 +    WebGLContext *GetParentObject() const {
    1.56 +        return Context();
    1.57 +    }
    1.58 +
    1.59 +    virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
    1.60 +
    1.61 +    NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLBuffer)
    1.62 +    NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer)
    1.63 +
    1.64 +protected:
    1.65 +
    1.66 +    GLuint mGLName;
    1.67 +    bool mHasEverBeenBound;
    1.68 +    WebGLsizeiptr mByteLength;
    1.69 +    GLenum mTarget;
    1.70 +
    1.71 +    nsAutoPtr<WebGLElementArrayCache> mCache;
    1.72 +};
    1.73 +}
    1.74 +#endif //WEBGLBUFFER_H_

mercurial