aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-11-20 14:50:39 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-20 14:50:39 -0800
commitc07379d6b1a02ddbf1a5fd9518696b3737067532 (patch)
tree1a74338aae0dd7da24d960ed4fd656dabcc9ce90
parentffe2f1cbd0a8ed8accabb2589afbd16a2b3e39fe (diff)
Adding GeometryData object
-rw-r--r--gyp/gpu.gypi1
-rw-r--r--src/gpu/GrGeometryData.h42
-rw-r--r--src/gpu/GrGeometryProcessor.h1
-rw-r--r--src/gpu/GrProcessor.cpp15
4 files changed, 59 insertions, 0 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index c019b12ea5..4690f62fc2 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -83,6 +83,7 @@
'<(skia_src_path)/gpu/GrFontScaler.cpp',
'<(skia_src_path)/gpu/GrFontScaler.h',
'<(skia_src_path)/gpu/GrGeometryBuffer.h',
+ '<(skia_src_path)/gpu/GrGeometryData.h',
'<(skia_src_path)/gpu/GrGeometryProcessor.h',
'<(skia_src_path)/gpu/GrGlyph.h',
'<(skia_src_path)/gpu/GrGpu.cpp',
diff --git a/src/gpu/GrGeometryData.h b/src/gpu/GrGeometryData.h
new file mode 100644
index 0000000000..a4e9fe6871
--- /dev/null
+++ b/src/gpu/GrGeometryData.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGeometryData_DEFINED
+#define GrGeometryData_DEFINED
+
+#include <new>
+#include "SkTypes.h"
+
+/*
+ * A super lightweight base class for GeometryProcessor's to use to store draw data in a reorderable
+ * fashion. Its most important feature is a pool allocator. Its virtual, but only so subclasses
+ * will have their destructors called.
+ */
+
+class GrGeometryData : SkNoncopyable {
+public:
+ virtual ~GrGeometryData() {}
+
+ /**
+ * Helper for down-casting to a GrGeometryData subclass
+ */
+ template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
+
+ void* operator new(size_t size);
+
+ void operator delete(void* target);
+
+ void* operator new(size_t size, void* placement) {
+ return ::operator new(size, placement);
+ }
+
+ void operator delete(void* target, void* placement) {
+ ::operator delete(target, placement);
+ }
+};
+
+#endif
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
index 01401ae797..6d27f0b4f1 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -8,6 +8,7 @@
#ifndef GrGeometryProcessor_DEFINED
#define GrGeometryProcessor_DEFINED
+#include "GrGeometryData.h"
#include "GrProcessor.h"
#include "GrShaderVar.h"
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 01071dabfd..d850d6894a 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -9,6 +9,7 @@
#include "GrBackendProcessorFactory.h"
#include "GrContext.h"
#include "GrCoordTransform.h"
+#include "GrGeometryData.h"
#include "GrInvariantOutput.h"
#include "GrMemoryPool.h"
#include "SkTLS.h"
@@ -152,3 +153,17 @@ bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con
}
return true;
}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*
+ * GrGeometryData shares the same pool so it lives in this file too
+ */
+void* GrGeometryData::operator new(size_t size) {
+ return GrProcessor_Globals::GetTLS()->allocate(size);
+}
+
+void GrGeometryData::operator delete(void* target) {
+ GrProcessor_Globals::GetTLS()->release(target);
+}
+