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

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

Issue 746253003: Add IndexType parameter to GrDrawTarget::drawPaths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/GrPathRange.h » ('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 "GrInOrderDrawBuffer.h" 8 #include "GrInOrderDrawBuffer.h"
9 9
10 #include "GrBufferAllocPool.h" 10 #include "GrBufferAllocPool.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, scissorSt ate, dstCopy)) { 317 if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, scissorSt ate, dstCopy)) {
318 return; 318 return;
319 } 319 }
320 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); 320 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
321 dp->fStencilSettings = stencilSettings; 321 dp->fStencilSettings = stencilSettings;
322 this->recordTraceMarkersIfNecessary(); 322 this->recordTraceMarkersIfNecessary();
323 } 323 }
324 324
325 void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, 325 void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
326 const GrPathRange* pathRange, 326 const GrPathRange* pathRange,
327 const uint32_t indices[], 327 const void* indices,
328 PathIndexType indexType,
329 const float transformValues[],
330 PathTransformType transformType,
328 int count, 331 int count,
329 const float transforms[],
330 PathTransformType transformsType,
331 const GrClipMaskManager::ScissorState& sci ssorState, 332 const GrClipMaskManager::ScissorState& sci ssorState,
332 const GrStencilSettings& stencilSettings, 333 const GrStencilSettings& stencilSettings,
333 const GrDeviceCoordTexture* dstCopy) { 334 const GrDeviceCoordTexture* dstCopy) {
334 SkASSERT(pathRange); 335 SkASSERT(pathRange);
335 SkASSERT(indices); 336 SkASSERT(indices);
336 SkASSERT(transforms); 337 SkASSERT(transformValues);
337 338
338 if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, scissorSt ate, dstCopy)) { 339 if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, scissorSt ate, dstCopy)) {
339 return; 340 return;
340 } 341 }
341 342
342 uint32_t* savedIndices = fPathIndexBuffer.append(count, indices); 343 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType);
343 float* savedTransforms = fPathTransformBuffer.append(count * 344 if (int misalign = fPathIndexBuffer.count() % indexBytes) {
344 GrPathRendering::PathTransformSize(transformsTy pe), transforms); 345 // Add padding to the index buffer so the indices are aligned properly.
346 fPathIndexBuffer.append(indexBytes - misalign);
347 }
348
349 char* savedIndices = fPathIndexBuffer.append(count * indexBytes,
350 reinterpret_cast<const char*>(i ndices));
351 float* savedTransforms = fPathTransformBuffer.append(
352 count * GrPathRendering::PathTransformSize(tran sformType),
353 transformValues);
345 354
346 if (kDrawPaths_Cmd == strip_trace_bit(fCmdBuffer.back().fType)) { 355 if (kDrawPaths_Cmd == strip_trace_bit(fCmdBuffer.back().fType)) {
347 // The previous command was also DrawPaths. Try to collapse this call in to the one 356 // The previous command was also DrawPaths. Try to collapse this call in to the one
348 // before. Note that stencilling all the paths at once, then covering, m ay not be 357 // before. Note that stencilling all the paths at once, then covering, m ay not be
349 // equivalent to two separate draw calls if there is overlap. Blending w on't work, 358 // equivalent to two separate draw calls if there is overlap. Blending w on't work,
350 // and the combined calls may also cancel each other's winding numbers i n some 359 // and the combined calls may also cancel each other's winding numbers i n some
351 // places. For now the winding numbers are only an issue if the fill is even/odd, 360 // places. For now the winding numbers are only an issue if the fill is even/odd,
352 // because DrawPaths is currently only used for glyphs, and glyphs in th e same 361 // because DrawPaths is currently only used for glyphs, and glyphs in th e same
353 // font tend to all wind in the same direction. 362 // font tend to all wind in the same direction.
354 DrawPaths* previous = static_cast<DrawPaths*>(&fCmdBuffer.back()); 363 DrawPaths* previous = static_cast<DrawPaths*>(&fCmdBuffer.back());
355 if (pathRange == previous->pathRange() && 364 if (pathRange == previous->pathRange() &&
356 transformsType == previous->fTransformsType && 365 indexType == previous->fIndexType &&
366 transformType == previous->fTransformType &&
357 stencilSettings == previous->fStencilSettings && 367 stencilSettings == previous->fStencilSettings &&
358 path_fill_type_is_winding(stencilSettings) && 368 path_fill_type_is_winding(stencilSettings) &&
359 !ds.willBlendWithDst()) { 369 !ds.willBlendWithDst()) {
360 // Fold this DrawPaths call into the one previous. 370 // Fold this DrawPaths call into the one previous.
361 previous->fCount += count; 371 previous->fCount += count;
362 return; 372 return;
363 } 373 }
364 } 374 }
365 375
366 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange)) ; 376 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange)) ;
367 dp->fIndicesLocation = savedIndices - fPathIndexBuffer.begin(); 377 dp->fIndicesLocation = savedIndices - fPathIndexBuffer.begin();
378 dp->fIndexType = indexType;
379 dp->fTransformsLocation = savedTransforms - fPathTransformBuffer.begin();
380 dp->fTransformType = transformType;
368 dp->fCount = count; 381 dp->fCount = count;
369 dp->fTransformsLocation = savedTransforms - fPathTransformBuffer.begin();
370 dp->fTransformsType = transformsType;
371 dp->fStencilSettings = stencilSettings; 382 dp->fStencilSettings = stencilSettings;
372 383
373 this->recordTraceMarkersIfNecessary(); 384 this->recordTraceMarkersIfNecessary();
374 } 385 }
375 386
376 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color, 387 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color,
377 bool canIgnoreRect, GrRenderTarget* renderTarg et) { 388 bool canIgnoreRect, GrRenderTarget* renderTarg et) {
378 SkASSERT(renderTarget); 389 SkASSERT(renderTarget);
379 SkIRect r; 390 SkIRect r;
380 if (NULL == rect) { 391 if (NULL == rect) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, 526 void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf,
516 const GrOptDrawState* optState) { 527 const GrOptDrawState* optState) {
517 SkASSERT(optState); 528 SkASSERT(optState);
518 buf->fDstGpu->drawPath(*optState, this->path(), fStencilSettings); 529 buf->fDstGpu->drawPath(*optState, this->path(), fStencilSettings);
519 } 530 }
520 531
521 void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, 532 void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf,
522 const GrOptDrawState* optState) { 533 const GrOptDrawState* optState) {
523 SkASSERT(optState); 534 SkASSERT(optState);
524 buf->fDstGpu->drawPaths(*optState, this->pathRange(), 535 buf->fDstGpu->drawPaths(*optState, this->pathRange(),
525 &buf->fPathIndexBuffer[fIndicesLocation], fCount, 536 &buf->fPathIndexBuffer[fIndicesLocation], fIndexType ,
526 &buf->fPathTransformBuffer[fTransformsLocation], fTr ansformsType, 537 &buf->fPathTransformBuffer[fTransformsLocation], fTr ansformType,
527 fStencilSettings); 538 fCount, fStencilSettings);
528 } 539 }
529 540
530 void GrInOrderDrawBuffer::SetState::execute(GrInOrderDrawBuffer*, const GrOptDra wState*) {} 541 void GrInOrderDrawBuffer::SetState::execute(GrInOrderDrawBuffer*, const GrOptDra wState*) {}
531 542
532 void GrInOrderDrawBuffer::Clear::execute(GrInOrderDrawBuffer* buf, const GrOptDr awState*) { 543 void GrInOrderDrawBuffer::Clear::execute(GrInOrderDrawBuffer* buf, const GrOptDr awState*) {
533 if (GrColor_ILLEGAL == fColor) { 544 if (GrColor_ILLEGAL == fColor) {
534 buf->fDstGpu->discard(this->renderTarget()); 545 buf->fDstGpu->discard(this->renderTarget());
535 } else { 546 } else {
536 buf->fDstGpu->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget() ); 547 buf->fDstGpu->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget() );
537 } 548 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 758
748 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { 759 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() {
749 SkASSERT(!fCmdBuffer.empty()); 760 SkASSERT(!fCmdBuffer.empty());
750 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); 761 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType));
751 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); 762 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers();
752 if (activeTraceMarkers.count() > 0) { 763 if (activeTraceMarkers.count() > 0) {
753 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); 764 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType);
754 fGpuCmdMarkers.push_back(activeTraceMarkers); 765 fGpuCmdMarkers.push_back(activeTraceMarkers);
755 } 766 }
756 } 767 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/GrPathRange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698