Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/GrTextureDomainEffect.h" | 10 #include "effects/GrTextureDomainEffect.h" |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 629 | 629 |
| 630 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, | 630 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, |
| 631 const SkPaint& paint) { | 631 const SkPaint& paint) { |
| 632 CHECK_FOR_NODRAW_ANNOTATION(paint); | 632 CHECK_FOR_NODRAW_ANNOTATION(paint); |
| 633 CHECK_SHOULD_DRAW(draw, false); | 633 CHECK_SHOULD_DRAW(draw, false); |
| 634 | 634 |
| 635 bool doStroke = paint.getStyle() != SkPaint::kFill_Style; | 635 bool doStroke = paint.getStyle() != SkPaint::kFill_Style; |
| 636 SkScalar width = paint.getStrokeWidth(); | 636 SkScalar width = paint.getStrokeWidth(); |
| 637 | 637 |
| 638 /* | 638 /* |
| 639 We have special code for hairline strokes, miter-strokes, and fills. | 639 We have special code for hairline strokes, miter-strokes, bevel-stroke |
| 640 Anything else we just call our path code. | 640 and fills. Anything else we just call our path code. |
| 641 */ | 641 */ |
| 642 bool usePath = doStroke && width > 0 && | 642 bool usePath = doStroke && width > 0 && |
|
bsalomon
2013/09/17 14:43:49
Can the logic about using a path b/c of stroking b
yunchao
2013/09/22 08:36:37
GrContext::drawRect will not fallback to drawPath.
| |
| 643 paint.getStrokeJoin() != SkPaint::kMiter_Join; | 643 paint.getStrokeJoin() == SkPaint::kRound_Join; |
| 644 // another two reasons we might need to call drawPath... | 644 // another two reasons we might need to call drawPath... |
| 645 if (paint.getMaskFilter() || paint.getPathEffect()) { | 645 if (paint.getMaskFilter() || paint.getPathEffect()) { |
| 646 usePath = true; | 646 usePath = true; |
| 647 } | 647 } |
| 648 if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect( )) { | 648 if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect( )) { |
| 649 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) | 649 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
| 650 if (doStroke) { | 650 if (doStroke) { |
| 651 #endif | 651 #endif |
| 652 usePath = true; | 652 usePath = true; |
| 653 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) | 653 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 671 SkPath path; | 671 SkPath path; |
| 672 path.addRect(rect); | 672 path.addRect(rect); |
| 673 this->drawPath(draw, path, paint, NULL, true); | 673 this->drawPath(draw, path, paint, NULL, true); |
| 674 return; | 674 return; |
| 675 } | 675 } |
| 676 | 676 |
| 677 GrPaint grPaint; | 677 GrPaint grPaint; |
| 678 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { | 678 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
| 679 return; | 679 return; |
| 680 } | 680 } |
| 681 fContext->drawRect(grPaint, rect, doStroke ? width : -1); | 681 bool miterStroke = true; |
| 682 if (paint.getStrokeJoin() != SkPaint::kMiter_Join) { | |
| 683 miterStroke = false; | |
| 684 } | |
| 685 fContext->drawRect(grPaint, rect, doStroke ? width : -1, NULL, miterStroke); | |
| 682 } | 686 } |
| 683 | 687 |
| 684 /////////////////////////////////////////////////////////////////////////////// | 688 /////////////////////////////////////////////////////////////////////////////// |
| 685 | 689 |
| 686 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 690 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
| 687 const SkPaint& paint) { | 691 const SkPaint& paint) { |
| 688 CHECK_FOR_NODRAW_ANNOTATION(paint); | 692 CHECK_FOR_NODRAW_ANNOTATION(paint); |
| 689 CHECK_SHOULD_DRAW(draw, false); | 693 CHECK_SHOULD_DRAW(draw, false); |
| 690 | 694 |
| 691 bool usePath = !rect.isSimple(); | 695 bool usePath = !rect.isSimple(); |
| (...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1864 GrTexture* texture, | 1868 GrTexture* texture, |
| 1865 bool needClear) | 1869 bool needClear) |
| 1866 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1870 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
| 1867 | 1871 |
| 1868 SkASSERT(texture && texture->asRenderTarget()); | 1872 SkASSERT(texture && texture->asRenderTarget()); |
| 1869 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture | 1873 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture |
| 1870 // cache. We pass true for the third argument so that it will get unlocked. | 1874 // cache. We pass true for the third argument so that it will get unlocked. |
| 1871 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1875 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
| 1872 fNeedClear = needClear; | 1876 fNeedClear = needClear; |
| 1873 } | 1877 } |
| OLD | NEW |