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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 GrStrokeInfo strokeInfo(paint); | 634 GrStrokeInfo strokeInfo(paint); |
635 SkASSERT(!strokeInfo.isDashed()); | 635 SkASSERT(!strokeInfo.isDashed()); |
636 | 636 |
637 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, strokeInfo); | 637 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, strokeInfo); |
638 } | 638 } |
639 | 639 |
640 #include "SkMaskFilter.h" | 640 #include "SkMaskFilter.h" |
641 | 641 |
642 /////////////////////////////////////////////////////////////////////////////// | 642 /////////////////////////////////////////////////////////////////////////////// |
643 | 643 |
644 static SkBitmap wrap_texture(GrTexture* texture, int width, int height) { | |
645 SkBitmap result; | |
646 result.setInfo(SkImageInfo::MakeN32Premul(width, height)); | |
647 result.setPixelRef(new SkGrPixelRef(result.info(), texture))->unref(); | |
648 return result; | |
649 } | |
650 | |
651 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, | 644 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
652 const SkPaint& paint, const SkMatrix* prePathMatrix, | 645 const SkPaint& paint, const SkMatrix* prePathMatrix, |
653 bool pathIsMutable) { | 646 bool pathIsMutable) { |
654 ASSERT_SINGLE_OWNER | 647 ASSERT_SINGLE_OWNER |
655 if (!origSrcPath.isInverseFillType() && !paint.getPathEffect() && !prePathMa
trix) { | 648 if (!origSrcPath.isInverseFillType() && !paint.getPathEffect() && !prePathMa
trix) { |
656 bool isClosed; | 649 bool isClosed; |
657 SkRect rect; | 650 SkRect rect; |
658 if (origSrcPath.isRect(&rect, &isClosed) && isClosed) { | 651 if (origSrcPath.isRect(&rect, &isClosed) && isClosed) { |
659 this->drawRect(draw, rect, paint); | 652 this->drawRect(draw, rect, paint); |
660 return; | 653 return; |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 int width, int height, | 1125 int width, int height, |
1133 const SkImageFilter* filter, | 1126 const SkImageFilter* filter, |
1134 const SkImageFilter::Context& ctx, | 1127 const SkImageFilter::Context& ctx, |
1135 SkBitmap* result, SkIPoint* offset) { | 1128 SkBitmap* result, SkIPoint* offset) { |
1136 ASSERT_SINGLE_OWNER | 1129 ASSERT_SINGLE_OWNER |
1137 SkASSERT(filter); | 1130 SkASSERT(filter); |
1138 | 1131 |
1139 SkImageFilter::DeviceProxy proxy(this); | 1132 SkImageFilter::DeviceProxy proxy(this); |
1140 | 1133 |
1141 if (filter->canFilterImageGPU()) { | 1134 if (filter->canFilterImageGPU()) { |
1142 return filter->filterImageGPU(&proxy, wrap_texture(texture, width, heigh
t), | 1135 SkBitmap bm; |
1143 ctx, result, offset); | 1136 GrWrapTextureInBitmap(texture, width, height, false, &bm); |
| 1137 return filter->filterImageGPU(&proxy, bm, ctx, result, offset); |
1144 } else { | 1138 } else { |
1145 return false; | 1139 return false; |
1146 } | 1140 } |
1147 } | 1141 } |
1148 | 1142 |
1149 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, | 1143 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, |
1150 int left, int top, const SkPaint& paint) { | 1144 int left, int top, const SkPaint& paint) { |
1151 ASSERT_SINGLE_OWNER | 1145 ASSERT_SINGLE_OWNER |
1152 // drawSprite is defined to be in device coords. | 1146 // drawSprite is defined to be in device coords. |
1153 CHECK_SHOULD_DRAW(draw); | 1147 CHECK_SHOULD_DRAW(draw); |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 } | 1908 } |
1915 | 1909 |
1916 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1910 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1917 ASSERT_SINGLE_OWNER | 1911 ASSERT_SINGLE_OWNER |
1918 // We always return a transient cache, so it is freed after each | 1912 // We always return a transient cache, so it is freed after each |
1919 // filter traversal. | 1913 // filter traversal. |
1920 return SkGpuDevice::NewImageFilterCache(); | 1914 return SkGpuDevice::NewImageFilterCache(); |
1921 } | 1915 } |
1922 | 1916 |
1923 #endif | 1917 #endif |
OLD | NEW |