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/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1054 } else { | 1054 } else { |
1055 SkASSERT(dstSizePtr); | 1055 SkASSERT(dstSizePtr); |
1056 srcRect = *srcRectPtr; | 1056 srcRect = *srcRectPtr; |
1057 dstSize = *dstSizePtr; | 1057 dstSize = *dstSizePtr; |
1058 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 && | 1058 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 && |
1059 srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height ()) { | 1059 srcRect.fRight >= bitmap.width() && srcRect.fBottom >= bitmap.height ()) { |
1060 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_Dr awBitmapRectFlag); | 1060 flags = (SkCanvas::DrawBitmapRectFlags) (flags | SkCanvas::kBleed_Dr awBitmapRectFlag); |
1061 } | 1061 } |
1062 } | 1062 } |
1063 | 1063 |
1064 if (paint.getMaskFilter()){ | 1064 // if the render target is not msaa and draw is antialiased, |
bsalomon
2014/11/26 14:22:48
Can we update the comment to say something like "T
| |
1065 // or the image size exceeds maximum texture size | |
1066 // we must call drawRect instead draw on render target directly | |
1067 int maxTextureSize = fContext->getMaxTextureSize(); | |
1068 bool directDraw = fRenderTarget->isMultisampled() || | |
1069 !paint.isAntiAlias() || | |
1070 bitmap.width() > maxTextureSize || | |
1071 bitmap.height() > maxTextureSize; | |
1072 | |
1073 // we check whether dst rect are pixel aligned | |
1074 if (!directDraw) { | |
1075 bool staysRect = fContext->getMatrix().rectStaysRect(); | |
1076 | |
1077 if (staysRect) { | |
1078 SkRect rect; | |
1079 SkRect dstRect = SkRect::MakeXYWH(0, 0, dstSize.fWidth, dstSize.fHei ght); | |
1080 fContext->getMatrix().mapRect(&rect, dstRect); | |
1081 const SkScalar *scalars = rect.asScalars(); | |
1082 bool isDstPixelAligned = true; | |
1083 for (int i = 0; i < 4; i++) { | |
1084 if (!SkScalarIsInt(scalars[i])) { | |
1085 isDstPixelAligned = false; | |
1086 break; | |
1087 } | |
1088 } | |
1089 | |
1090 if (isDstPixelAligned) | |
1091 directDraw = true; | |
1092 } | |
1093 } | |
1094 | |
1095 if (paint.getMaskFilter() || !directDraw) { | |
1065 // Convert the bitmap to a shader so that the rect can be drawn | 1096 // Convert the bitmap to a shader so that the rect can be drawn |
1066 // through drawRect, which supports mask filters. | 1097 // through drawRect, which supports mask filters. |
1067 SkBitmap tmp; // subset of bitmap, if necessary | 1098 SkBitmap tmp; // subset of bitmap, if necessary |
1068 const SkBitmap* bitmapPtr = &bitmap; | 1099 const SkBitmap* bitmapPtr = &bitmap; |
1069 SkMatrix localM; | 1100 SkMatrix localM; |
1070 if (srcRectPtr) { | 1101 if (srcRectPtr) { |
1071 localM.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop); | 1102 localM.setTranslate(-srcRectPtr->fLeft, -srcRectPtr->fTop); |
1072 localM.postScale(dstSize.fWidth / srcRectPtr->width(), | 1103 localM.postScale(dstSize.fWidth / srcRectPtr->width(), |
1073 dstSize.fHeight / srcRectPtr->height()); | 1104 dstSize.fHeight / srcRectPtr->height()); |
1074 // In bleed mode we position and trim the bitmap based on the src re ct which is | 1105 // In bleed mode we position and trim the bitmap based on the src re ct which is |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1838 return true; | 1869 return true; |
1839 } | 1870 } |
1840 | 1871 |
1841 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1872 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1842 // We always return a transient cache, so it is freed after each | 1873 // We always return a transient cache, so it is freed after each |
1843 // filter traversal. | 1874 // filter traversal. |
1844 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1875 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1845 } | 1876 } |
1846 | 1877 |
1847 #endif | 1878 #endif |
OLD | NEW |