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, PathGenerator* pathGenerator, const S
kStrokeRec& stroke) | 14 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const S
kStrokeRec& stroke) |
15 : INHERITED(gpu, pathGenerator, stroke), | 15 : INHERITED(gpu, pathGenerator, stroke), |
16 fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())), | 16 fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())), |
17 fGpuMemorySize(0) { | 17 fGpuMemorySize(0) { |
18 this->registerWithCache(); | 18 this->registerWithCache(); |
19 } | 19 } |
20 | 20 |
21 GrGLPathRange::GrGLPathRange(GrGpuGL* gpu, | 21 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, |
22 GrGLuint basePathID, | 22 GrGLuint basePathID, |
23 int numPaths, | 23 int numPaths, |
24 size_t gpuMemorySize, | 24 size_t gpuMemorySize, |
25 const SkStrokeRec& stroke) | 25 const SkStrokeRec& stroke) |
26 : INHERITED(gpu, numPaths, stroke), | 26 : INHERITED(gpu, numPaths, stroke), |
27 fBasePathID(basePathID), | 27 fBasePathID(basePathID), |
28 fGpuMemorySize(gpuMemorySize) { | 28 fGpuMemorySize(gpuMemorySize) { |
29 this->registerWithCache(); | 29 this->registerWithCache(); |
30 } | 30 } |
31 | 31 |
32 void GrGLPathRange::onInitPath(int index, const SkPath& skPath) const { | 32 void GrGLPathRange::onInitPath(int index, const SkPath& skPath) const { |
33 GrGpuGL* gpu = static_cast<GrGpuGL*>(this->getGpu()); | 33 GrGLGpu* gpu = static_cast<GrGLGpu*>(this->getGpu()); |
34 if (NULL == gpu) { | 34 if (NULL == gpu) { |
35 return; | 35 return; |
36 } | 36 } |
37 | 37 |
38 // Make sure the path at this index hasn't been initted already. | 38 // Make sure the path at this index hasn't been initted already. |
39 SkDEBUGCODE( | 39 SkDEBUGCODE( |
40 GrGLboolean isPath; | 40 GrGLboolean isPath; |
41 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index)))
; | 41 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index)))
; |
42 SkASSERT(GR_GL_FALSE == isPath); | 42 SkASSERT(GR_GL_FALSE == isPath); |
43 | 43 |
44 GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, this->getStroke()
); | 44 GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, this->getStroke()
); |
45 | 45 |
46 // TODO: Use a better approximation for the individual path sizes. | 46 // TODO: Use a better approximation for the individual path sizes. |
47 fGpuMemorySize += 100; | 47 fGpuMemorySize += 100; |
48 } | 48 } |
49 | 49 |
50 void GrGLPathRange::onRelease() { | 50 void GrGLPathRange::onRelease() { |
51 SkASSERT(this->getGpu()); | 51 SkASSERT(this->getGpu()); |
52 | 52 |
53 if (0 != fBasePathID && !this->isWrapped()) { | 53 if (0 != fBasePathID && !this->isWrapped()) { |
54 static_cast<GrGpuGL*>(this->getGpu())->glPathRendering()->deletePaths(fB
asePathID, | 54 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fB
asePathID, |
55 th
is->getNumPaths()); | 55 th
is->getNumPaths()); |
56 fBasePathID = 0; | 56 fBasePathID = 0; |
57 } | 57 } |
58 | 58 |
59 INHERITED::onRelease(); | 59 INHERITED::onRelease(); |
60 } | 60 } |
61 | 61 |
62 void GrGLPathRange::onAbandon() { | 62 void GrGLPathRange::onAbandon() { |
63 fBasePathID = 0; | 63 fBasePathID = 0; |
64 | 64 |
65 INHERITED::onAbandon(); | 65 INHERITED::onAbandon(); |
66 } | 66 } |
OLD | NEW |