OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrResourceProvider.h" | 8 #include "GrResourceProvider.h" |
9 | 9 |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // This is typically used in GrBatchs, so we assume kNoPendingIO. | 31 // This is typically used in GrBatchs, so we assume kNoPendingIO. |
32 GrIndexBuffer* buffer = this->createIndexBuffer(bufferSize, kStatic_BufferUs
age, | 32 GrIndexBuffer* buffer = this->createIndexBuffer(bufferSize, kStatic_BufferUs
age, |
33 kNoPendingIO_Flag); | 33 kNoPendingIO_Flag); |
34 if (!buffer) { | 34 if (!buffer) { |
35 return NULL; | 35 return NULL; |
36 } | 36 } |
37 uint16_t* data = (uint16_t*) buffer->map(); | 37 uint16_t* data = (uint16_t*) buffer->map(); |
38 bool useTempData = (NULL == data); | 38 bool useTempData = (NULL == data); |
39 if (useTempData) { | 39 if (useTempData) { |
40 data = SkNEW_ARRAY(uint16_t, reps * patternSize); | 40 data = new uint16_t[reps * patternSize]; |
41 } | 41 } |
42 for (int i = 0; i < reps; ++i) { | 42 for (int i = 0; i < reps; ++i) { |
43 int baseIdx = i * patternSize; | 43 int baseIdx = i * patternSize; |
44 uint16_t baseVert = (uint16_t)(i * vertCount); | 44 uint16_t baseVert = (uint16_t)(i * vertCount); |
45 for (int j = 0; j < patternSize; ++j) { | 45 for (int j = 0; j < patternSize; ++j) { |
46 data[baseIdx+j] = baseVert + pattern[j]; | 46 data[baseIdx+j] = baseVert + pattern[j]; |
47 } | 47 } |
48 } | 48 } |
49 if (useTempData) { | 49 if (useTempData) { |
50 if (!buffer->updateData(data, bufferSize)) { | 50 if (!buffer->updateData(data, bufferSize)) { |
51 buffer->unref(); | 51 buffer->unref(); |
52 return NULL; | 52 return NULL; |
53 } | 53 } |
54 SkDELETE_ARRAY(data); | 54 delete[] data; |
55 } else { | 55 } else { |
56 buffer->unmap(); | 56 buffer->unmap(); |
57 } | 57 } |
58 this->assignUniqueKeyToResource(key, buffer); | 58 this->assignUniqueKeyToResource(key, buffer); |
59 return buffer; | 59 return buffer; |
60 } | 60 } |
61 | 61 |
62 const GrIndexBuffer* GrResourceProvider::createQuadIndexBuffer() { | 62 const GrIndexBuffer* GrResourceProvider::createQuadIndexBuffer() { |
63 static const int kMaxQuads = 1 << 12; // max possible: (1 << 14) - 1; | 63 static const int kMaxQuads = 1 << 12; // max possible: (1 << 14) - 1; |
64 GR_STATIC_ASSERT(4 * kMaxQuads <= 65535); | 64 GR_STATIC_ASSERT(4 * kMaxQuads <= 65535); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 desc.fConfig = config; | 154 desc.fConfig = config; |
155 | 155 |
156 // We don't want to flush the context so we claim we're in the middle of flu
shing so as to | 156 // We don't want to flush the context so we claim we're in the middle of flu
shing so as to |
157 // guarantee we do not recieve a texture with pending IO | 157 // guarantee we do not recieve a texture with pending IO |
158 // TODO: Determine how to avoid having to do this. (http://skbug.com/4156) | 158 // TODO: Determine how to avoid having to do this. (http://skbug.com/4156) |
159 static const uint32_t kFlags = GrResourceProvider::kNoPendingIO_Flag; | 159 static const uint32_t kFlags = GrResourceProvider::kNoPendingIO_Flag; |
160 GrTexture* texture = this->createApproxTexture(desc, kFlags); | 160 GrTexture* texture = this->createApproxTexture(desc, kFlags); |
161 if (!texture) { | 161 if (!texture) { |
162 return NULL; | 162 return NULL; |
163 } | 163 } |
164 return SkNEW_ARGS(GrBatchAtlas, (texture, numPlotsX, numPlotsY)); | 164 return new GrBatchAtlas(texture, numPlotsX, numPlotsY); |
165 } | 165 } |
OLD | NEW |