OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 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 | 9 |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 this->handleDirtyContext(); | 191 this->handleDirtyContext(); |
192 return this->onCreateVertexBuffer(size, dynamic); | 192 return this->onCreateVertexBuffer(size, dynamic); |
193 } | 193 } |
194 | 194 |
195 GrIndexBuffer* GrGpu::createIndexBuffer(uint32_t size, bool dynamic) { | 195 GrIndexBuffer* GrGpu::createIndexBuffer(uint32_t size, bool dynamic) { |
196 this->handleDirtyContext(); | 196 this->handleDirtyContext(); |
197 return this->onCreateIndexBuffer(size, dynamic); | 197 return this->onCreateIndexBuffer(size, dynamic); |
198 } | 198 } |
199 | 199 |
200 GrPath* GrGpu::createPath(const SkPath& path) { | 200 GrPath* GrGpu::createPath(const SkPath& path) { |
201 SkASSERT(this->caps()->pathStencilingSupport()); | 201 SkASSERT(this->caps()->pathRenderingSupport()); |
202 this->handleDirtyContext(); | 202 this->handleDirtyContext(); |
203 return this->onCreatePath(path); | 203 return this->onCreatePath(path); |
204 } | 204 } |
205 | 205 |
206 void GrGpu::clear(const SkIRect* rect, | 206 void GrGpu::clear(const SkIRect* rect, |
207 GrColor color, | 207 GrColor color, |
208 GrRenderTarget* renderTarget) { | 208 GrRenderTarget* renderTarget) { |
209 GrDrawState::AutoRenderTargetRestore art; | 209 GrDrawState::AutoRenderTargetRestore art; |
210 if (NULL != renderTarget) { | 210 if (NULL != renderTarget) { |
211 art.set(this->drawState(), renderTarget); | 211 art.set(this->drawState(), renderTarget); |
(...skipping 28 matching lines...) Expand all Loading... | |
240 return this->onWriteTexturePixels(texture, left, top, width, height, | 240 return this->onWriteTexturePixels(texture, left, top, width, height, |
241 config, buffer, rowBytes); | 241 config, buffer, rowBytes); |
242 } | 242 } |
243 | 243 |
244 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { | 244 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { |
245 SkASSERT(target); | 245 SkASSERT(target); |
246 this->handleDirtyContext(); | 246 this->handleDirtyContext(); |
247 this->onResolveRenderTarget(target); | 247 this->onResolveRenderTarget(target); |
248 } | 248 } |
249 | 249 |
250 namespace { | |
bsalomon
2013/10/08 14:05:08
We were using anonymous namespaces in Gr code, but
Kimmo Kinnunen
2013/10/09 07:07:01
Done.
| |
251 | |
252 const GrStencilSettings& winding_path_stencil_settings() { | |
253 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | |
254 kIncClamp_StencilOp, | |
255 kIncClamp_StencilOp, | |
256 kAlwaysIfInClip_StencilFunc, | |
257 0xFFFF, 0xFFFF, 0xFFFF); | |
258 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); | |
259 } | |
260 const GrStencilSettings& even_odd_path_stencil_settings() { | |
261 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | |
262 kInvert_StencilOp, | |
263 kInvert_StencilOp, | |
264 kAlwaysIfInClip_StencilFunc, | |
265 0xFFFF, 0xFFFF, 0xFFFF); | |
266 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); | |
267 } | |
268 | |
269 } | |
270 | |
271 void GrGpu::getPathStencilSettingsForFillType(SkPath::FillType fill, GrStencilSe ttings* outStencilSettings) { | |
272 | |
273 switch (fill) { | |
274 default: | |
275 GrCrash("Unexpected path fill."); | |
276 /* fallthrough */; | |
277 case SkPath::kWinding_FillType: | |
278 case SkPath::kInverseWinding_FillType: | |
279 *outStencilSettings = winding_path_stencil_settings(); | |
280 break; | |
281 case SkPath::kEvenOdd_FillType: | |
282 case SkPath::kInverseEvenOdd_FillType: | |
283 *outStencilSettings = even_odd_path_stencil_settings(); | |
284 break; | |
285 } | |
286 fClipMaskManager.adjustPathStencilParams(outStencilSettings); | |
287 } | |
288 | |
250 | 289 |
251 //////////////////////////////////////////////////////////////////////////////// | 290 //////////////////////////////////////////////////////////////////////////////// |
252 | 291 |
253 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1; | 292 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1; |
254 | 293 |
255 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); | 294 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); |
256 | 295 |
257 static inline void fill_indices(uint16_t* indices, int quadCount) { | 296 static inline void fill_indices(uint16_t* indices, int quadCount) { |
258 for (int i = 0; i < quadCount; ++i) { | 297 for (int i = 0; i < quadCount; ++i) { |
259 indices[6 * i + 0] = 4 * i + 0; | 298 indices[6 * i + 0] = 4 * i + 0; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 info.getDstCopy(), | 381 info.getDstCopy(), |
343 &are)) { | 382 &are)) { |
344 return; | 383 return; |
345 } | 384 } |
346 this->onGpuDraw(info); | 385 this->onGpuDraw(info); |
347 } | 386 } |
348 | 387 |
349 void GrGpu::onStencilPath(const GrPath* path, const SkStrokeRec&, SkPath::FillTy pe fill) { | 388 void GrGpu::onStencilPath(const GrPath* path, const SkStrokeRec&, SkPath::FillTy pe fill) { |
350 this->handleDirtyContext(); | 389 this->handleDirtyContext(); |
351 | 390 |
352 // TODO: make this more efficient (don't copy and copy back) | |
353 GrAutoTRestore<GrStencilSettings> asr(this->drawState()->stencil()); | |
354 | |
355 this->setStencilPathSettings(*path, fill, this->drawState()->stencil()); | |
356 GrDrawState::AutoRestoreEffects are; | 391 GrDrawState::AutoRestoreEffects are; |
357 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, &are)) { | 392 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, &are)) { |
358 return; | 393 return; |
359 } | 394 } |
360 | 395 |
361 this->onGpuStencilPath(path, fill); | 396 this->onGpuStencilPath(path, fill); |
362 } | 397 } |
363 | 398 |
399 void GrGpu::onFillPath(const GrPath* path, const SkStrokeRec& stroke, SkPath::Fi llType fill, | |
400 const GrDeviceCoordTexture* dstCopy) { | |
401 this->handleDirtyContext(); | |
402 | |
403 drawState()->setDefaultVertexAttribs(); | |
404 | |
405 GrDrawState::AutoRestoreEffects are; | |
406 if (!this->setupClipAndFlushState(kFillPath_DrawType, dstCopy, &are)) { | |
407 return; | |
408 } | |
409 | |
410 this->onGpuFillPath(path, fill); | |
411 } | |
412 | |
364 void GrGpu::finalizeReservedVertices() { | 413 void GrGpu::finalizeReservedVertices() { |
365 SkASSERT(NULL != fVertexPool); | 414 SkASSERT(NULL != fVertexPool); |
366 fVertexPool->unlock(); | 415 fVertexPool->unlock(); |
367 } | 416 } |
368 | 417 |
369 void GrGpu::finalizeReservedIndices() { | 418 void GrGpu::finalizeReservedIndices() { |
370 SkASSERT(NULL != fIndexPool); | 419 SkASSERT(NULL != fIndexPool); |
371 fIndexPool->unlock(); | 420 fIndexPool->unlock(); |
372 } | 421 } |
373 | 422 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 } | 540 } |
492 | 541 |
493 void GrGpu::releaseIndexArray() { | 542 void GrGpu::releaseIndexArray() { |
494 // if index source was array, we stowed data in the pool | 543 // if index source was array, we stowed data in the pool |
495 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 544 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
496 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 545 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
497 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 546 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
498 fIndexPool->putBack(bytes); | 547 fIndexPool->putBack(bytes); |
499 --fIndexPoolUseCnt; | 548 --fIndexPoolUseCnt; |
500 } | 549 } |
OLD | NEW |