| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrGLPathRange.h" | 8 #include "GrGLPathRange.h" |
| 9 #include "GrGLPath.h" | 9 #include "GrGLPath.h" |
| 10 #include "GrGLPathRendering.h" | 10 #include "GrGLPathRendering.h" |
| 11 #include "GrGLGpu.h" | 11 #include "GrGLGpu.h" |
| 12 | 12 |
| 13 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const G
rStrokeInfo& stroke) | 13 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const G
rStrokeInfo& stroke) |
| 14 : INHERITED(gpu, pathGenerator), | 14 : INHERITED(gpu, pathGenerator), |
| 15 fStroke(stroke), | 15 fStroke(stroke), |
| 16 fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())), | 16 fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())), |
| 17 fGpuMemorySize(0) { | 17 fGpuMemorySize(0) { |
| 18 this->init(); | 18 this->init(); |
| 19 this->registerWithCache(); | 19 this->registerWithCache(SkBudgeted::kYes); |
| 20 } | 20 } |
| 21 | 21 |
| 22 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, | 22 GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, |
| 23 GrGLuint basePathID, | 23 GrGLuint basePathID, |
| 24 int numPaths, | 24 int numPaths, |
| 25 size_t gpuMemorySize, | 25 size_t gpuMemorySize, |
| 26 const GrStrokeInfo& stroke) | 26 const GrStrokeInfo& stroke) |
| 27 : INHERITED(gpu, numPaths), | 27 : INHERITED(gpu, numPaths), |
| 28 fStroke(stroke), | 28 fStroke(stroke), |
| 29 fBasePathID(basePathID), | 29 fBasePathID(basePathID), |
| 30 fGpuMemorySize(gpuMemorySize) { | 30 fGpuMemorySize(gpuMemorySize) { |
| 31 this->init(); | 31 this->init(); |
| 32 this->registerWithCache(); | 32 this->registerWithCache(SkBudgeted::kYes); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void GrGLPathRange::init() { | 35 void GrGLPathRange::init() { |
| 36 // Must force fill: | 36 // Must force fill: |
| 37 // * dashing: NVPR stroke dashing is different to Skia. | 37 // * dashing: NVPR stroke dashing is different to Skia. |
| 38 // * end caps: NVPR stroking degenerate contours with end caps is different
to Skia. | 38 // * end caps: NVPR stroking degenerate contours with end caps is different
to Skia. |
| 39 bool forceFill = fStroke.isDashed() || | 39 bool forceFill = fStroke.isDashed() || |
| 40 (fStroke.needToApply() && fStroke.getCap() != SkPaint::kButt_Cap); | 40 (fStroke.needToApply() && fStroke.getCap() != SkPaint::kButt_Cap); |
| 41 | 41 |
| 42 if (forceFill) { | 42 if (forceFill) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 GrGLPath::InitPathObjectPathData(gpu, fBasePathID + index, *skPath); | 95 GrGLPath::InitPathObjectPathData(gpu, fBasePathID + index, *skPath); |
| 96 } | 96 } |
| 97 // TODO: Use a better approximation for the individual path sizes. | 97 // TODO: Use a better approximation for the individual path sizes. |
| 98 fGpuMemorySize += 100; | 98 fGpuMemorySize += 100; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void GrGLPathRange::onRelease() { | 101 void GrGLPathRange::onRelease() { |
| 102 SkASSERT(this->getGpu()); | 102 SkASSERT(this->getGpu()); |
| 103 | 103 |
| 104 if (0 != fBasePathID && this->shouldFreeResources()) { | 104 if (0 != fBasePathID) { |
| 105 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fB
asePathID, | 105 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fB
asePathID, |
| 106 th
is->getNumPaths()); | 106 th
is->getNumPaths()); |
| 107 fBasePathID = 0; | 107 fBasePathID = 0; |
| 108 } | 108 } |
| 109 | 109 |
| 110 INHERITED::onRelease(); | 110 INHERITED::onRelease(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void GrGLPathRange::onAbandon() { | 113 void GrGLPathRange::onAbandon() { |
| 114 fBasePathID = 0; | 114 fBasePathID = 0; |
| 115 | 115 |
| 116 INHERITED::onAbandon(); | 116 INHERITED::onAbandon(); |
| 117 } | 117 } |
| OLD | NEW |