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 "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 | 1035 |
1036 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill(grPaint.get
Color(), | 1036 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill(grPaint.get
Color(), |
1037 viewMatrix, | 1037 viewMatrix, |
1038 matrix, | 1038 matrix, |
1039 dstRect, | 1039 dstRect, |
1040 devRect)); | 1040 devRect)); |
1041 | 1041 |
1042 drawContext->drawBatch(renderTarget, clip, grPaint, batch); | 1042 drawContext->drawBatch(renderTarget, clip, grPaint, batch); |
1043 } | 1043 } |
1044 | 1044 |
| 1045 static bool can_ignore_strict_subset_constraint(const SkBitmap& bitmap, const Sk
Rect& subset) { |
| 1046 GrTexture* tex = bitmap.getTexture(); |
| 1047 int width = tex ? tex->width() : bitmap.width(); |
| 1048 int height = tex ? tex->height() : bitmap.height(); |
| 1049 return subset.contains(SkRect::MakeIWH(width, height)); |
| 1050 } |
| 1051 |
1045 void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, | 1052 void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, |
1046 const SkBitmap& bitmap, | 1053 const SkBitmap& bitmap, |
1047 const SkRect* srcRectPtr, | 1054 const SkRect* srcRectPtr, |
1048 const SkSize* dstSizePtr, | 1055 const SkSize* dstSizePtr, |
1049 const SkPaint& paint, | 1056 const SkPaint& paint, |
1050 SkCanvas::SrcRectConstraint constraint) { | 1057 SkCanvas::SrcRectConstraint constraint) { |
1051 CHECK_SHOULD_DRAW(draw); | 1058 CHECK_SHOULD_DRAW(draw); |
1052 | 1059 |
1053 SkRect srcRect; | 1060 SkRect srcRect; |
1054 SkSize dstSize; | 1061 SkSize dstSize; |
1055 // If there is no src rect, or the src rect contains the entire bitmap then
we're effectively | 1062 // If there is no src rect, or the src rect contains the entire bitmap then
we're effectively |
1056 // in the (easier) bleed case, so update flags. | 1063 // in the (easier) bleed case, so update flags. |
1057 if (nullptr == srcRectPtr) { | 1064 if (nullptr == srcRectPtr) { |
1058 SkScalar w = SkIntToScalar(bitmap.width()); | 1065 SkScalar w = SkIntToScalar(bitmap.width()); |
1059 SkScalar h = SkIntToScalar(bitmap.height()); | 1066 SkScalar h = SkIntToScalar(bitmap.height()); |
1060 dstSize.fWidth = w; | 1067 dstSize.fWidth = w; |
1061 dstSize.fHeight = h; | 1068 dstSize.fHeight = h; |
1062 srcRect.set(0, 0, w, h); | 1069 srcRect.set(0, 0, w, h); |
1063 } else { | 1070 } else { |
1064 SkASSERT(dstSizePtr); | 1071 SkASSERT(dstSizePtr); |
1065 srcRect = *srcRectPtr; | 1072 srcRect = *srcRectPtr; |
1066 dstSize = *dstSizePtr; | 1073 dstSize = *dstSizePtr; |
1067 } | 1074 } |
1068 GrTexture* tex = bitmap.getTexture(); | 1075 |
1069 int width = tex ? tex->width() : bitmap.width(); | 1076 if (can_ignore_strict_subset_constraint(bitmap, srcRect)) { |
1070 int height = tex ? tex->height() : bitmap.height(); | |
1071 if (srcRect.fLeft <= 0 && srcRect.fTop <= 0 && | |
1072 srcRect.fRight >= width && srcRect.fBottom >= height) { | |
1073 constraint = SkCanvas::kFast_SrcRectConstraint; | 1077 constraint = SkCanvas::kFast_SrcRectConstraint; |
1074 } | 1078 } |
1075 | 1079 |
1076 // If the render target is not msaa and draw is antialiased, we call | 1080 // If the render target is not msaa and draw is antialiased, we call |
1077 // drawRect instead of drawing on the render target directly. | 1081 // drawRect instead of drawing on the render target directly. |
1078 // FIXME: the tiled bitmap code path doesn't currently support | 1082 // FIXME: the tiled bitmap code path doesn't currently support |
1079 // anti-aliased edges, we work around that for now by drawing directly | 1083 // anti-aliased edges, we work around that for now by drawing directly |
1080 // if the image size exceeds maximum texture size. | 1084 // if the image size exceeds maximum texture size. |
1081 int maxTextureSize = fContext->caps()->maxTextureSize(); | 1085 int maxTextureSize = fContext->caps()->maxTextureSize(); |
1082 bool drawAA = !fRenderTarget->isUnifiedMultisampled() && | 1086 bool drawAA = !fRenderTarget->isUnifiedMultisampled() && |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 #endif | 1978 #endif |
1975 } | 1979 } |
1976 | 1980 |
1977 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1981 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1978 // We always return a transient cache, so it is freed after each | 1982 // We always return a transient cache, so it is freed after each |
1979 // filter traversal. | 1983 // filter traversal. |
1980 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1984 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1981 } | 1985 } |
1982 | 1986 |
1983 #endif | 1987 #endif |
OLD | NEW |