gfx/skia/trunk/src/gpu/GrGeometryBuffer.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2011 Google Inc.
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef GrGeometryBuffer_DEFINED
michael@0 11 #define GrGeometryBuffer_DEFINED
michael@0 12
michael@0 13 #include "GrResource.h"
michael@0 14
michael@0 15 class GrGpu;
michael@0 16
michael@0 17 /**
michael@0 18 * Parent class for vertex and index buffers
michael@0 19 */
michael@0 20 class GrGeometryBuffer : public GrResource {
michael@0 21 public:
michael@0 22 SK_DECLARE_INST_COUNT(GrGeometryBuffer);
michael@0 23
michael@0 24 /**
michael@0 25 *Retrieves whether the buffer was created with the dynamic flag
michael@0 26 *
michael@0 27 * @return true if the buffer was created with the dynamic flag
michael@0 28 */
michael@0 29 bool dynamic() const { return fDynamic; }
michael@0 30
michael@0 31 /**
michael@0 32 * Returns true if the buffer is a wrapper around a CPU array. If true it
michael@0 33 * indicates that lock will always succeed and will be free.
michael@0 34 */
michael@0 35 bool isCPUBacked() const { return fCPUBacked; }
michael@0 36
michael@0 37 /**
michael@0 38 * Locks the buffer to be written by the CPU.
michael@0 39 *
michael@0 40 * The previous content of the buffer is invalidated. It is an error
michael@0 41 * to draw from the buffer while it is locked. It is an error to call lock
michael@0 42 * on an already locked buffer. It may fail if the backend doesn't support
michael@0 43 * locking the buffer. If the buffer is CPU backed then it will always
michael@0 44 * succeed and is a free operation. Must be matched by an unlock() call.
michael@0 45 * Currently only one lock at a time is supported (no nesting of
michael@0 46 * lock/unlock).
michael@0 47 *
michael@0 48 * @return a pointer to the data or NULL if the lock fails.
michael@0 49 */
michael@0 50 virtual void* lock() = 0;
michael@0 51
michael@0 52 /**
michael@0 53 * Returns the same ptr that lock() returned at time of lock or NULL if the
michael@0 54 * is not locked.
michael@0 55 *
michael@0 56 * @return ptr to locked buffer data or undefined if buffer is not locked.
michael@0 57 */
michael@0 58 virtual void* lockPtr() const = 0;
michael@0 59
michael@0 60 /**
michael@0 61 * Unlocks the buffer.
michael@0 62 *
michael@0 63 * The pointer returned by the previous lock call will no longer be valid.
michael@0 64 */
michael@0 65 virtual void unlock() = 0;
michael@0 66
michael@0 67 /**
michael@0 68 Queries whether the buffer has been locked.
michael@0 69
michael@0 70 @return true if the buffer is locked, false otherwise.
michael@0 71 */
michael@0 72 virtual bool isLocked() const = 0;
michael@0 73
michael@0 74 /**
michael@0 75 * Updates the buffer data.
michael@0 76 *
michael@0 77 * The size of the buffer will be preserved. The src data will be
michael@0 78 * placed at the beginning of the buffer and any remaining contents will
michael@0 79 * be undefined.
michael@0 80 *
michael@0 81 * @return returns true if the update succeeds, false otherwise.
michael@0 82 */
michael@0 83 virtual bool updateData(const void* src, size_t srcSizeInBytes) = 0;
michael@0 84
michael@0 85 // GrResource overrides
michael@0 86 virtual size_t sizeInBytes() const { return fSizeInBytes; }
michael@0 87
michael@0 88 protected:
michael@0 89 GrGeometryBuffer(GrGpu* gpu, bool isWrapped, size_t sizeInBytes, bool dynamic, bool cpuBacked)
michael@0 90 : INHERITED(gpu, isWrapped)
michael@0 91 , fSizeInBytes(sizeInBytes)
michael@0 92 , fDynamic(dynamic)
michael@0 93 , fCPUBacked(cpuBacked) {}
michael@0 94
michael@0 95 private:
michael@0 96 size_t fSizeInBytes;
michael@0 97 bool fDynamic;
michael@0 98 bool fCPUBacked;
michael@0 99
michael@0 100 typedef GrResource INHERITED;
michael@0 101 };
michael@0 102
michael@0 103 #endif

mercurial