3 * Copyright 2014 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
9 #include "GrGLPathRange.h"
11 #include "GrGLPathRendering.h"
14 GrGLPathRange::GrGLPathRange(GrGpuGL* gpu, PathGenerator* pathGenerator, const SkStrokeRec& stroke)
15 : INHERITED(gpu, pathGenerator, stroke),
16 fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())),
18 this->registerWithCache();
21 GrGLPathRange::GrGLPathRange(GrGpuGL* gpu,
25 const SkStrokeRec& stroke)
26 : INHERITED(gpu, numPaths, stroke),
27 fBasePathID(basePathID),
28 fGpuMemorySize(gpuMemorySize) {
29 this->registerWithCache();
32 GrGLPathRange::~GrGLPathRange() {
36 void GrGLPathRange::onInitPath(int index, const SkPath& skPath) const {
37 GrGpuGL* gpu = static_cast<GrGpuGL*>(this->getGpu());
42 // Make sure the path at this index hasn't been initted already.
45 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index)));
46 SkASSERT(GR_GL_FALSE == isPath);
48 GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, this->getStroke());
50 // TODO: Use a better approximation for the individual path sizes.
51 fGpuMemorySize += 100;
54 void GrGLPathRange::onRelease() {
55 SkASSERT(this->getGpu());
57 if (0 != fBasePathID && !this->isWrapped()) {
58 static_cast<GrGpuGL*>(this->getGpu())->glPathRendering()->deletePaths(fBasePathID,
63 INHERITED::onRelease();
66 void GrGLPathRange::onAbandon() {
69 INHERITED::onAbandon();