Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: src/gpu/gl/GrGLBufferImpl.h

Issue 1831133004: Revert of Consolidate GPU buffer implementations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLBuffer.cpp ('k') | src/gpu/gl/GrGLBufferImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLBufferImpl.h
diff --git a/src/gpu/gl/GrGLBufferImpl.h b/src/gpu/gl/GrGLBufferImpl.h
new file mode 100644
index 0000000000000000000000000000000000000000..a8f2cced372e6271e68fbba2c0373b2f3e28f9fd
--- /dev/null
+++ b/src/gpu/gl/GrGLBufferImpl.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLBufferImpl_DEFINED
+#define GrGLBufferImpl_DEFINED
+
+#include "SkTypes.h"
+#include "gl/GrGLTypes.h"
+
+class GrGLGpu;
+
+/**
+ * This class serves as the implementation of GrGL*Buffer classes. It was written to avoid code
+ * duplication in those classes.
+ */
+class GrGLBufferImpl : SkNoncopyable {
+public:
+ enum Usage {
+ kStaticDraw_Usage = 0,
+ kDynamicDraw_Usage,
+ kStreamDraw_Usage,
+ kStreamRead_Usage,
+
+ kLast_Usage = kStreamRead_Usage
+ };
+ static const int kUsageCount = kLast_Usage + 1;
+
+ struct Desc {
+ GrGLuint fID; // set to 0 to indicate buffer is CPU-backed and not a VBO.
+ size_t fSizeInBytes;
+ Usage fUsage;
+ };
+
+ GrGLBufferImpl(GrGLGpu*, const Desc&, GrGLenum bufferType);
+ ~GrGLBufferImpl() {
+ // either release or abandon should have been called by the owner of this object.
+ SkASSERT(0 == fDesc.fID);
+ }
+
+ void abandon();
+ void release(GrGLGpu* gpu);
+
+ GrGLuint bufferID() const { return fDesc.fID; }
+ size_t baseOffset() const { return reinterpret_cast<size_t>(fCPUData); }
+ GrGLenum bufferType() const { return fBufferType; }
+
+ void* map(GrGLGpu* gpu);
+ void unmap(GrGLGpu* gpu);
+ bool isMapped() const;
+ bool updateData(GrGLGpu* gpu, const void* src, size_t srcSizeInBytes);
+
+private:
+ void validate() const;
+
+ Desc fDesc;
+ GrGLenum fBufferType; // GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER, e.g.
+ void* fCPUData;
+ void* fMapPtr;
+ size_t fGLSizeInBytes; // In certain cases we make the size of the GL buffer object
+ // smaller or larger than the size in fDesc.
+
+ typedef SkNoncopyable INHERITED;
+};
+
+#endif
« no previous file with comments | « src/gpu/gl/GrGLBuffer.cpp ('k') | src/gpu/gl/GrGLBufferImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698