gfx/angle/src/libGLESv2/renderer/IndexBuffer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/angle/src/libGLESv2/renderer/IndexBuffer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,111 @@
     1.4 +//
     1.5 +// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
     1.6 +// Use of this source code is governed by a BSD-style license that can be
     1.7 +// found in the LICENSE file.
     1.8 +//
     1.9 +
    1.10 +// IndexBuffer.h: Defines the abstract IndexBuffer class and IndexBufferInterface
    1.11 +// class with derivations, classes that perform graphics API agnostic index buffer operations.
    1.12 +
    1.13 +#ifndef LIBGLESV2_RENDERER_INDEXBUFFER_H_
    1.14 +#define LIBGLESV2_RENDERER_INDEXBUFFER_H_
    1.15 +
    1.16 +#include "common/angleutils.h"
    1.17 +#include "libGLESv2/renderer/IndexRangeCache.h"
    1.18 +
    1.19 +namespace rx
    1.20 +{
    1.21 +class Renderer;
    1.22 +
    1.23 +class IndexBuffer
    1.24 +{
    1.25 +  public:
    1.26 +    IndexBuffer();
    1.27 +    virtual ~IndexBuffer();
    1.28 +
    1.29 +    virtual bool initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) = 0;
    1.30 +
    1.31 +    virtual bool mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) = 0;
    1.32 +    virtual bool unmapBuffer() = 0;
    1.33 +
    1.34 +    virtual bool discard() = 0;
    1.35 +
    1.36 +    virtual GLenum getIndexType() const = 0;
    1.37 +    virtual unsigned int getBufferSize() const = 0;
    1.38 +    virtual bool setSize(unsigned int bufferSize, GLenum indexType) = 0;
    1.39 +
    1.40 +    unsigned int getSerial() const;
    1.41 +
    1.42 +  protected:
    1.43 +    void updateSerial();
    1.44 +
    1.45 +  private:
    1.46 +    DISALLOW_COPY_AND_ASSIGN(IndexBuffer);
    1.47 +
    1.48 +    unsigned int mSerial;
    1.49 +    static unsigned int mNextSerial;
    1.50 +};
    1.51 +
    1.52 +class IndexBufferInterface
    1.53 +{
    1.54 +  public:
    1.55 +    IndexBufferInterface(Renderer *renderer, bool dynamic);
    1.56 +    virtual ~IndexBufferInterface();
    1.57 +
    1.58 +    virtual bool reserveBufferSpace(unsigned int size, GLenum indexType) = 0;
    1.59 +
    1.60 +    GLenum getIndexType() const;
    1.61 +    unsigned int getBufferSize() const;
    1.62 +
    1.63 +    unsigned int getSerial() const;
    1.64 +
    1.65 +    bool mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset);
    1.66 +    bool unmapBuffer();
    1.67 +
    1.68 +    IndexBuffer *getIndexBuffer() const;
    1.69 +
    1.70 +  protected:
    1.71 +    unsigned int getWritePosition() const;
    1.72 +    void setWritePosition(unsigned int writePosition);
    1.73 +
    1.74 +    bool discard();
    1.75 +
    1.76 +    bool setBufferSize(unsigned int bufferSize, GLenum indexType);
    1.77 +
    1.78 +  private:
    1.79 +    DISALLOW_COPY_AND_ASSIGN(IndexBufferInterface);
    1.80 +
    1.81 +    rx::Renderer *const mRenderer;
    1.82 +
    1.83 +    IndexBuffer* mIndexBuffer;
    1.84 +
    1.85 +    unsigned int mWritePosition;
    1.86 +    bool mDynamic;
    1.87 +};
    1.88 +
    1.89 +class StreamingIndexBufferInterface : public IndexBufferInterface
    1.90 +{
    1.91 +  public:
    1.92 +    StreamingIndexBufferInterface(Renderer *renderer);
    1.93 +    ~StreamingIndexBufferInterface();
    1.94 +
    1.95 +    virtual bool reserveBufferSpace(unsigned int size, GLenum indexType);
    1.96 +};
    1.97 +
    1.98 +class StaticIndexBufferInterface : public IndexBufferInterface
    1.99 +{
   1.100 +  public:
   1.101 +    explicit StaticIndexBufferInterface(Renderer *renderer);
   1.102 +    ~StaticIndexBufferInterface();
   1.103 +
   1.104 +    virtual bool reserveBufferSpace(unsigned int size, GLenum indexType);
   1.105 +
   1.106 +    IndexRangeCache *getIndexRangeCache();
   1.107 +
   1.108 +  private:
   1.109 +    IndexRangeCache mIndexRangeCache;
   1.110 +};
   1.111 +
   1.112 +}
   1.113 +
   1.114 +#endif // LIBGLESV2_RENDERER_INDEXBUFFER_H_
   1.115 \ No newline at end of file

mercurial