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 22 matching lines...) Expand all Loading... |
33 #include "SkRRect.h" | 33 #include "SkRRect.h" |
34 #include "SkRecord.h" | 34 #include "SkRecord.h" |
35 #include "SkStroke.h" | 35 #include "SkStroke.h" |
36 #include "SkSurface.h" | 36 #include "SkSurface.h" |
37 #include "SkSurface_Gpu.h" | 37 #include "SkSurface_Gpu.h" |
38 #include "SkTLazy.h" | 38 #include "SkTLazy.h" |
39 #include "SkUtils.h" | 39 #include "SkUtils.h" |
40 #include "SkVertState.h" | 40 #include "SkVertState.h" |
41 #include "SkXfermode.h" | 41 #include "SkXfermode.h" |
42 #include "batches/GrRectBatchFactory.h" | 42 #include "batches/GrRectBatchFactory.h" |
| 43 #include "draws/GrDrawRect.h" |
43 #include "effects/GrBicubicEffect.h" | 44 #include "effects/GrBicubicEffect.h" |
44 #include "effects/GrDashingEffect.h" | 45 #include "effects/GrDashingEffect.h" |
45 #include "effects/GrSimpleTextureEffect.h" | 46 #include "effects/GrSimpleTextureEffect.h" |
46 #include "effects/GrTextureDomain.h" | 47 #include "effects/GrTextureDomain.h" |
47 | 48 |
48 #if SK_SUPPORT_GPU | 49 #if SK_SUPPORT_GPU |
49 | 50 |
50 enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; | 51 enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; |
51 | 52 |
52 #if 0 | 53 #if 0 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 usePath = true; | 500 usePath = true; |
500 } | 501 } |
501 | 502 |
502 GrStrokeInfo strokeInfo(paint); | 503 GrStrokeInfo strokeInfo(paint); |
503 | 504 |
504 const SkPathEffect* pe = paint.getPathEffect(); | 505 const SkPathEffect* pe = paint.getPathEffect(); |
505 if (!usePath && pe && !strokeInfo.isDashed()) { | 506 if (!usePath && pe && !strokeInfo.isDashed()) { |
506 usePath = true; | 507 usePath = true; |
507 } | 508 } |
508 | 509 |
| 510 if (strokeInfo.isDashed()) { |
| 511 usePath = true; |
| 512 } |
| 513 |
509 if (usePath) { | 514 if (usePath) { |
510 SkPath path; | 515 SkPath path; |
511 path.setIsVolatile(true); | 516 path.setIsVolatile(true); |
512 path.addRect(rect); | 517 path.addRect(rect); |
513 this->drawPath(draw, path, paint, nullptr, true); | 518 this->drawPath(draw, path, paint, nullptr, true); |
514 return; | 519 return; |
515 } | 520 } |
516 | 521 |
517 GrPaint grPaint; | 522 GrDrawRect grDraw(fRenderTarget, fContext, fClip, paint, *draw.fMatrix, rect
, &strokeInfo); |
518 if (!SkPaint2GrPaint(this->context(), paint, *draw.fMatrix, true, &grPaint))
{ | 523 grDraw.execute(fDrawContext); |
519 return; | |
520 } | |
521 | |
522 fDrawContext->drawRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, rect, &
strokeInfo); | |
523 } | 524 } |
524 | 525 |
525 /////////////////////////////////////////////////////////////////////////////// | 526 /////////////////////////////////////////////////////////////////////////////// |
526 | 527 |
527 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 528 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
528 const SkPaint& paint) { | 529 const SkPaint& paint) { |
529 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext); | 530 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext); |
530 CHECK_FOR_ANNOTATION(paint); | 531 CHECK_FOR_ANNOTATION(paint); |
531 CHECK_SHOULD_DRAW(draw); | 532 CHECK_SHOULD_DRAW(draw); |
532 | 533 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 if (!SkPaint2GrPaintNoShader(context, paint, SkColor2GrColor(paint.getColor(
)), false, | 1013 if (!SkPaint2GrPaintNoShader(context, paint, SkColor2GrColor(paint.getColor(
)), false, |
1013 &grPaint)) { | 1014 &grPaint)) { |
1014 return; | 1015 return; |
1015 } | 1016 } |
1016 | 1017 |
1017 grPaint.setColor(paintColor); | 1018 grPaint.setColor(paintColor); |
1018 | 1019 |
1019 // Setup dst rect and final matrix | 1020 // Setup dst rect and final matrix |
1020 SkRect dstRect = {0, 0, dstSize.fWidth, dstSize.fHeight}; | 1021 SkRect dstRect = {0, 0, dstSize.fWidth, dstSize.fHeight}; |
1021 | 1022 |
1022 SkRect devRect; | |
1023 viewMatrix.mapRect(&devRect, dstRect); | |
1024 | |
1025 SkMatrix matrix; | 1023 SkMatrix matrix; |
1026 matrix.setIDiv(bitmapPtr->width(), bitmapPtr->height()); | 1024 matrix.setIDiv(bitmapPtr->width(), bitmapPtr->height()); |
1027 | 1025 |
1028 SkMatrix dstRectToSrcRect; | 1026 SkMatrix dstRectToSrcRect; |
1029 if (!srcRectToDstRect.invert(&dstRectToSrcRect)) { | 1027 if (!srcRectToDstRect.invert(&dstRectToSrcRect)) { |
1030 return; | 1028 return; |
1031 } | 1029 } |
1032 matrix.preConcat(dstRectToSrcRect); | 1030 matrix.preConcat(dstRectToSrcRect); |
1033 | 1031 |
1034 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill(grPaint.get
Color(), | 1032 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill(grPaint.get
Color(), |
1035 viewMatrix, | 1033 viewMatrix, |
1036 matrix, | 1034 matrix, |
1037 dstRect, | 1035 dstRect)); |
1038 devRect)); | |
1039 | 1036 |
1040 drawContext->drawBatch(renderTarget, clip, grPaint, batch); | 1037 drawContext->drawBatch(renderTarget, clip, grPaint, batch); |
1041 } | 1038 } |
1042 | 1039 |
1043 static bool can_ignore_strict_subset_constraint(const SkBitmap& bitmap, const Sk
Rect& subset) { | 1040 static bool can_ignore_strict_subset_constraint(const SkBitmap& bitmap, const Sk
Rect& subset) { |
1044 GrTexture* tex = bitmap.getTexture(); | 1041 GrTexture* tex = bitmap.getTexture(); |
1045 int width = tex ? tex->width() : bitmap.width(); | 1042 int width = tex ? tex->width() : bitmap.width(); |
1046 int height = tex ? tex->height() : bitmap.height(); | 1043 int height = tex ? tex->height() : bitmap.height(); |
1047 return subset.contains(SkRect::MakeIWH(width, height)); | 1044 return subset.contains(SkRect::MakeIWH(width, height)); |
1048 } | 1045 } |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1975 #endif | 1972 #endif |
1976 } | 1973 } |
1977 | 1974 |
1978 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1975 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1979 // We always return a transient cache, so it is freed after each | 1976 // We always return a transient cache, so it is freed after each |
1980 // filter traversal. | 1977 // filter traversal. |
1981 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1978 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1982 } | 1979 } |
1983 | 1980 |
1984 #endif | 1981 #endif |
OLD | NEW |