| 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" |
| 11 #include "effects/GrSimpleTextureEffect.h" | 11 #include "effects/GrSimpleTextureEffect.h" |
| 12 | 12 |
| 13 #include "GrContext.h" | 13 #include "GrContext.h" |
| 14 #include "GrTextContext.h" | 14 #include "GrTextContext.h" |
| 15 | 15 |
| 16 #include "SkGrTexturePixelRef.h" | 16 #include "SkGrTexturePixelRef.h" |
| 17 | 17 |
| 18 #include "SkColorFilter.h" | 18 #include "SkColorFilter.h" |
| 19 #include "SkDeviceImageFilterProxy.h" | 19 #include "SkDeviceImageFilterProxy.h" |
| 20 #include "SkDrawProcs.h" | 20 #include "SkDrawProcs.h" |
| 21 #include "SkGlyphCache.h" | 21 #include "SkGlyphCache.h" |
| 22 #include "SkImageFilter.h" | 22 #include "SkImageFilter.h" |
| 23 #include "SkPathEffect.h" | 23 #include "SkPathEffect.h" |
| 24 #include "SkRRect.h" |
| 24 #include "SkStroke.h" | 25 #include "SkStroke.h" |
| 25 #include "SkUtils.h" | 26 #include "SkUtils.h" |
| 26 | 27 |
| 27 #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1 | 28 #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1 |
| 28 | 29 |
| 29 #if 0 | 30 #if 0 |
| 30 extern bool (*gShouldDrawProc)(); | 31 extern bool (*gShouldDrawProc)(); |
| 31 #define CHECK_SHOULD_DRAW(draw, forceI) \ | 32 #define CHECK_SHOULD_DRAW(draw, forceI) \ |
| 32 do { \ | 33 do { \ |
| 33 if (gShouldDrawProc && !gShouldDrawProc()) return; \ | 34 if (gShouldDrawProc && !gShouldDrawProc()) return; \ |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 | 701 |
| 701 GrPaint grPaint; | 702 GrPaint grPaint; |
| 702 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { | 703 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
| 703 return; | 704 return; |
| 704 } | 705 } |
| 705 fContext->drawRect(grPaint, rect, doStroke ? width : -1); | 706 fContext->drawRect(grPaint, rect, doStroke ? width : -1); |
| 706 } | 707 } |
| 707 | 708 |
| 708 /////////////////////////////////////////////////////////////////////////////// | 709 /////////////////////////////////////////////////////////////////////////////// |
| 709 | 710 |
| 711 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
| 712 const SkPaint& paint) { |
| 713 CHECK_FOR_NODRAW_ANNOTATION(paint); |
| 714 CHECK_SHOULD_DRAW(draw, false); |
| 715 |
| 716 bool usePath = !rect.isSimple() || !paint.isAntiAlias(); |
| 717 // another two reasons we might need to call drawPath... |
| 718 if (paint.getMaskFilter() || paint.getPathEffect()) { |
| 719 usePath = true; |
| 720 } |
| 721 // until we can rotate rrects... |
| 722 if (!usePath && !fContext->getMatrix().rectStaysRect()) { |
| 723 usePath = true; |
| 724 } |
| 725 |
| 726 if (usePath) { |
| 727 SkPath path; |
| 728 path.addRRect(rect); |
| 729 this->drawPath(draw, path, paint, NULL, true); |
| 730 return; |
| 731 } |
| 732 |
| 733 GrPaint grPaint; |
| 734 if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
| 735 return; |
| 736 } |
| 737 |
| 738 SkStrokeRec stroke(paint); |
| 739 fContext->drawRRect(grPaint, rect, stroke); |
| 740 } |
| 741 |
| 742 /////////////////////////////////////////////////////////////////////////////// |
| 743 |
| 710 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, | 744 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, |
| 711 const SkPaint& paint) { | 745 const SkPaint& paint) { |
| 712 CHECK_FOR_NODRAW_ANNOTATION(paint); | 746 CHECK_FOR_NODRAW_ANNOTATION(paint); |
| 713 CHECK_SHOULD_DRAW(draw, false); | 747 CHECK_SHOULD_DRAW(draw, false); |
| 714 | 748 |
| 715 bool usePath = false; | 749 bool usePath = false; |
| 716 // some basic reasons we might need to call drawPath... | 750 // some basic reasons we might need to call drawPath... |
| 717 if (paint.getMaskFilter() || paint.getPathEffect()) { | 751 if (paint.getMaskFilter() || paint.getPathEffect()) { |
| 718 usePath = true; | 752 usePath = true; |
| 719 } | 753 } |
| (...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 GrTexture* texture, | 1858 GrTexture* texture, |
| 1825 bool needClear) | 1859 bool needClear) |
| 1826 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { | 1860 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { |
| 1827 | 1861 |
| 1828 GrAssert(texture && texture->asRenderTarget()); | 1862 GrAssert(texture && texture->asRenderTarget()); |
| 1829 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1863 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
| 1830 // cache. We pass true for the third argument so that it will get unlocked. | 1864 // cache. We pass true for the third argument so that it will get unlocked. |
| 1831 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1865 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
| 1832 fNeedClear = needClear; | 1866 fNeedClear = needClear; |
| 1833 } | 1867 } |
| OLD | NEW |