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

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

Issue 23712005: Add bevel-stroke support in GrAARectRenderer (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: remove changes for GM/rects.cpp, and revised the code according to Brian and Rob's suggestions Created 7 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 | Annotate | Revision Log
« src/gpu/GrAARectRenderer.cpp ('K') | « src/gpu/GrContext.cpp ('k') | no next file » | 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/GrTextureDomainEffect.h" 10 #include "effects/GrTextureDomainEffect.h"
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 646
647 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, 647 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
648 const SkPaint& paint) { 648 const SkPaint& paint) {
649 CHECK_FOR_NODRAW_ANNOTATION(paint); 649 CHECK_FOR_NODRAW_ANNOTATION(paint);
650 CHECK_SHOULD_DRAW(draw, false); 650 CHECK_SHOULD_DRAW(draw, false);
651 651
652 bool doStroke = paint.getStyle() != SkPaint::kFill_Style; 652 bool doStroke = paint.getStyle() != SkPaint::kFill_Style;
653 SkScalar width = paint.getStrokeWidth(); 653 SkScalar width = paint.getStrokeWidth();
654 654
655 /* 655 /*
656 We have special code for hairline strokes, miter-strokes, and fills. 656 We have special code for hairline strokes, miter-strokes, bevel-stroke
657 Anything else we just call our path code. 657 and fills. Anything else we just call our path code.
658 */ 658 */
659 bool usePath = doStroke && width > 0 && 659 bool usePath = doStroke && width > 0 &&
660 paint.getStrokeJoin() != SkPaint::kMiter_Join; 660 paint.getStrokeJoin() == SkPaint::kRound_Join;
661 // another two reasons we might need to call drawPath... 661 // another two reasons we might need to call drawPath...
662 if (paint.getMaskFilter() || paint.getPathEffect()) { 662 if (paint.getMaskFilter() || paint.getPathEffect()) {
663 usePath = true; 663 usePath = true;
664 } 664 }
665 if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect( )) { 665 if (!usePath && paint.isAntiAlias() && !fContext->getMatrix().rectStaysRect( )) {
666 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) 666 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
667 if (doStroke) { 667 if (doStroke) {
668 #endif 668 #endif
669 usePath = true; 669 usePath = true;
670 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) 670 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
671 } else { 671 } else {
672 usePath = !fContext->getMatrix().preservesRightAngles(); 672 usePath = !fContext->getMatrix().preservesRightAngles();
673 } 673 }
674 #endif 674 #endif
675 } 675 }
676 // small miter limit means right angles show bevel...
677 if (SkPaint::kMiter_Join == paint.getStrokeJoin() &&
678 paint.getStrokeMiter() < SK_ScalarSqrt2)
679 {
680 usePath = true;
681 }
682 // until we can both stroke and fill rectangles 676 // until we can both stroke and fill rectangles
683 if (paint.getStyle() == SkPaint::kStrokeAndFill_Style) { 677 if (paint.getStyle() == SkPaint::kStrokeAndFill_Style) {
684 usePath = true; 678 usePath = true;
685 } 679 }
686 680
687 if (usePath) { 681 if (usePath) {
688 SkPath path; 682 SkPath path;
689 path.addRect(rect); 683 path.addRect(rect);
690 this->drawPath(draw, path, paint, NULL, true); 684 this->drawPath(draw, path, paint, NULL, true);
691 return; 685 return;
692 } 686 }
693 687
694 GrPaint grPaint; 688 GrPaint grPaint;
695 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { 689 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) {
696 return; 690 return;
697 } 691 }
698 fContext->drawRect(grPaint, rect, doStroke ? width : -1); 692
693 if (!doStroke) {
694 fContext->drawRect(grPaint, rect);
695 } else {
696 SkStrokeRec stroke(paint);
697 fContext->drawRect(grPaint, rect, &stroke);
698 }
699 } 699 }
700 700
701 /////////////////////////////////////////////////////////////////////////////// 701 ///////////////////////////////////////////////////////////////////////////////
702 702
703 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, 703 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
704 const SkPaint& paint) { 704 const SkPaint& paint) {
705 CHECK_FOR_NODRAW_ANNOTATION(paint); 705 CHECK_FOR_NODRAW_ANNOTATION(paint);
706 CHECK_SHOULD_DRAW(draw, false); 706 CHECK_SHOULD_DRAW(draw, false);
707 707
708 bool usePath = !rect.isSimple(); 708 bool usePath = !rect.isSimple();
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 GrTexture* texture, 1878 GrTexture* texture,
1879 bool needClear) 1879 bool needClear)
1880 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1880 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1881 1881
1882 SkASSERT(texture && texture->asRenderTarget()); 1882 SkASSERT(texture && texture->asRenderTarget());
1883 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1883 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1884 // cache. We pass true for the third argument so that it will get unlocked. 1884 // cache. We pass true for the third argument so that it will get unlocked.
1885 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1885 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1886 fNeedClear = needClear; 1886 fNeedClear = needClear;
1887 } 1887 }
OLDNEW
« src/gpu/GrAARectRenderer.cpp ('K') | « src/gpu/GrContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698