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

Side by Side Diff: src/gpu/GrAAHairLinePathRenderer.cpp

Issue 275493004: Rename from "(un)lock" to "(un)map" for geometry buffers. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Address Rob's comments Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « include/gpu/GrUserConfig.h ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "GrAAHairLinePathRenderer.h" 8 #include "GrAAHairLinePathRenderer.h"
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 static const size_t kQuadIdxSBufize = kIdxsPerQuad * 43 static const size_t kQuadIdxSBufize = kIdxsPerQuad *
44 sizeof(uint16_t) * 44 sizeof(uint16_t) *
45 kNumQuadsInIdxBuffer; 45 kNumQuadsInIdxBuffer;
46 46
47 static const int kNumLineSegsInIdxBuffer = 256; 47 static const int kNumLineSegsInIdxBuffer = 256;
48 static const size_t kLineSegIdxSBufize = kIdxsPerLineSeg * 48 static const size_t kLineSegIdxSBufize = kIdxsPerLineSeg *
49 sizeof(uint16_t) * 49 sizeof(uint16_t) *
50 kNumLineSegsInIdxBuffer; 50 kNumLineSegsInIdxBuffer;
51 51
52 static bool push_quad_index_data(GrIndexBuffer* qIdxBuffer) { 52 static bool push_quad_index_data(GrIndexBuffer* qIdxBuffer) {
53 uint16_t* data = (uint16_t*) qIdxBuffer->lock(); 53 uint16_t* data = (uint16_t*) qIdxBuffer->map();
54 bool tempData = NULL == data; 54 bool tempData = NULL == data;
55 if (tempData) { 55 if (tempData) {
56 data = SkNEW_ARRAY(uint16_t, kNumQuadsInIdxBuffer * kIdxsPerQuad); 56 data = SkNEW_ARRAY(uint16_t, kNumQuadsInIdxBuffer * kIdxsPerQuad);
57 } 57 }
58 for (int i = 0; i < kNumQuadsInIdxBuffer; ++i) { 58 for (int i = 0; i < kNumQuadsInIdxBuffer; ++i) {
59 59
60 // Each quadratic is rendered as a five sided polygon. This poly bounds 60 // Each quadratic is rendered as a five sided polygon. This poly bounds
61 // the quadratic's bounding triangle but has been expanded so that the 61 // the quadratic's bounding triangle but has been expanded so that the
62 // 1-pixel wide area around the curve is inside the poly. 62 // 1-pixel wide area around the curve is inside the poly.
63 // If a,b,c are the original control points then the poly a0,b0,c0,c1,a1 63 // If a,b,c are the original control points then the poly a0,b0,c0,c1,a1
(...skipping 15 matching lines...) Expand all
79 data[5 + baseIdx] = baseVert + 3; // c0 79 data[5 + baseIdx] = baseVert + 3; // c0
80 data[6 + baseIdx] = baseVert + 1; // a1 80 data[6 + baseIdx] = baseVert + 1; // a1
81 data[7 + baseIdx] = baseVert + 4; // c1 81 data[7 + baseIdx] = baseVert + 4; // c1
82 data[8 + baseIdx] = baseVert + 2; // b0 82 data[8 + baseIdx] = baseVert + 2; // b0
83 } 83 }
84 if (tempData) { 84 if (tempData) {
85 bool ret = qIdxBuffer->updateData(data, kQuadIdxSBufize); 85 bool ret = qIdxBuffer->updateData(data, kQuadIdxSBufize);
86 delete[] data; 86 delete[] data;
87 return ret; 87 return ret;
88 } else { 88 } else {
89 qIdxBuffer->unlock(); 89 qIdxBuffer->unmap();
90 return true; 90 return true;
91 } 91 }
92 } 92 }
93 93
94 static bool push_line_index_data(GrIndexBuffer* lIdxBuffer) { 94 static bool push_line_index_data(GrIndexBuffer* lIdxBuffer) {
95 uint16_t* data = (uint16_t*) lIdxBuffer->lock(); 95 uint16_t* data = (uint16_t*) lIdxBuffer->map();
96 bool tempData = NULL == data; 96 bool tempData = NULL == data;
97 if (tempData) { 97 if (tempData) {
98 data = SkNEW_ARRAY(uint16_t, kNumLineSegsInIdxBuffer * kIdxsPerLineSeg); 98 data = SkNEW_ARRAY(uint16_t, kNumLineSegsInIdxBuffer * kIdxsPerLineSeg);
99 } 99 }
100 for (int i = 0; i < kNumLineSegsInIdxBuffer; ++i) { 100 for (int i = 0; i < kNumLineSegsInIdxBuffer; ++i) {
101 // Each line segment is rendered as two quads and two triangles. 101 // Each line segment is rendered as two quads and two triangles.
102 // p0 and p1 have alpha = 1 while all other points have alpha = 0. 102 // p0 and p1 have alpha = 1 while all other points have alpha = 0.
103 // The four external points are offset 1 pixel perpendicular to the 103 // The four external points are offset 1 pixel perpendicular to the
104 // line and half a pixel parallel to the line. 104 // line and half a pixel parallel to the line.
105 // 105 //
(...skipping 26 matching lines...) Expand all
132 132
133 data[15 + baseIdx] = baseVert + 1; 133 data[15 + baseIdx] = baseVert + 1;
134 data[16 + baseIdx] = baseVert + 5; 134 data[16 + baseIdx] = baseVert + 5;
135 data[17 + baseIdx] = baseVert + 3; 135 data[17 + baseIdx] = baseVert + 3;
136 } 136 }
137 if (tempData) { 137 if (tempData) {
138 bool ret = lIdxBuffer->updateData(data, kLineSegIdxSBufize); 138 bool ret = lIdxBuffer->updateData(data, kLineSegIdxSBufize);
139 delete[] data; 139 delete[] data;
140 return ret; 140 return ret;
141 } else { 141 } else {
142 lIdxBuffer->unlock(); 142 lIdxBuffer->unmap();
143 return true; 143 return true;
144 } 144 }
145 } 145 }
146 } 146 }
147 147
148 GrPathRenderer* GrAAHairLinePathRenderer::Create(GrContext* context) { 148 GrPathRenderer* GrAAHairLinePathRenderer::Create(GrContext* context) {
149 GrGpu* gpu = context->getGpu(); 149 GrGpu* gpu = context->getGpu();
150 GrIndexBuffer* qIdxBuf = gpu->createIndexBuffer(kQuadIdxSBufize, false); 150 GrIndexBuffer* qIdxBuf = gpu->createIndexBuffer(kQuadIdxSBufize, false);
151 SkAutoTUnref<GrIndexBuffer> qIdxBuffer(qIdxBuf); 151 SkAutoTUnref<GrIndexBuffer> qIdxBuffer(qIdxBuf);
152 if (NULL == qIdxBuf || !push_quad_index_data(qIdxBuf)) { 152 if (NULL == qIdxBuf || !push_quad_index_data(qIdxBuf)) {
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 &devBounds); 1033 &devBounds);
1034 conics += n; 1034 conics += n;
1035 } 1035 }
1036 } 1036 }
1037 } 1037 }
1038 1038
1039 target->resetIndexSource(); 1039 target->resetIndexSource();
1040 1040
1041 return true; 1041 return true;
1042 } 1042 }
OLDNEW
« no previous file with comments | « include/gpu/GrUserConfig.h ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698