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

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

Issue 687563008: Beginning to refactor nvpr code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanups Created 6 years, 1 month 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
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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 268 }
269 269
270 return fQuadIndexBuffer; 270 return fQuadIndexBuffer;
271 } 271 }
272 272
273 //////////////////////////////////////////////////////////////////////////////// 273 ////////////////////////////////////////////////////////////////////////////////
274 274
275 bool GrGpu::setupClipAndFlushState(DrawType type, 275 bool GrGpu::setupClipAndFlushState(DrawType type,
276 const GrDeviceCoordTexture* dstCopy, 276 const GrDeviceCoordTexture* dstCopy,
277 const SkRect* devBounds, 277 const SkRect* devBounds,
278 GrDrawState::AutoRestoreEffects* are) { 278 GrDrawState::AutoRestoreEffects* are,
279 GrDrawState::AutoRestoreStencil* ars) {
279 GrClipMaskManager::ScissorState scissorState; 280 GrClipMaskManager::ScissorState scissorState;
280 GrDrawState::AutoRestoreStencil ars; 281 //GrDrawState::AutoRestoreStencil ars;
281 if (!fClipMaskManager.setupClipping(this->getClip(), 282 if (!fClipMaskManager.setupClipping(this->getClip(),
282 devBounds, 283 devBounds,
283 are, 284 are,
284 &ars, 285 ars,
285 &scissorState)) { 286 &scissorState)) {
286 return false; 287 return false;
287 } 288 }
288 289
289 if (!this->flushGraphicsState(type, scissorState, dstCopy)) { 290 if (!this->flushGraphicsState(type, scissorState, dstCopy)) {
290 return false; 291 return false;
291 } 292 }
292 293
293 return true; 294 return true;
294 } 295 }
(...skipping 23 matching lines...) Expand all
318 319
319 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { 320 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) {
320 // if popping last entry then pops are unbalanced with pushes 321 // if popping last entry then pops are unbalanced with pushes
321 SkASSERT(fGeomPoolStateStack.count() > 1); 322 SkASSERT(fGeomPoolStateStack.count() > 1);
322 fGeomPoolStateStack.pop_back(); 323 fGeomPoolStateStack.pop_back();
323 } 324 }
324 325
325 void GrGpu::onDraw(const DrawInfo& info) { 326 void GrGpu::onDraw(const DrawInfo& info) {
326 this->handleDirtyContext(); 327 this->handleDirtyContext();
327 GrDrawState::AutoRestoreEffects are; 328 GrDrawState::AutoRestoreEffects are;
329 GrDrawState::AutoRestoreStencil ars;
328 if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()), 330 if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()),
329 info.getDstCopy(), 331 info.getDstCopy(),
330 info.getDevBounds(), 332 info.getDevBounds(),
331 &are)) { 333 &are,
334 &ars)) {
332 return; 335 return;
333 } 336 }
334 this->onGpuDraw(info); 337 this->onGpuDraw(info);
335 } 338 }
336 339
337 void GrGpu::onStencilPath(const GrPath* path, SkPath::FillType fill) { 340
341 // TODO hack
342 static const GrStencilSettings& winding_path_stencil_settings() {
343 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
344 kIncClamp_StencilOp,
345 kIncClamp_StencilOp,
346 kAlwaysIfInClip_StencilFunc,
347 0xFFFF, 0xFFFF, 0xFFFF);
348 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
349 }
350
351 static const GrStencilSettings& even_odd_path_stencil_settings() {
352 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
353 kInvert_StencilOp,
354 kInvert_StencilOp,
355 kAlwaysIfInClip_StencilFunc,
356 0xFFFF, 0xFFFF, 0xFFFF);
357 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
358 }
359
360 static void get_path_stencil_settings_for_filltype(GrPathRendering::FillType fil l,
361 GrStencilSettings* outStencil Settings) {
362
363 switch (fill) {
364 default:
365 SkFAIL("Unexpected path fill.");
366 case GrPathRendering::kWinding_FillType:
367 *outStencilSettings = winding_path_stencil_settings();
368 break;
369 case GrPathRendering::kEvenOdd_FillType:
370 *outStencilSettings = even_odd_path_stencil_settings();
371 break;
372 }
373 }
374
375 void GrGpu::onStencilPath(const GrPath* path, GrPathRendering::FillType fill) {
338 this->handleDirtyContext(); 376 this->handleDirtyContext();
339 377
340 GrDrawState::AutoRestoreEffects are; 378 GrDrawState::AutoRestoreEffects are;
341 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, NULL, &are)) { 379 GrDrawState::AutoRestoreStencil ars;
380 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, NULL, &are, & ars)) {
342 return; 381 return;
343 } 382 }
344 383
345 this->pathRendering()->stencilPath(path, fill); 384 GrStencilSettings stencilSettings;
385 get_path_stencil_settings_for_filltype(fill, &stencilSettings);
386 fClipMaskManager.adjustPathStencilParams(&stencilSettings);
387
388 this->pathRendering()->stencilPath(path, stencilSettings);
346 } 389 }
347 390
348 391
349 void GrGpu::onDrawPath(const GrPath* path, SkPath::FillType fill, 392 void GrGpu::onDrawPath(const GrPath* path, GrPathRendering::FillType fill,
350 const GrDeviceCoordTexture* dstCopy) { 393 const GrDeviceCoordTexture* dstCopy) {
351 this->handleDirtyContext(); 394 this->handleDirtyContext();
352 395
353 drawState()->setDefaultVertexAttribs(); 396 drawState()->setDefaultVertexAttribs();
354 397
355 GrDrawState::AutoRestoreEffects are; 398 GrDrawState::AutoRestoreEffects are;
356 if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, NULL, &are)) { 399 GrDrawState::AutoRestoreStencil ars;
400 if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, NULL, &are, & ars)) {
357 return; 401 return;
358 } 402 }
359 403
360 this->pathRendering()->drawPath(path, fill); 404 GrStencilSettings stencilSettings;
405 get_path_stencil_settings_for_filltype(fill, &stencilSettings);
406 fClipMaskManager.adjustPathStencilParams(&stencilSettings);
407
408 this->pathRendering()->drawPath(path, stencilSettings);
361 } 409 }
362 410
363 void GrGpu::onDrawPaths(const GrPathRange* pathRange, 411 void GrGpu::onDrawPaths(const GrPathRange* pathRange,
364 const uint32_t indices[], int count, 412 const uint32_t indices[], int count,
365 const float transforms[], PathTransformType transformsTy pe, 413 const float transforms[], PathTransformType transformsTy pe,
366 SkPath::FillType fill, const GrDeviceCoordTexture* dstCo py) { 414 GrPathRendering::FillType fill, const GrDeviceCoordTextu re* dstCopy) {
367 this->handleDirtyContext(); 415 this->handleDirtyContext();
368 416
369 drawState()->setDefaultVertexAttribs(); 417 drawState()->setDefaultVertexAttribs();
370 418
371 GrDrawState::AutoRestoreEffects are; 419 GrDrawState::AutoRestoreEffects are;
372 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, NULL, &are)) { 420 GrDrawState::AutoRestoreStencil ars;
421 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, NULL, &are, &ars)) {
373 return; 422 return;
374 } 423 }
375 424
425 GrStencilSettings stencilSettings;
426 get_path_stencil_settings_for_filltype(fill, &stencilSettings);
427 fClipMaskManager.adjustPathStencilParams(&stencilSettings);
428
376 pathRange->willDrawPaths(indices, count); 429 pathRange->willDrawPaths(indices, count);
377 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran sformsType, fill); 430 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran sformsType,
431 stencilSettings);
378 } 432 }
379 433
380 void GrGpu::finalizeReservedVertices() { 434 void GrGpu::finalizeReservedVertices() {
381 SkASSERT(fVertexPool); 435 SkASSERT(fVertexPool);
382 fVertexPool->unmap(); 436 fVertexPool->unmap();
383 } 437 }
384 438
385 void GrGpu::finalizeReservedIndices() { 439 void GrGpu::finalizeReservedIndices() {
386 SkASSERT(fIndexPool); 440 SkASSERT(fIndexPool);
387 fIndexPool->unmap(); 441 fIndexPool->unmap();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 561 }
508 562
509 void GrGpu::releaseIndexArray() { 563 void GrGpu::releaseIndexArray() {
510 // if index source was array, we stowed data in the pool 564 // if index source was array, we stowed data in the pool
511 const GeometrySrcState& geoSrc = this->getGeomSrc(); 565 const GeometrySrcState& geoSrc = this->getGeomSrc();
512 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); 566 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc);
513 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); 567 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t);
514 fIndexPool->putBack(bytes); 568 fIndexPool->putBack(bytes);
515 --fIndexPoolUseCnt; 569 --fIndexPoolUseCnt;
516 } 570 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698