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

Unified Diff: src/gpu/gl/GrGLPathRange.cpp

Issue 400713003: Add a GrPathRange class (Closed) Base URL: https://skia.googlesource.com/skia.git@clupload-ispath
Patch Set: Created 6 years, 5 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
Index: src/gpu/gl/GrGLPathRange.cpp
diff --git a/src/gpu/gl/GrGLPathRange.cpp b/src/gpu/gl/GrGLPathRange.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..833326c6a0eef0879051cabe46fa1cc8e6db37f9
--- /dev/null
+++ b/src/gpu/gl/GrGLPathRange.cpp
@@ -0,0 +1,64 @@
+
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrGLPathRange.h"
+#include "GrGLPath.h"
+#include "GrGpuGL.h"
+
+#define GPUGL static_cast<GrGpuGL*>(this->getGpu())
+
+#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
+#define GL_CALL_RET(R, X) GR_GL_CALL_RET(GPUGL->glInterface(), R, X)
+
+static const bool kIsWrapped = false; // The constructor creates the GL path objects.
+
+GrGLPathRange::GrGLPathRange(GrGpu* gpu, size_t size, const SkStrokeRec& stroke)
+ : INHERITED(gpu, kIsWrapped, size, stroke),
+ fNumDefinedPaths(0) {
+ GL_CALL_RET(fBasePathID, GenPaths(fSize));
+}
+
+GrGLPathRange::~GrGLPathRange() {
+ this->release();
+}
+
+void GrGLPathRange::initAt(size_t index, const SkPath& skPath) {
+ GrGpuGL* gpu = static_cast<GrGpuGL*>(this->getGpu());
+ if (NULL == gpu) {
+ return;
+ }
+
+#ifdef SK_DEBUG
+ // Make sure the path at this index hasn't been initted already.
+ bool hasPathAtIndex;
+ GL_CALL_RET(hasPathAtIndex, IsPath(fBasePathID + index));
+ SkASSERT(!hasPathAtIndex);
+#endif
+
+ GrGLPath::InitPathObject(gpu->glInterface(), fBasePathID + index, skPath, fStroke);
+
+ ++fNumDefinedPaths;
+ this->didChangeGpuMemorySize();
+}
+
+void GrGLPathRange::onRelease() {
+ SkASSERT(NULL != this->getGpu());
+
+ if (0 != fBasePathID && !this->isWrapped()) {
+ GL_CALL(DeletePaths(fBasePathID, fSize));
+ fBasePathID = 0;
+ }
+
+ INHERITED::onRelease();
+}
+
+void GrGLPathRange::onAbandon() {
+ fBasePathID = 0;
+
+ INHERITED::onAbandon();
+}

Powered by Google App Engine
This is Rietveld 408576698