OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrGLPathRange.h" | 9 #include "GrGLPathRange.h" |
10 #include "GrGLPath.h" | 10 #include "GrGLPath.h" |
11 #include "GrGLPathRendering.h" | 11 #include "GrGLPathRendering.h" |
12 #include "GrGpuGL.h" | 12 #include "GrGpuGL.h" |
13 | 13 |
14 GrGLPathRange::GrGLPathRange(GrGpuGL* gpu, size_t size, const SkStrokeRec& strok
e) | 14 GrGLPathRange::GrGLPathRange(GrGpuGL* gpu, PathGenerator* pathGenerator, const S
kStrokeRec& stroke) |
15 : INHERITED(gpu, size, stroke), | 15 : INHERITED(gpu, pathGenerator, stroke), |
16 fBasePathID(gpu->glPathRendering()->genPaths(fSize)), | 16 fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())), |
17 fNumDefinedPaths(0) { | 17 fGpuMemorySize(0) { |
| 18 this->registerWithCache(); |
| 19 } |
| 20 |
| 21 GrGLPathRange::GrGLPathRange(GrGpuGL* gpu, |
| 22 GrGLuint basePathID, |
| 23 int numPaths, |
| 24 size_t gpuMemorySize, |
| 25 const SkStrokeRec& stroke) |
| 26 : INHERITED(gpu, numPaths, stroke), |
| 27 fBasePathID(basePathID), |
| 28 fGpuMemorySize(gpuMemorySize) { |
| 29 this->registerWithCache(); |
18 } | 30 } |
19 | 31 |
20 GrGLPathRange::~GrGLPathRange() { | 32 GrGLPathRange::~GrGLPathRange() { |
21 this->release(); | 33 this->release(); |
22 } | 34 } |
23 | 35 |
24 void GrGLPathRange::initAt(size_t index, const SkPath& skPath) { | 36 void GrGLPathRange::onInitPath(int index, const SkPath& skPath) const { |
25 GrGpuGL* gpu = static_cast<GrGpuGL*>(this->getGpu()); | 37 GrGpuGL* gpu = static_cast<GrGpuGL*>(this->getGpu()); |
26 if (NULL == gpu) { | 38 if (NULL == gpu) { |
27 return; | 39 return; |
28 } | 40 } |
29 | 41 |
30 // Make sure the path at this index hasn't been initted already. | 42 // Make sure the path at this index hasn't been initted already. |
31 SkDEBUGCODE( | 43 SkDEBUGCODE( |
32 GrGLboolean isPath; | 44 GrGLboolean isPath; |
33 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index)))
; | 45 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index)))
; |
34 SkASSERT(GR_GL_FALSE == isPath); | 46 SkASSERT(GR_GL_FALSE == isPath); |
35 | 47 |
36 GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, fStroke); | 48 GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, this->getStroke()
); |
37 ++fNumDefinedPaths; | 49 |
38 this->didChangeGpuMemorySize(); | 50 // TODO: Use a better approximation for the individual path sizes. |
| 51 fGpuMemorySize += 100; |
39 } | 52 } |
40 | 53 |
41 void GrGLPathRange::onRelease() { | 54 void GrGLPathRange::onRelease() { |
42 SkASSERT(this->getGpu()); | 55 SkASSERT(this->getGpu()); |
43 | 56 |
44 if (0 != fBasePathID && !this->isWrapped()) { | 57 if (0 != fBasePathID && !this->isWrapped()) { |
45 static_cast<GrGpuGL*>(this->getGpu())->glPathRendering()->deletePaths(fB
asePathID, fSize); | 58 static_cast<GrGpuGL*>(this->getGpu())->glPathRendering()->deletePaths(fB
asePathID, |
| 59 th
is->getNumPaths()); |
46 fBasePathID = 0; | 60 fBasePathID = 0; |
47 } | 61 } |
48 | 62 |
49 INHERITED::onRelease(); | 63 INHERITED::onRelease(); |
50 } | 64 } |
51 | 65 |
52 void GrGLPathRange::onAbandon() { | 66 void GrGLPathRange::onAbandon() { |
53 fBasePathID = 0; | 67 fBasePathID = 0; |
54 | 68 |
55 INHERITED::onAbandon(); | 69 INHERITED::onAbandon(); |
56 } | 70 } |
OLD | NEW |