Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: src/gpu/gl/GrGLPathRange.cpp

Issue 400713003: Add a GrPathRange class (Closed) Base URL: https://skia.googlesource.com/skia.git@clupload-ispath
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2014 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9 #include "GrGLPathRange.h"
10 #include "GrGLPath.h"
11 #include "GrGpuGL.h"
12
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 static const bool kIsWrapped = false; // The constructor creates the GL path obj ects.
19
20 GrGLPathRange::GrGLPathRange(GrGpu* gpu, size_t size, const SkStrokeRec& stroke)
21 : INHERITED(gpu, kIsWrapped, size, stroke),
22 fNumDefinedPaths(0) {
23 GL_CALL_RET(fBasePathID, GenPaths(fSize));
24 }
25
26 GrGLPathRange::~GrGLPathRange() {
27 this->release();
28 }
29
30 void GrGLPathRange::initAt(size_t index, const SkPath& skPath) {
31 GrGpuGL* gpu = static_cast<GrGpuGL*>(this->getGpu());
32 if (NULL == gpu) {
33 return;
34 }
35
36 #ifdef SK_DEBUG
37 // Make sure the path at this index hasn't been initted already.
38 bool hasPathAtIndex;
39 GL_CALL_RET(hasPathAtIndex, IsPath(fBasePathID + index));
40 SkASSERT(!hasPathAtIndex);
41 #endif
42
43 GrGLPath::InitPathObject(gpu->glInterface(), fBasePathID + index, skPath, fS troke);
44
45 ++fNumDefinedPaths;
46 this->didChangeGpuMemorySize();
47 }
48
49 void GrGLPathRange::onRelease() {
50 SkASSERT(NULL != this->getGpu());
51
52 if (0 != fBasePathID && !this->isWrapped()) {
53 GL_CALL(DeletePaths(fBasePathID, fSize));
54 fBasePathID = 0;
55 }
56
57 INHERITED::onRelease();
58 }
59
60 void GrGLPathRange::onAbandon() {
61 fBasePathID = 0;
62
63 INHERITED::onAbandon();
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698