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

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

Issue 378933002: Improve gpu tracing when applying markers directly to gpu target (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « src/gpu/GrTraceMarker.cpp ('k') | src/gpu/gl/GrGpuGL.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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "effects/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 SK_COMPILE_ASSERT(SkShader::kTwoPointRadial_BitmapType == 4, 337 SK_COMPILE_ASSERT(SkShader::kTwoPointRadial_BitmapType == 4,
338 shader_type_mismatch); 338 shader_type_mismatch);
339 SK_COMPILE_ASSERT(SkShader::kTwoPointConical_BitmapType == 5, 339 SK_COMPILE_ASSERT(SkShader::kTwoPointConical_BitmapType == 5,
340 shader_type_mismatch); 340 shader_type_mismatch);
341 SK_COMPILE_ASSERT(SkShader::kLinear_BitmapType == 6, shader_type_mismatch); 341 SK_COMPILE_ASSERT(SkShader::kLinear_BitmapType == 6, shader_type_mismatch);
342 SK_COMPILE_ASSERT(SkShader::kLast_BitmapType == 6, shader_type_mismatch); 342 SK_COMPILE_ASSERT(SkShader::kLast_BitmapType == 6, shader_type_mismatch);
343 343
344 /////////////////////////////////////////////////////////////////////////////// 344 ///////////////////////////////////////////////////////////////////////////////
345 345
346 void SkGpuDevice::clear(SkColor color) { 346 void SkGpuDevice::clear(SkColor color) {
347 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::clear", fContext);
347 SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); 348 SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
348 fContext->clear(&rect, SkColor2GrColor(color), true, fRenderTarget); 349 fContext->clear(&rect, SkColor2GrColor(color), true, fRenderTarget);
349 fNeedClear = false; 350 fNeedClear = false;
350 } 351 }
351 352
352 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { 353 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
353 CHECK_SHOULD_DRAW(draw, false); 354 CHECK_SHOULD_DRAW(draw, false);
355 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext);
354 356
355 GrPaint grPaint; 357 GrPaint grPaint;
356 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); 358 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
357 359
358 fContext->drawPaint(grPaint); 360 fContext->drawPaint(grPaint);
359 } 361 }
360 362
361 // must be in SkCanvas::PointMode order 363 // must be in SkCanvas::PointMode order
362 static const GrPrimitiveType gPointMode2PrimtiveType[] = { 364 static const GrPrimitiveType gPointMode2PrimtiveType[] = {
363 kPoints_GrPrimitiveType, 365 kPoints_GrPrimitiveType,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 GrPaint grPaint; 466 GrPaint grPaint;
465 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); 467 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
466 468
467 fContext->drawRect(grPaint, rect, &strokeInfo); 469 fContext->drawRect(grPaint, rect, &strokeInfo);
468 } 470 }
469 471
470 /////////////////////////////////////////////////////////////////////////////// 472 ///////////////////////////////////////////////////////////////////////////////
471 473
472 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, 474 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
473 const SkPaint& paint) { 475 const SkPaint& paint) {
476 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext);
474 CHECK_FOR_ANNOTATION(paint); 477 CHECK_FOR_ANNOTATION(paint);
475 CHECK_SHOULD_DRAW(draw, false); 478 CHECK_SHOULD_DRAW(draw, false);
476 479
477 GrPaint grPaint; 480 GrPaint grPaint;
478 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); 481 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
479 482
480 GrStrokeInfo strokeInfo(paint); 483 GrStrokeInfo strokeInfo(paint);
481 if (paint.getMaskFilter()) { 484 if (paint.getMaskFilter()) {
482 // try to hit the fast path for drawing filtered round rects 485 // try to hit the fast path for drawing filtered round rects
483 486
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 path.setFillType(SkPath::kEvenOdd_FillType); 555 path.setFillType(SkPath::kEvenOdd_FillType);
553 556
554 this->drawPath(draw, path, paint, NULL, true); 557 this->drawPath(draw, path, paint, NULL, true);
555 } 558 }
556 559
557 560
558 ///////////////////////////////////////////////////////////////////////////// 561 /////////////////////////////////////////////////////////////////////////////
559 562
560 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, 563 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
561 const SkPaint& paint) { 564 const SkPaint& paint) {
565 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawOval", fContext);
562 CHECK_FOR_ANNOTATION(paint); 566 CHECK_FOR_ANNOTATION(paint);
563 CHECK_SHOULD_DRAW(draw, false); 567 CHECK_SHOULD_DRAW(draw, false);
564 568
565 GrStrokeInfo strokeInfo(paint); 569 GrStrokeInfo strokeInfo(paint);
566 570
567 bool usePath = false; 571 bool usePath = false;
568 // some basic reasons we might need to call drawPath... 572 // some basic reasons we might need to call drawPath...
569 if (paint.getMaskFilter()) { 573 if (paint.getMaskFilter()) {
570 usePath = true; 574 usePath = true;
571 } else { 575 } else {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 return result; 721 return result;
718 } 722 }
719 723
720 }; 724 };
721 725
722 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, 726 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
723 const SkPaint& paint, const SkMatrix* prePathMatrix, 727 const SkPaint& paint, const SkMatrix* prePathMatrix,
724 bool pathIsMutable) { 728 bool pathIsMutable) {
725 CHECK_FOR_ANNOTATION(paint); 729 CHECK_FOR_ANNOTATION(paint);
726 CHECK_SHOULD_DRAW(draw, false); 730 CHECK_SHOULD_DRAW(draw, false);
731 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext);
727 732
728 GrPaint grPaint; 733 GrPaint grPaint;
729 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); 734 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
730 735
731 // If we have a prematrix, apply it to the path, optimizing for the case 736 // If we have a prematrix, apply it to the path, optimizing for the case
732 // where the original path can in fact be modified in place (even though 737 // where the original path can in fact be modified in place (even though
733 // its parameter type is const). 738 // its parameter type is const).
734 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); 739 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath);
735 SkTLazy<SkPath> tmpPath; 740 SkTLazy<SkPath> tmpPath;
736 SkTLazy<SkPath> effectPath; 741 SkTLazy<SkPath> effectPath;
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 SkSize dstSize; 1498 SkSize dstSize;
1494 dstSize.fWidth = tmpDst.width(); 1499 dstSize.fWidth = tmpDst.width();
1495 dstSize.fHeight = tmpDst.height(); 1500 dstSize.fHeight = tmpDst.height();
1496 1501
1497 this->drawBitmapCommon(*draw, bitmap, &tmpSrc, &dstSize, paint, flags); 1502 this->drawBitmapCommon(*draw, bitmap, &tmpSrc, &dstSize, paint, flags);
1498 } 1503 }
1499 1504
1500 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, 1505 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
1501 int x, int y, const SkPaint& paint) { 1506 int x, int y, const SkPaint& paint) {
1502 // clear of the source device must occur before CHECK_SHOULD_DRAW 1507 // clear of the source device must occur before CHECK_SHOULD_DRAW
1508 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDevice", fContext);
1503 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); 1509 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device);
1504 if (dev->fNeedClear) { 1510 if (dev->fNeedClear) {
1505 // TODO: could check here whether we really need to draw at all 1511 // TODO: could check here whether we really need to draw at all
1506 dev->clear(0x0); 1512 dev->clear(0x0);
1507 } 1513 }
1508 1514
1509 // drawDevice is defined to be in device coords. 1515 // drawDevice is defined to be in device coords.
1510 CHECK_SHOULD_DRAW(draw, true); 1516 CHECK_SHOULD_DRAW(draw, true);
1511 1517
1512 GrRenderTarget* devRT = dev->accessRenderTarget(); 1518 GrRenderTarget* devRT = dev->accessRenderTarget();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 }; 1604 };
1599 1605
1600 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, 1606 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
1601 int vertexCount, const SkPoint vertices[], 1607 int vertexCount, const SkPoint vertices[],
1602 const SkPoint texs[], const SkColor colors[], 1608 const SkPoint texs[], const SkColor colors[],
1603 SkXfermode* xmode, 1609 SkXfermode* xmode,
1604 const uint16_t indices[], int indexCount, 1610 const uint16_t indices[], int indexCount,
1605 const SkPaint& paint) { 1611 const SkPaint& paint) {
1606 CHECK_SHOULD_DRAW(draw, false); 1612 CHECK_SHOULD_DRAW(draw, false);
1607 1613
1614 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawVertices", fContext);
1608 // If both textures and vertex-colors are NULL, strokes hairlines with the p aint's color. 1615 // If both textures and vertex-colors are NULL, strokes hairlines with the p aint's color.
1609 if ((NULL == texs || NULL == paint.getShader()) && NULL == colors) { 1616 if ((NULL == texs || NULL == paint.getShader()) && NULL == colors) {
1610 texs = NULL; 1617 texs = NULL;
1611 SkPaint copy(paint); 1618 SkPaint copy(paint);
1612 copy.setStyle(SkPaint::kStroke_Style); 1619 copy.setStyle(SkPaint::kStroke_Style);
1613 copy.setStrokeWidth(0); 1620 copy.setStrokeWidth(0);
1614 1621
1615 VertState state(vertexCount, indices, indexCount); 1622 VertState state(vertexCount, indices, indexCount);
1616 VertState::Proc vertProc = state.chooseProc(vmode); 1623 VertState::Proc vertProc = state.chooseProc(vmode);
1617 1624
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 indices, 1678 indices,
1672 indexCount); 1679 indexCount);
1673 } 1680 }
1674 1681
1675 /////////////////////////////////////////////////////////////////////////////// 1682 ///////////////////////////////////////////////////////////////////////////////
1676 1683
1677 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, 1684 void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
1678 size_t byteLength, SkScalar x, SkScalar y, 1685 size_t byteLength, SkScalar x, SkScalar y,
1679 const SkPaint& paint) { 1686 const SkPaint& paint) {
1680 CHECK_SHOULD_DRAW(draw, false); 1687 CHECK_SHOULD_DRAW(draw, false);
1688 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
1681 1689
1682 if (fMainTextContext->canDraw(paint)) { 1690 if (fMainTextContext->canDraw(paint)) {
1683 GrPaint grPaint; 1691 GrPaint grPaint;
1684 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint); 1692 SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
1685 1693
1686 SkDEBUGCODE(this->validate();) 1694 SkDEBUGCODE(this->validate();)
1687 1695
1688 fMainTextContext->drawText(grPaint, paint, (const char *)text, byteLengt h, x, y); 1696 fMainTextContext->drawText(grPaint, paint, (const char *)text, byteLengt h, x, y);
1689 } else if (fFallbackTextContext && fFallbackTextContext->canDraw(paint)) { 1697 } else if (fFallbackTextContext && fFallbackTextContext->canDraw(paint)) {
1690 GrPaint grPaint; 1698 GrPaint grPaint;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2028 playback.draw(canvas, NULL); 2036 playback.draw(canvas, NULL);
2029 2037
2030 // unlock the layers 2038 // unlock the layers
2031 for (int i = 0; i < gpuData->numSaveLayers(); ++i) { 2039 for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
2032 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, i); 2040 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, i);
2033 fContext->getLayerCache()->unlock(layer); 2041 fContext->getLayerCache()->unlock(layer);
2034 } 2042 }
2035 2043
2036 return true; 2044 return true;
2037 } 2045 }
OLDNEW
« no previous file with comments | « src/gpu/GrTraceMarker.cpp ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698