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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 302 } |
303 | 303 |
304 /////////////////////////////////////////////////////////////////////////////// | 304 /////////////////////////////////////////////////////////////////////////////// |
305 | 305 |
306 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 306 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
307 ASSERT_SINGLE_OWNER | 307 ASSERT_SINGLE_OWNER |
308 CHECK_SHOULD_DRAW(draw); | 308 CHECK_SHOULD_DRAW(draw); |
309 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext); | 309 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext); |
310 | 310 |
311 GrPaint grPaint; | 311 GrPaint grPaint; |
312 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 312 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.fMat
rix, &grPaint)) { |
313 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), | |
314 &grPaint)) { | |
315 return; | 313 return; |
316 } | 314 } |
317 | 315 |
318 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix); | 316 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix); |
319 } | 317 } |
320 | 318 |
321 // must be in SkCanvas::PointMode order | 319 // must be in SkCanvas::PointMode order |
322 static const GrPrimitiveType gPointMode2PrimtiveType[] = { | 320 static const GrPrimitiveType gPointMode2PrimtiveType[] = { |
323 kPoints_GrPrimitiveType, | 321 kPoints_GrPrimitiveType, |
324 kLines_GrPrimitiveType, | 322 kLines_GrPrimitiveType, |
(...skipping 29 matching lines...) Expand all Loading... |
354 CHECK_SHOULD_DRAW(draw); | 352 CHECK_SHOULD_DRAW(draw); |
355 | 353 |
356 SkScalar width = paint.getStrokeWidth(); | 354 SkScalar width = paint.getStrokeWidth(); |
357 if (width < 0) { | 355 if (width < 0) { |
358 return; | 356 return; |
359 } | 357 } |
360 | 358 |
361 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod
e) { | 359 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod
e) { |
362 GrStyle style(paint, SkPaint::kStroke_Style); | 360 GrStyle style(paint, SkPaint::kStroke_Style); |
363 GrPaint grPaint; | 361 GrPaint grPaint; |
364 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 362 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.
fMatrix, |
365 this->surfaceProps().isGammaCorrect(), fDrawContex
t->getColorSpace(), | |
366 &grPaint)) { | 363 &grPaint)) { |
367 return; | 364 return; |
368 } | 365 } |
369 SkPath path; | 366 SkPath path; |
370 path.setIsVolatile(true); | 367 path.setIsVolatile(true); |
371 path.moveTo(pts[0]); | 368 path.moveTo(pts[0]); |
372 path.lineTo(pts[1]); | 369 path.lineTo(pts[1]); |
373 fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, style); | 370 fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, style); |
374 return; | 371 return; |
375 } | 372 } |
376 | 373 |
377 // we only handle non-antialiased hairlines and paints without path effects
or mask filters, | 374 // we only handle non-antialiased hairlines and paints without path effects
or mask filters, |
378 // else we let the SkDraw call our drawPath() | 375 // else we let the SkDraw call our drawPath() |
379 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() || | 376 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() || |
380 (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) { | 377 (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) { |
381 draw.drawPoints(mode, count, pts, paint, true); | 378 draw.drawPoints(mode, count, pts, paint, true); |
382 return; | 379 return; |
383 } | 380 } |
384 | 381 |
385 GrPaint grPaint; | 382 GrPaint grPaint; |
386 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 383 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.fMat
rix, &grPaint)) { |
387 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), | |
388 &grPaint)) { | |
389 return; | 384 return; |
390 } | 385 } |
391 | 386 |
392 fDrawContext->drawVertices(fClip, | 387 fDrawContext->drawVertices(fClip, |
393 grPaint, | 388 grPaint, |
394 *draw.fMatrix, | 389 *draw.fMatrix, |
395 gPointMode2PrimtiveType[mode], | 390 gPointMode2PrimtiveType[mode], |
396 SkToS32(count), | 391 SkToS32(count), |
397 (SkPoint*)pts, | 392 (SkPoint*)pts, |
398 nullptr, | 393 nullptr, |
(...skipping 16 matching lines...) Expand all Loading... |
415 path.setIsVolatile(true); | 410 path.setIsVolatile(true); |
416 path.addRect(rect); | 411 path.addRect(rect); |
417 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext.get(), | 412 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext.get(), |
418 fClip, path, paint, | 413 fClip, path, paint, |
419 *draw.fMatrix, nullptr, | 414 *draw.fMatrix, nullptr, |
420 draw.fRC->getBounds(), true); | 415 draw.fRC->getBounds(), true); |
421 return; | 416 return; |
422 } | 417 } |
423 | 418 |
424 GrPaint grPaint; | 419 GrPaint grPaint; |
425 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 420 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.fMat
rix, &grPaint)) { |
426 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), | |
427 &grPaint)) { | |
428 return; | 421 return; |
429 } | 422 } |
430 | 423 |
431 GrStyle style(paint); | 424 GrStyle style(paint); |
432 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &style); | 425 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &style); |
433 } | 426 } |
434 | 427 |
435 /////////////////////////////////////////////////////////////////////////////// | 428 /////////////////////////////////////////////////////////////////////////////// |
436 | 429 |
437 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 430 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
438 const SkPaint& paint) { | 431 const SkPaint& paint) { |
439 ASSERT_SINGLE_OWNER | 432 ASSERT_SINGLE_OWNER |
440 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext); | 433 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext); |
441 CHECK_SHOULD_DRAW(draw); | 434 CHECK_SHOULD_DRAW(draw); |
442 | 435 |
443 GrPaint grPaint; | 436 GrPaint grPaint; |
444 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 437 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.fMat
rix, &grPaint)) { |
445 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), | |
446 &grPaint)) { | |
447 return; | 438 return; |
448 } | 439 } |
449 | 440 |
450 GrStyle style(paint); | 441 GrStyle style(paint); |
451 if (paint.getMaskFilter()) { | 442 if (paint.getMaskFilter()) { |
452 // try to hit the fast path for drawing filtered round rects | 443 // try to hit the fast path for drawing filtered round rects |
453 | 444 |
454 SkRRect devRRect; | 445 SkRRect devRRect; |
455 if (rect.transform(*draw.fMatrix, &devRRect)) { | 446 if (rect.transform(*draw.fMatrix, &devRRect)) { |
456 if (devRRect.allCornersCircular()) { | 447 if (devRRect.allCornersCircular()) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 } | 502 } |
512 | 503 |
513 if (inner.isEmpty()) { | 504 if (inner.isEmpty()) { |
514 return this->drawRRect(draw, outer, paint); | 505 return this->drawRRect(draw, outer, paint); |
515 } | 506 } |
516 | 507 |
517 SkStrokeRec stroke(paint); | 508 SkStrokeRec stroke(paint); |
518 | 509 |
519 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()
) { | 510 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()
) { |
520 GrPaint grPaint; | 511 GrPaint grPaint; |
521 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 512 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.
fMatrix, |
522 this->surfaceProps().isGammaCorrect(), fDrawContex
t->getColorSpace(), | |
523 &grPaint)) { | 513 &grPaint)) { |
524 return; | 514 return; |
525 } | 515 } |
526 | 516 |
527 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner); | 517 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner); |
528 return; | 518 return; |
529 } | 519 } |
530 | 520 |
531 SkPath path; | 521 SkPath path; |
532 path.setIsVolatile(true); | 522 path.setIsVolatile(true); |
(...skipping 24 matching lines...) Expand all Loading... |
557 return; | 547 return; |
558 } | 548 } |
559 | 549 |
560 if (paint.getMaskFilter()) { | 550 if (paint.getMaskFilter()) { |
561 // The RRect path can handle special case blurring | 551 // The RRect path can handle special case blurring |
562 SkRRect rr = SkRRect::MakeOval(oval); | 552 SkRRect rr = SkRRect::MakeOval(oval); |
563 return this->drawRRect(draw, rr, paint); | 553 return this->drawRRect(draw, rr, paint); |
564 } | 554 } |
565 | 555 |
566 GrPaint grPaint; | 556 GrPaint grPaint; |
567 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 557 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.fMat
rix, &grPaint)) { |
568 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), | |
569 &grPaint)) { | |
570 return; | 558 return; |
571 } | 559 } |
572 | 560 |
573 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, GrStyle(paint)); | 561 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, GrStyle(paint)); |
574 } | 562 } |
575 | 563 |
576 #include "SkMaskFilter.h" | 564 #include "SkMaskFilter.h" |
577 | 565 |
578 /////////////////////////////////////////////////////////////////////////////// | 566 /////////////////////////////////////////////////////////////////////////////// |
579 void SkGpuDevice::drawStrokedLine(const SkPoint points[2], | 567 void SkGpuDevice::drawStrokedLine(const SkPoint points[2], |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 SkRect rect = SkRect::MakeLTRB(mid.fX-halfWidth, mid.fY - 0.5f*length - xtra
Length, | 603 SkRect rect = SkRect::MakeLTRB(mid.fX-halfWidth, mid.fY - 0.5f*length - xtra
Length, |
616 mid.fX+halfWidth, mid.fY + 0.5f*length + xtra
Length); | 604 mid.fX+halfWidth, mid.fY + 0.5f*length + xtra
Length); |
617 SkMatrix m; | 605 SkMatrix m; |
618 m.setSinCos(v.fX, -v.fY, mid.fX, mid.fY); | 606 m.setSinCos(v.fX, -v.fY, mid.fX, mid.fY); |
619 | 607 |
620 SkMatrix local = m; | 608 SkMatrix local = m; |
621 | 609 |
622 m.postConcat(*draw.fMatrix); | 610 m.postConcat(*draw.fMatrix); |
623 | 611 |
624 GrPaint grPaint; | 612 GrPaint grPaint; |
625 if (!SkPaintToGrPaint(this->context(), newPaint, m, | 613 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), newPaint, m, &grP
aint)) { |
626 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), | |
627 &grPaint)) { | |
628 return; | 614 return; |
629 } | 615 } |
630 | 616 |
631 fDrawContext->fillRectWithLocalMatrix(fClip, grPaint, m, rect, local); | 617 fDrawContext->fillRectWithLocalMatrix(fClip, grPaint, m, rect, local); |
632 } | 618 } |
633 | 619 |
634 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, | 620 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
635 const SkPaint& paint, const SkMatrix* prePathMatrix, | 621 const SkPaint& paint, const SkMatrix* prePathMatrix, |
636 bool pathIsMutable) { | 622 bool pathIsMutable) { |
637 ASSERT_SINGLE_OWNER | 623 ASSERT_SINGLE_OWNER |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 SkCanvas::SrcRectConstraint constraint, | 1015 SkCanvas::SrcRectConstraint constraint, |
1030 bool bicubic, | 1016 bool bicubic, |
1031 bool needsTextureDomain) { | 1017 bool needsTextureDomain) { |
1032 // We should have already handled bitmaps larger than the max texture size. | 1018 // We should have already handled bitmaps larger than the max texture size. |
1033 SkASSERT(bitmap.width() <= fContext->caps()->maxTextureSize() && | 1019 SkASSERT(bitmap.width() <= fContext->caps()->maxTextureSize() && |
1034 bitmap.height() <= fContext->caps()->maxTextureSize()); | 1020 bitmap.height() <= fContext->caps()->maxTextureSize()); |
1035 // We should be respecting the max tile size by the time we get here. | 1021 // We should be respecting the max tile size by the time we get here. |
1036 SkASSERT(bitmap.width() <= fContext->caps()->maxTileSize() && | 1022 SkASSERT(bitmap.width() <= fContext->caps()->maxTileSize() && |
1037 bitmap.height() <= fContext->caps()->maxTileSize()); | 1023 bitmap.height() <= fContext->caps()->maxTileSize()); |
1038 | 1024 |
1039 SkSourceGammaTreatment gammaTreatment = this->surfaceProps().isGammaCorrect(
) | 1025 sk_sp<GrTexture> texture = GrMakeCachedBitmapTexture(fContext, bitmap, param
s, |
1040 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore; | 1026 fDrawContext->sourceGam
maTreatment()); |
1041 sk_sp<GrTexture> texture = GrMakeCachedBitmapTexture(fContext, bitmap, param
s, gammaTreatment); | |
1042 if (nullptr == texture) { | 1027 if (nullptr == texture) { |
1043 return; | 1028 return; |
1044 } | 1029 } |
1045 | 1030 |
1046 sk_sp<GrColorSpaceXform> colorSpaceXform = | 1031 sk_sp<GrColorSpaceXform> colorSpaceXform = |
1047 GrColorSpaceXform::Make(bitmap.colorSpace(), fDrawContext->getColorSpace
()); | 1032 GrColorSpaceXform::Make(bitmap.colorSpace(), fDrawContext->getColorSpace
()); |
1048 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() }; | 1033 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() }; |
1049 SkRect paintRect; | 1034 SkRect paintRect; |
1050 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); | 1035 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); |
1051 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); | 1036 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 } | 1083 } |
1099 } else if (bicubic) { | 1084 } else if (bicubic) { |
1100 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); | 1085 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); |
1101 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil
eModeY() }; | 1086 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil
eModeY() }; |
1102 fp = GrBicubicEffect::Make(texture.get(), std::move(colorSpaceXform), te
xMatrix, tileModes); | 1087 fp = GrBicubicEffect::Make(texture.get(), std::move(colorSpaceXform), te
xMatrix, tileModes); |
1103 } else { | 1088 } else { |
1104 fp = GrSimpleTextureEffect::Make(texture.get(), std::move(colorSpaceXfor
m), texMatrix, params); | 1089 fp = GrSimpleTextureEffect::Make(texture.get(), std::move(colorSpaceXfor
m), texMatrix, params); |
1105 } | 1090 } |
1106 | 1091 |
1107 GrPaint grPaint; | 1092 GrPaint grPaint; |
1108 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::mo
ve(fp), | 1093 if (!SkPaintToGrPaintWithTexture(this->context(), fDrawContext.get(), paint,
viewMatrix, |
1109 kAlpha_8_SkColorType == bitmap.colorType(), | 1094 std::move(fp), kAlpha_8_SkColorType == bitm
ap.colorType(), |
1110 this->surfaceProps().isGammaCorrect(), | 1095 &grPaint)) { |
1111 fDrawContext->getColorSpace(), &grPaint)) { | |
1112 return; | 1096 return; |
1113 } | 1097 } |
1114 | 1098 |
1115 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { | 1099 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { |
1116 // We don't have local coords in this case and have previously set the t
ransform | 1100 // We don't have local coords in this case and have previously set the t
ransform |
1117 // matrices directly on the texture processor. | 1101 // matrices directly on the texture processor. |
1118 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect); | 1102 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect); |
1119 } else { | 1103 } else { |
1120 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR
ect); | 1104 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR
ect); |
1121 } | 1105 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 tmpUnfiltered.setImageFilter(nullptr); | 1175 tmpUnfiltered.setImageFilter(nullptr); |
1192 | 1176 |
1193 GrPaint grPaint; | 1177 GrPaint grPaint; |
1194 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nul
lptr, | 1178 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nul
lptr, |
1195 SkMatrix::I())); | 1179 SkMatrix::I())); |
1196 if (GrPixelConfigIsAlphaOnly(texture->config())) { | 1180 if (GrPixelConfigIsAlphaOnly(texture->config())) { |
1197 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); | 1181 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); |
1198 } else { | 1182 } else { |
1199 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); | 1183 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); |
1200 } | 1184 } |
1201 if (!SkPaintToGrPaintReplaceShader(this->context(), tmpUnfiltered, std::move
(fp), | 1185 if (!SkPaintToGrPaintReplaceShader(this->context(), fDrawContext.get(), tmpU
nfiltered, |
1202 this->surfaceProps().isGammaCorrect(), | 1186 std::move(fp), &grPaint)) { |
1203 fDrawContext->getColorSpace(), &grPaint))
{ | |
1204 return; | 1187 return; |
1205 } | 1188 } |
1206 | 1189 |
1207 const SkIRect& subset = result->subset(); | 1190 const SkIRect& subset = result->subset(); |
1208 | 1191 |
1209 fDrawContext->fillRectToRect(fClip, | 1192 fDrawContext->fillRectToRect(fClip, |
1210 grPaint, | 1193 grPaint, |
1211 SkMatrix::I(), | 1194 SkMatrix::I(), |
1212 SkRect::Make(SkIRect::MakeXYWH(left + offset.fX
, top + offset.fY, | 1195 SkRect::Make(SkIRect::MakeXYWH(left + offset.fX
, top + offset.fY, |
1213 subset.width(),
subset.height())), | 1196 subset.width(),
subset.height())), |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 | 1447 |
1465 SkRect srcR, dstR; | 1448 SkRect srcR, dstR; |
1466 while (iter.next(&srcR, &dstR)) { | 1449 while (iter.next(&srcR, &dstR)) { |
1467 this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_
SrcRectConstraint, | 1450 this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_
SrcRectConstraint, |
1468 *draw.fMatrix, fClip, paint); | 1451 *draw.fMatrix, fClip, paint); |
1469 } | 1452 } |
1470 return; | 1453 return; |
1471 } | 1454 } |
1472 | 1455 |
1473 static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_Filt
erMode; | 1456 static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_Filt
erMode; |
1474 bool gammaCorrect = this->surfaceProps().isGammaCorrect(); | |
1475 SkSourceGammaTreatment gammaTreatment = gammaCorrect | |
1476 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore; | |
1477 sk_sp<GrFragmentProcessor> fp( | 1457 sk_sp<GrFragmentProcessor> fp( |
1478 producer->createFragmentProcessor(SkMatrix::I(), | 1458 producer->createFragmentProcessor(SkMatrix::I(), |
1479 SkRect::MakeIWH(producer->width(), pro
ducer->height()), | 1459 SkRect::MakeIWH(producer->width(), pro
ducer->height()), |
1480 GrTextureProducer::kNo_FilterConstrain
t, true, | 1460 GrTextureProducer::kNo_FilterConstrain
t, true, |
1481 &kMode, fDrawContext->getColorSpace(),
gammaTreatment)); | 1461 &kMode, fDrawContext->getColorSpace(), |
| 1462 fDrawContext->sourceGammaTreatment()))
; |
1482 GrPaint grPaint; | 1463 GrPaint grPaint; |
1483 if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, std:
:move(fp), | 1464 if (!SkPaintToGrPaintWithTexture(this->context(), fDrawContext.get(), paint,
*draw.fMatrix, |
1484 producer->isAlphaOnly(), gammaCorrect, | 1465 std::move(fp), producer->isAlphaOnly(), &gr
Paint)) { |
1485 fDrawContext->getColorSpace(), &grPaint)) { | |
1486 return; | 1466 return; |
1487 } | 1467 } |
1488 | 1468 |
1489 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width()
, | 1469 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width()
, |
1490 producer->height(), center, dst); | 1470 producer->height(), center, dst); |
1491 } | 1471 } |
1492 | 1472 |
1493 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, | 1473 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, |
1494 const SkIRect& center, const SkRect& dst, const
SkPaint& paint) { | 1474 const SkIRect& center, const SkRect& dst, const
SkPaint& paint) { |
1495 ASSERT_SINGLE_OWNER | 1475 ASSERT_SINGLE_OWNER |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 if ((nullptr == texs || nullptr == paint.getShader()) && nullptr == colors)
{ | 1517 if ((nullptr == texs || nullptr == paint.getShader()) && nullptr == colors)
{ |
1538 | 1518 |
1539 texs = nullptr; | 1519 texs = nullptr; |
1540 | 1520 |
1541 SkPaint copy(paint); | 1521 SkPaint copy(paint); |
1542 copy.setStyle(SkPaint::kStroke_Style); | 1522 copy.setStyle(SkPaint::kStroke_Style); |
1543 copy.setStrokeWidth(0); | 1523 copy.setStrokeWidth(0); |
1544 | 1524 |
1545 GrPaint grPaint; | 1525 GrPaint grPaint; |
1546 // we ignore the shader if texs is null. | 1526 // we ignore the shader if texs is null. |
1547 if (!SkPaintToGrPaintNoShader(this->context(), copy, | 1527 if (!SkPaintToGrPaintNoShader(this->context(), fDrawContext.get(), copy,
&grPaint)) { |
1548 this->surfaceProps().isGammaCorrect(), | |
1549 fDrawContext->getColorSpace(), &grPaint))
{ | |
1550 return; | 1528 return; |
1551 } | 1529 } |
1552 | 1530 |
1553 int triangleCount = 0; | 1531 int triangleCount = 0; |
1554 int n = (nullptr == indices) ? vertexCount : indexCount; | 1532 int n = (nullptr == indices) ? vertexCount : indexCount; |
1555 switch (vmode) { | 1533 switch (vmode) { |
1556 case SkCanvas::kTriangles_VertexMode: | 1534 case SkCanvas::kTriangles_VertexMode: |
1557 triangleCount = n / 3; | 1535 triangleCount = n / 3; |
1558 break; | 1536 break; |
1559 case SkCanvas::kTriangleStrip_VertexMode: | 1537 case SkCanvas::kTriangleStrip_VertexMode: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 // When there are texs and colors the shader and colors are combined
using xmode. A null | 1588 // When there are texs and colors the shader and colors are combined
using xmode. A null |
1611 // xmode is defined to mean modulate. | 1589 // xmode is defined to mean modulate. |
1612 SkXfermode::Mode colorMode; | 1590 SkXfermode::Mode colorMode; |
1613 if (xmode) { | 1591 if (xmode) { |
1614 if (!xmode->asMode(&colorMode)) { | 1592 if (!xmode->asMode(&colorMode)) { |
1615 return; | 1593 return; |
1616 } | 1594 } |
1617 } else { | 1595 } else { |
1618 colorMode = SkXfermode::kModulate_Mode; | 1596 colorMode = SkXfermode::kModulate_Mode; |
1619 } | 1597 } |
1620 if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMat
rix, colorMode, | 1598 if (!SkPaintToGrPaintWithXfermode(this->context(), fDrawContext.get(
), paint, |
1621 false, this->surfaceProps().isGamm
aCorrect(), | 1599 *draw.fMatrix, colorMode, false, &
grPaint)) { |
1622 fDrawContext->getColorSpace(), &gr
Paint)) { | |
1623 return; | 1600 return; |
1624 } | 1601 } |
1625 } else { | 1602 } else { |
1626 // We have a shader, but no colors to blend it against. | 1603 // We have a shader, but no colors to blend it against. |
1627 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 1604 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *d
raw.fMatrix, |
1628 this->surfaceProps().isGammaCorrect(), | 1605 &grPaint)) { |
1629 fDrawContext->getColorSpace(), &grPaint)) { | |
1630 return; | 1606 return; |
1631 } | 1607 } |
1632 } | 1608 } |
1633 } else { | 1609 } else { |
1634 if (colors) { | 1610 if (colors) { |
1635 // We have colors, but either have no shader or no texture coords (w
hich implies that | 1611 // We have colors, but either have no shader or no texture coords (w
hich implies that |
1636 // we should ignore the shader). | 1612 // we should ignore the shader). |
1637 if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint, | 1613 if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), fDrawContex
t.get(), paint, |
1638 this->surfaceProps().isGamma
Correct(), | 1614 &grPaint)) { |
1639 fDrawContext->getColorSpace(
), &grPaint)) { | |
1640 return; | 1615 return; |
1641 } | 1616 } |
1642 } else { | 1617 } else { |
1643 // No colors and no shaders. Just draw with the paint color. | 1618 // No colors and no shaders. Just draw with the paint color. |
1644 if (!SkPaintToGrPaintNoShader(this->context(), paint, | 1619 if (!SkPaintToGrPaintNoShader(this->context(), fDrawContext.get(), p
aint, &grPaint)) { |
1645 this->surfaceProps().isGammaCorrect(), | |
1646 fDrawContext->getColorSpace(), &grPain
t)) { | |
1647 return; | 1620 return; |
1648 } | 1621 } |
1649 } | 1622 } |
1650 } | 1623 } |
1651 | 1624 |
1652 fDrawContext->drawVertices(fClip, | 1625 fDrawContext->drawVertices(fClip, |
1653 grPaint, | 1626 grPaint, |
1654 *draw.fMatrix, | 1627 *draw.fMatrix, |
1655 primType, | 1628 primType, |
1656 vertexCount, | 1629 vertexCount, |
(...skipping 16 matching lines...) Expand all Loading... |
1673 } | 1646 } |
1674 | 1647 |
1675 CHECK_SHOULD_DRAW(draw); | 1648 CHECK_SHOULD_DRAW(draw); |
1676 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); | 1649 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); |
1677 | 1650 |
1678 SkPaint p(paint); | 1651 SkPaint p(paint); |
1679 p.setShader(atlas->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_Ti
leMode)); | 1652 p.setShader(atlas->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_Ti
leMode)); |
1680 | 1653 |
1681 GrPaint grPaint; | 1654 GrPaint grPaint; |
1682 if (colors) { | 1655 if (colors) { |
1683 if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mod
e, true, | 1656 if (!SkPaintToGrPaintWithXfermode(this->context(), fDrawContext.get(), p
, *draw.fMatrix, |
1684 this->surfaceProps().isGammaCorrect(), | 1657 mode, true, &grPaint)) { |
1685 fDrawContext->getColorSpace(), &grPain
t)) { | |
1686 return; | 1658 return; |
1687 } | 1659 } |
1688 } else { | 1660 } else { |
1689 if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix, | 1661 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), p, *draw.fMat
rix, &grPaint)) { |
1690 this->surfaceProps().isGammaCorrect(), | |
1691 fDrawContext->getColorSpace(), &grPaint)) { | |
1692 return; | 1662 return; |
1693 } | 1663 } |
1694 } | 1664 } |
1695 | 1665 |
1696 SkDEBUGCODE(this->validate();) | 1666 SkDEBUGCODE(this->validate();) |
1697 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect
, colors); | 1667 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect
, colors); |
1698 } | 1668 } |
1699 | 1669 |
1700 /////////////////////////////////////////////////////////////////////////////// | 1670 /////////////////////////////////////////////////////////////////////////////// |
1701 | 1671 |
1702 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, | 1672 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
1703 size_t byteLength, SkScalar x, SkScalar y, | 1673 size_t byteLength, SkScalar x, SkScalar y, |
1704 const SkPaint& paint) { | 1674 const SkPaint& paint) { |
1705 ASSERT_SINGLE_OWNER | 1675 ASSERT_SINGLE_OWNER |
1706 CHECK_SHOULD_DRAW(draw); | 1676 CHECK_SHOULD_DRAW(draw); |
1707 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); | 1677 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); |
1708 | 1678 |
1709 GrPaint grPaint; | 1679 GrPaint grPaint; |
1710 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 1680 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.fMat
rix, &grPaint)) { |
1711 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), | |
1712 &grPaint)) { | |
1713 return; | 1681 return; |
1714 } | 1682 } |
1715 | 1683 |
1716 SkDEBUGCODE(this->validate();) | 1684 SkDEBUGCODE(this->validate();) |
1717 | 1685 |
1718 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix, | 1686 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix, |
1719 (const char *)text, byteLength, x, y, draw.fRC->getBo
unds()); | 1687 (const char *)text, byteLength, x, y, draw.fRC->getBo
unds()); |
1720 } | 1688 } |
1721 | 1689 |
1722 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, | 1690 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, |
1723 const SkScalar pos[], int scalarsPerPos, | 1691 const SkScalar pos[], int scalarsPerPos, |
1724 const SkPoint& offset, const SkPaint& paint) { | 1692 const SkPoint& offset, const SkPaint& paint) { |
1725 ASSERT_SINGLE_OWNER | 1693 ASSERT_SINGLE_OWNER |
1726 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPosText", fContext); | 1694 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPosText", fContext); |
1727 CHECK_SHOULD_DRAW(draw); | 1695 CHECK_SHOULD_DRAW(draw); |
1728 | 1696 |
1729 GrPaint grPaint; | 1697 GrPaint grPaint; |
1730 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, | 1698 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.fMat
rix, &grPaint)) { |
1731 this->surfaceProps().isGammaCorrect(), fDrawContext->g
etColorSpace(), | |
1732 &grPaint)) { | |
1733 return; | 1699 return; |
1734 } | 1700 } |
1735 | 1701 |
1736 SkDEBUGCODE(this->validate();) | 1702 SkDEBUGCODE(this->validate();) |
1737 | 1703 |
1738 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix, | 1704 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix, |
1739 (const char *)text, byteLength, pos, scalarsPerPos
, offset, | 1705 (const char *)text, byteLength, pos, scalarsPerPos
, offset, |
1740 draw.fRC->getBounds()); | 1706 draw.fRC->getBounds()); |
1741 } | 1707 } |
1742 | 1708 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 } | 1773 } |
1808 | 1774 |
1809 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1775 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
1810 ASSERT_SINGLE_OWNER | 1776 ASSERT_SINGLE_OWNER |
1811 // We always return a transient cache, so it is freed after each | 1777 // We always return a transient cache, so it is freed after each |
1812 // filter traversal. | 1778 // filter traversal. |
1813 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1779 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
1814 } | 1780 } |
1815 | 1781 |
1816 #endif | 1782 #endif |
OLD | NEW |