aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLPath.cpp17
-rw-r--r--src/gpu/gl/GrGLPath.h18
-rw-r--r--src/gpu/gl/GrGLPathRange.cpp5
-rw-r--r--src/gpu/gl/GrGLPathRange.h9
4 files changed, 27 insertions, 22 deletions
diff --git a/src/gpu/gl/GrGLPath.cpp b/src/gpu/gl/GrGLPath.cpp
index 6f158cdea9..e80259ebc8 100644
--- a/src/gpu/gl/GrGLPath.cpp
+++ b/src/gpu/gl/GrGLPath.cpp
@@ -81,10 +81,10 @@ inline GrGLenum cap_to_gl_cap(SkPaint::Cap cap) {
static const bool kIsWrapped = false; // The constructor creates the GL path object.
-void GrGLPath::InitPathObject(GrGpuGL* gpu,
- GrGLuint pathID,
- const SkPath& skPath,
- const SkStrokeRec& stroke) {
+size_t GrGLPath::InitPathObject(GrGpuGL* gpu,
+ GrGLuint pathID,
+ const SkPath& skPath,
+ const SkStrokeRec& stroke) {
GrGLPathRendering* pr = gpu->pathRendering();
SkSTArray<16, GrGLubyte, true> pathCommands;
SkSTArray<16, SkPoint, true> pathPoints;
@@ -117,6 +117,13 @@ void GrGLPath::InitPathObject(GrGpuGL* gpu,
pr->pathParameteri(pathID, GR_GL_PATH_INITIAL_END_CAP, cap);
pr->pathParameteri(pathID, GR_GL_PATH_TERMINAL_END_CAP, cap);
}
+
+ size_t approximateSize = 5 * (verbCnt + pointCnt);
+ if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) {
+ // It will take approxoimately twice the memory if it has both fill *and* stroke.
+ approximateSize *= 2;
+ }
+ return approximateSize;
}
GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke)
@@ -124,7 +131,7 @@ GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke)
fPathID(gpu->pathRendering()->genPaths(1)) {
SkASSERT(!path.isEmpty());
- InitPathObject(gpu, fPathID, fSkPath, stroke);
+ fGpuMemorySize = InitPathObject(gpu, fPathID, fSkPath, stroke);
if (stroke.needToApply()) {
// FIXME: try to account for stroking, without rasterizing the stroke.
diff --git a/src/gpu/gl/GrGLPath.h b/src/gpu/gl/GrGLPath.h
index 935a2e24ad..7ce93c61e1 100644
--- a/src/gpu/gl/GrGLPath.h
+++ b/src/gpu/gl/GrGLPath.h
@@ -22,17 +22,20 @@ class GrGpuGL;
class GrGLPath : public GrPath {
public:
- static void InitPathObject(GrGpuGL*,
- GrGLuint pathID,
- const SkPath&,
- const SkStrokeRec&);
+ /**
+ * Initialize a GL path object with a given path and stroke.
+ *
+ * @return the approximate GPU memory size of the path object in bytes.
+ */
+ static size_t InitPathObject(GrGpuGL*,
+ GrGLuint pathID,
+ const SkPath&,
+ const SkStrokeRec&);
GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke);
virtual ~GrGLPath();
GrGLuint pathID() const { return fPathID; }
- // TODO: Figure out how to get an approximate size of the path in Gpu
- // memory.
- virtual size_t gpuMemorySize() const SK_OVERRIDE { return 100; }
+ virtual size_t gpuMemorySize() const SK_OVERRIDE { return fGpuMemorySize; }
protected:
virtual void onRelease() SK_OVERRIDE;
@@ -40,6 +43,7 @@ protected:
private:
GrGLuint fPathID;
+ size_t fGpuMemorySize;
typedef GrPath INHERITED;
};
diff --git a/src/gpu/gl/GrGLPathRange.cpp b/src/gpu/gl/GrGLPathRange.cpp
index 5e89cb5d87..9e2b2e7326 100644
--- a/src/gpu/gl/GrGLPathRange.cpp
+++ b/src/gpu/gl/GrGLPathRange.cpp
@@ -14,7 +14,7 @@
GrGLPathRange::GrGLPathRange(GrGpuGL* gpu, size_t size, const SkStrokeRec& stroke)
: INHERITED(gpu, size, stroke),
fBasePathID(gpu->pathRendering()->genPaths(fSize)),
- fNumDefinedPaths(0) {
+ fGpuMemorySize(0) {
}
GrGLPathRange::~GrGLPathRange() {
@@ -30,8 +30,7 @@ void GrGLPathRange::initAt(size_t index, const SkPath& skPath) {
// Make sure the path at this index hasn't been initted already.
SkASSERT(GR_GL_FALSE == gpu->pathRendering()->isPath(fBasePathID + index));
- GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, fStroke);
- ++fNumDefinedPaths;
+ fGpuMemorySize += GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, fStroke);
this->didChangeGpuMemorySize();
}
diff --git a/src/gpu/gl/GrGLPathRange.h b/src/gpu/gl/GrGLPathRange.h
index 927310d651..8e2df76efb 100644
--- a/src/gpu/gl/GrGLPathRange.h
+++ b/src/gpu/gl/GrGLPathRange.h
@@ -26,13 +26,8 @@ public:
virtual ~GrGLPathRange();
GrGLuint basePathID() const { return fBasePathID; }
-
virtual void initAt(size_t index, const SkPath&);
-
- // TODO: Use a better approximation for the individual path sizes.
- virtual size_t gpuMemorySize() const SK_OVERRIDE {
- return 100 * fNumDefinedPaths;
- }
+ virtual size_t gpuMemorySize() const SK_OVERRIDE { return fGpuMemorySize; }
protected:
virtual void onRelease() SK_OVERRIDE;
@@ -40,7 +35,7 @@ protected:
private:
GrGLuint fBasePathID;
- size_t fNumDefinedPaths;
+ size_t fGpuMemorySize;
typedef GrPathRange INHERITED;
};