| 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" | |
| 12 #include "GrGpuGL.h" | 11 #include "GrGpuGL.h" |
| 13 | 12 |
| 14 GrGLPathRange::GrGLPathRange(GrGpuGL* gpu, size_t size, const SkStrokeRec& strok
e) | 13 #define GPUGL static_cast<GrGpuGL*>(this->getGpu()) |
| 14 |
| 15 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) |
| 16 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(GPUGL->glInterface(), R, X) |
| 17 |
| 18 GrGLPathRange::GrGLPathRange(GrGpu* gpu, size_t size, const SkStrokeRec& stroke) |
| 15 : INHERITED(gpu, size, stroke), | 19 : INHERITED(gpu, size, stroke), |
| 16 fBasePathID(gpu->pathRendering()->genPaths(fSize)), | |
| 17 fNumDefinedPaths(0) { | 20 fNumDefinedPaths(0) { |
| 21 GL_CALL_RET(fBasePathID, GenPaths(fSize)); |
| 18 } | 22 } |
| 19 | 23 |
| 20 GrGLPathRange::~GrGLPathRange() { | 24 GrGLPathRange::~GrGLPathRange() { |
| 21 this->release(); | 25 this->release(); |
| 22 } | 26 } |
| 23 | 27 |
| 24 void GrGLPathRange::initAt(size_t index, const SkPath& skPath) { | 28 void GrGLPathRange::initAt(size_t index, const SkPath& skPath) { |
| 25 GrGpuGL* gpu = static_cast<GrGpuGL*>(this->getGpu()); | 29 GrGpuGL* gpu = static_cast<GrGpuGL*>(this->getGpu()); |
| 26 if (NULL == gpu) { | 30 if (NULL == gpu) { |
| 27 return; | 31 return; |
| 28 } | 32 } |
| 29 | 33 |
| 34 #ifdef SK_DEBUG |
| 30 // Make sure the path at this index hasn't been initted already. | 35 // Make sure the path at this index hasn't been initted already. |
| 31 SkASSERT(GR_GL_FALSE == gpu->pathRendering()->isPath(fBasePathID + index)); | 36 GrGLboolean hasPathAtIndex; |
| 37 GL_CALL_RET(hasPathAtIndex, IsPath(fBasePathID + index)); |
| 38 SkASSERT(GR_GL_FALSE == hasPathAtIndex); |
| 39 #endif |
| 32 | 40 |
| 33 GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, fStroke); | 41 GrGLPath::InitPathObject(gpu->glInterface(), fBasePathID + index, skPath, fS
troke); |
| 42 |
| 34 ++fNumDefinedPaths; | 43 ++fNumDefinedPaths; |
| 35 this->didChangeGpuMemorySize(); | 44 this->didChangeGpuMemorySize(); |
| 36 } | 45 } |
| 37 | 46 |
| 38 void GrGLPathRange::onRelease() { | 47 void GrGLPathRange::onRelease() { |
| 39 SkASSERT(NULL != this->getGpu()); | 48 SkASSERT(NULL != this->getGpu()); |
| 40 | 49 |
| 41 if (0 != fBasePathID && !this->isWrapped()) { | 50 if (0 != fBasePathID && !this->isWrapped()) { |
| 42 static_cast<GrGpuGL*>(this->getGpu())->pathRendering()->deletePaths(fBas
ePathID, fSize); | 51 GL_CALL(DeletePaths(fBasePathID, fSize)); |
| 43 fBasePathID = 0; | 52 fBasePathID = 0; |
| 44 } | 53 } |
| 45 | 54 |
| 46 INHERITED::onRelease(); | 55 INHERITED::onRelease(); |
| 47 } | 56 } |
| 48 | 57 |
| 49 void GrGLPathRange::onAbandon() { | 58 void GrGLPathRange::onAbandon() { |
| 50 fBasePathID = 0; | 59 fBasePathID = 0; |
| 51 | 60 |
| 52 INHERITED::onAbandon(); | 61 INHERITED::onAbandon(); |
| 53 } | 62 } |
| OLD | NEW |