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 "GrBitmapTextContext.h" | 10 #include "GrBitmapTextContext.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 return SkNEW_ARGS(SkGpuDevice, (rt, props, flags)); | 213 return SkNEW_ARGS(SkGpuDevice, (rt, props, flags)); |
214 } | 214 } |
215 | 215 |
216 SkGpuDevice::~SkGpuDevice() { | 216 SkGpuDevice::~SkGpuDevice() { |
217 if (fDrawProcs) { | 217 if (fDrawProcs) { |
218 delete fDrawProcs; | 218 delete fDrawProcs; |
219 } | 219 } |
220 | 220 |
221 delete fTextContext; | 221 delete fTextContext; |
222 | 222 |
223 if (fContext->getClip() == &fClipData) { | |
224 fContext->setClip(NULL); | |
225 } | |
226 | |
227 fRenderTarget->unref(); | 223 fRenderTarget->unref(); |
228 fContext->unref(); | 224 fContext->unref(); |
229 } | 225 } |
230 | 226 |
231 /////////////////////////////////////////////////////////////////////////////// | 227 /////////////////////////////////////////////////////////////////////////////// |
232 | 228 |
233 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
_t dstRowBytes, | 229 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
_t dstRowBytes, |
234 int x, int y) { | 230 int x, int y) { |
235 DO_DEFERRED_CLEAR(); | 231 DO_DEFERRED_CLEAR(); |
236 | 232 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 270 |
275 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { | 271 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { |
276 INHERITED::onAttachToCanvas(canvas); | 272 INHERITED::onAttachToCanvas(canvas); |
277 | 273 |
278 // Canvas promises that this ptr is valid until onDetachFromCanvas is called | 274 // Canvas promises that this ptr is valid until onDetachFromCanvas is called |
279 fClipStack.reset(SkRef(canvas->getClipStack())); | 275 fClipStack.reset(SkRef(canvas->getClipStack())); |
280 } | 276 } |
281 | 277 |
282 void SkGpuDevice::onDetachFromCanvas() { | 278 void SkGpuDevice::onDetachFromCanvas() { |
283 INHERITED::onDetachFromCanvas(); | 279 INHERITED::onDetachFromCanvas(); |
284 fClipData.reset(); | 280 fClip.reset(); |
285 fClipStack.reset(NULL); | 281 fClipStack.reset(NULL); |
286 } | 282 } |
287 | 283 |
288 // call this every draw call, to ensure that the context reflects our state, | 284 // call this every draw call, to ensure that the context reflects our state, |
289 // and not the state from some other canvas/device | 285 // and not the state from some other canvas/device |
290 void SkGpuDevice::prepareDraw(const SkDraw& draw) { | 286 void SkGpuDevice::prepareDraw(const SkDraw& draw) { |
291 SkASSERT(fClipStack.get()); | 287 SkASSERT(fClipStack.get()); |
292 | 288 |
293 SkASSERT(draw.fClipStack && draw.fClipStack == fClipStack); | 289 SkASSERT(draw.fClipStack && draw.fClipStack == fClipStack); |
294 | 290 |
295 fClipData.setClipStack(fClipStack, &this->getOrigin()); | 291 fClip.setClipStack(fClipStack, &this->getOrigin()); |
296 | |
297 fContext->setClip(&fClipData); | |
298 | 292 |
299 DO_DEFERRED_CLEAR(); | 293 DO_DEFERRED_CLEAR(); |
300 } | 294 } |
301 | 295 |
302 GrRenderTarget* SkGpuDevice::accessRenderTarget() { | 296 GrRenderTarget* SkGpuDevice::accessRenderTarget() { |
303 DO_DEFERRED_CLEAR(); | 297 DO_DEFERRED_CLEAR(); |
304 return fRenderTarget; | 298 return fRenderTarget; |
305 } | 299 } |
306 | 300 |
307 void SkGpuDevice::clearAll() { | 301 void SkGpuDevice::clearAll() { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 353 |
360 /////////////////////////////////////////////////////////////////////////////// | 354 /////////////////////////////////////////////////////////////////////////////// |
361 | 355 |
362 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 356 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
363 CHECK_SHOULD_DRAW(draw); | 357 CHECK_SHOULD_DRAW(draw); |
364 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); | 358 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); |
365 | 359 |
366 GrPaint grPaint; | 360 GrPaint grPaint; |
367 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 361 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); |
368 | 362 |
369 fContext->drawPaint(fRenderTarget, grPaint, *draw.fMatrix); | 363 fContext->drawPaint(fRenderTarget, fClip, grPaint, *draw.fMatrix); |
370 } | 364 } |
371 | 365 |
372 // must be in SkCanvas::PointMode order | 366 // must be in SkCanvas::PointMode order |
373 static const GrPrimitiveType gPointMode2PrimtiveType[] = { | 367 static const GrPrimitiveType gPointMode2PrimtiveType[] = { |
374 kPoints_GrPrimitiveType, | 368 kPoints_GrPrimitiveType, |
375 kLines_GrPrimitiveType, | 369 kLines_GrPrimitiveType, |
376 kLineStrip_GrPrimitiveType | 370 kLineStrip_GrPrimitiveType |
377 }; | 371 }; |
378 | 372 |
379 void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, | 373 void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, |
380 size_t count, const SkPoint pts[], const SkPaint& p
aint) { | 374 size_t count, const SkPoint pts[], const SkPaint& p
aint) { |
381 CHECK_FOR_ANNOTATION(paint); | 375 CHECK_FOR_ANNOTATION(paint); |
382 CHECK_SHOULD_DRAW(draw); | 376 CHECK_SHOULD_DRAW(draw); |
383 | 377 |
384 SkScalar width = paint.getStrokeWidth(); | 378 SkScalar width = paint.getStrokeWidth(); |
385 if (width < 0) { | 379 if (width < 0) { |
386 return; | 380 return; |
387 } | 381 } |
388 | 382 |
389 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod
e) { | 383 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod
e) { |
390 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); | 384 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); |
391 GrPaint grPaint; | 385 GrPaint grPaint; |
392 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatr
ix, true, &grPaint); | 386 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatr
ix, true, &grPaint); |
393 SkPath path; | 387 SkPath path; |
394 path.setIsVolatile(true); | 388 path.setIsVolatile(true); |
395 path.moveTo(pts[0]); | 389 path.moveTo(pts[0]); |
396 path.lineTo(pts[1]); | 390 path.lineTo(pts[1]); |
397 fContext->drawPath(fRenderTarget, grPaint, *draw.fMatrix, path, strokeIn
fo); | 391 fContext->drawPath(fRenderTarget, fClip, grPaint, *draw.fMatrix, path, s
trokeInfo); |
398 return; | 392 return; |
399 } | 393 } |
400 | 394 |
401 // we only handle hairlines and paints without path effects or mask filters, | 395 // we only handle hairlines and paints without path effects or mask filters, |
402 // else we let the SkDraw call our drawPath() | 396 // else we let the SkDraw call our drawPath() |
403 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter()) { | 397 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter()) { |
404 draw.drawPoints(mode, count, pts, paint, true); | 398 draw.drawPoints(mode, count, pts, paint, true); |
405 return; | 399 return; |
406 } | 400 } |
407 | 401 |
408 GrPaint grPaint; | 402 GrPaint grPaint; |
409 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 403 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); |
410 | 404 |
411 fContext->drawVertices(fRenderTarget, | 405 fContext->drawVertices(fRenderTarget, |
| 406 fClip, |
412 grPaint, | 407 grPaint, |
413 *draw.fMatrix, | 408 *draw.fMatrix, |
414 gPointMode2PrimtiveType[mode], | 409 gPointMode2PrimtiveType[mode], |
415 SkToS32(count), | 410 SkToS32(count), |
416 (SkPoint*)pts, | 411 (SkPoint*)pts, |
417 NULL, | 412 NULL, |
418 NULL, | 413 NULL, |
419 NULL, | 414 NULL, |
420 0); | 415 0); |
421 } | 416 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 SkPath path; | 467 SkPath path; |
473 path.setIsVolatile(true); | 468 path.setIsVolatile(true); |
474 path.addRect(rect); | 469 path.addRect(rect); |
475 this->drawPath(draw, path, paint, NULL, true); | 470 this->drawPath(draw, path, paint, NULL, true); |
476 return; | 471 return; |
477 } | 472 } |
478 | 473 |
479 GrPaint grPaint; | 474 GrPaint grPaint; |
480 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 475 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); |
481 | 476 |
482 fContext->drawRect(fRenderTarget, grPaint, *draw.fMatrix, rect, &strokeInfo)
; | 477 fContext->drawRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, rect, &stro
keInfo); |
483 } | 478 } |
484 | 479 |
485 /////////////////////////////////////////////////////////////////////////////// | 480 /////////////////////////////////////////////////////////////////////////////// |
486 | 481 |
487 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 482 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
488 const SkPaint& paint) { | 483 const SkPaint& paint) { |
489 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext); | 484 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext); |
490 CHECK_FOR_ANNOTATION(paint); | 485 CHECK_FOR_ANNOTATION(paint); |
491 CHECK_SHOULD_DRAW(draw); | 486 CHECK_SHOULD_DRAW(draw); |
492 | 487 |
(...skipping 14 matching lines...) Expand all Loading... |
507 &maskRect)) { | 502 &maskRect)) { |
508 SkIRect finalIRect; | 503 SkIRect finalIRect; |
509 maskRect.roundOut(&finalIRect); | 504 maskRect.roundOut(&finalIRect); |
510 if (draw.fClip->quickReject(finalIRect)) { | 505 if (draw.fClip->quickReject(finalIRect)) { |
511 // clipped out | 506 // clipped out |
512 return; | 507 return; |
513 } | 508 } |
514 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext
, | 509 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext
, |
515 fRenderT
arget, | 510 fRenderT
arget, |
516 &grPaint
, | 511 &grPaint
, |
| 512 fClip, |
517 *draw.fM
atrix, | 513 *draw.fM
atrix, |
518 strokeIn
fo.getStrokeRec(), | 514 strokeIn
fo.getStrokeRec(), |
519 devRRect
)) { | 515 devRRect
)) { |
520 return; | 516 return; |
521 } | 517 } |
522 } | 518 } |
523 | 519 |
524 } | 520 } |
525 } | 521 } |
526 | 522 |
(...skipping 12 matching lines...) Expand all Loading... |
539 | 535 |
540 | 536 |
541 if (usePath) { | 537 if (usePath) { |
542 SkPath path; | 538 SkPath path; |
543 path.setIsVolatile(true); | 539 path.setIsVolatile(true); |
544 path.addRRect(rect); | 540 path.addRRect(rect); |
545 this->drawPath(draw, path, paint, NULL, true); | 541 this->drawPath(draw, path, paint, NULL, true); |
546 return; | 542 return; |
547 } | 543 } |
548 | 544 |
549 fContext->drawRRect(fRenderTarget, grPaint, *draw.fMatrix, rect, strokeInfo)
; | 545 fContext->drawRRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, rect, stro
keInfo); |
550 } | 546 } |
551 | 547 |
552 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, | 548 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
553 const SkRRect& inner, const SkPaint& paint) { | 549 const SkRRect& inner, const SkPaint& paint) { |
554 SkStrokeRec stroke(paint); | 550 SkStrokeRec stroke(paint); |
555 if (stroke.isFillStyle()) { | 551 if (stroke.isFillStyle()) { |
556 | 552 |
557 CHECK_FOR_ANNOTATION(paint); | 553 CHECK_FOR_ANNOTATION(paint); |
558 CHECK_SHOULD_DRAW(draw); | 554 CHECK_SHOULD_DRAW(draw); |
559 | 555 |
560 GrPaint grPaint; | 556 GrPaint grPaint; |
561 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatr
ix, true, &grPaint); | 557 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatr
ix, true, &grPaint); |
562 | 558 |
563 if (NULL == paint.getMaskFilter() && NULL == paint.getPathEffect()) { | 559 if (NULL == paint.getMaskFilter() && NULL == paint.getPathEffect()) { |
564 fContext->drawDRRect(fRenderTarget, grPaint, *draw.fMatrix, outer, i
nner); | 560 fContext->drawDRRect(fRenderTarget, fClip, grPaint, *draw.fMatrix, o
uter, inner); |
565 return; | 561 return; |
566 } | 562 } |
567 } | 563 } |
568 | 564 |
569 SkPath path; | 565 SkPath path; |
570 path.setIsVolatile(true); | 566 path.setIsVolatile(true); |
571 path.addRRect(outer); | 567 path.addRRect(outer); |
572 path.addRRect(inner); | 568 path.addRRect(inner); |
573 path.setFillType(SkPath::kEvenOdd_FillType); | 569 path.setFillType(SkPath::kEvenOdd_FillType); |
574 | 570 |
(...skipping 26 matching lines...) Expand all Loading... |
601 SkPath path; | 597 SkPath path; |
602 path.setIsVolatile(true); | 598 path.setIsVolatile(true); |
603 path.addOval(oval); | 599 path.addOval(oval); |
604 this->drawPath(draw, path, paint, NULL, true); | 600 this->drawPath(draw, path, paint, NULL, true); |
605 return; | 601 return; |
606 } | 602 } |
607 | 603 |
608 GrPaint grPaint; | 604 GrPaint grPaint; |
609 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 605 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); |
610 | 606 |
611 fContext->drawOval(fRenderTarget, grPaint, *draw.fMatrix, oval, strokeInfo); | 607 fContext->drawOval(fRenderTarget, fClip, grPaint, *draw.fMatrix, oval, strok
eInfo); |
612 } | 608 } |
613 | 609 |
614 #include "SkMaskFilter.h" | 610 #include "SkMaskFilter.h" |
615 | 611 |
616 /////////////////////////////////////////////////////////////////////////////// | 612 /////////////////////////////////////////////////////////////////////////////// |
617 | 613 |
618 // helpers for applying mask filters | 614 // helpers for applying mask filters |
619 namespace { | 615 namespace { |
620 | 616 |
621 // Draw a mask using the supplied paint. Since the coverage/geometry | 617 // Draw a mask using the supplied paint. Since the coverage/geometry |
622 // is already burnt into the mask this boils down to a rect draw. | 618 // is already burnt into the mask this boils down to a rect draw. |
623 // Return true if the mask was successfully drawn. | 619 // Return true if the mask was successfully drawn. |
624 bool draw_mask(GrContext* context, | 620 bool draw_mask(GrContext* context, |
625 GrRenderTarget* rt, | 621 GrRenderTarget* rt, |
| 622 const GrClip& clip, |
626 const SkMatrix& viewMatrix, | 623 const SkMatrix& viewMatrix, |
627 const SkRect& maskRect, | 624 const SkRect& maskRect, |
628 GrPaint* grp, | 625 GrPaint* grp, |
629 GrTexture* mask) { | 626 GrTexture* mask) { |
630 SkMatrix matrix; | 627 SkMatrix matrix; |
631 matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop); | 628 matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop); |
632 matrix.postIDiv(mask->width(), mask->height()); | 629 matrix.postIDiv(mask->width(), mask->height()); |
633 | 630 |
634 grp->addCoverageProcessor(GrSimpleTextureEffect::Create(mask, matrix, | 631 grp->addCoverageProcessor(GrSimpleTextureEffect::Create(mask, matrix, |
635 kDevice_GrCoordSet))
->unref(); | 632 kDevice_GrCoordSet))
->unref(); |
636 | 633 |
637 SkMatrix inverse; | 634 SkMatrix inverse; |
638 if (!viewMatrix.invert(&inverse)) { | 635 if (!viewMatrix.invert(&inverse)) { |
639 return false; | 636 return false; |
640 } | 637 } |
641 context->drawNonAARectWithLocalMatrix(rt, *grp, SkMatrix::I(), maskRect, inv
erse); | 638 context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), maskRec
t, inverse); |
642 return true; | 639 return true; |
643 } | 640 } |
644 | 641 |
645 bool draw_with_mask_filter(GrContext* context, | 642 bool draw_with_mask_filter(GrContext* context, |
646 GrRenderTarget* rt, | 643 GrRenderTarget* rt, |
| 644 const GrClip& clipData, |
647 const SkMatrix& viewMatrix, | 645 const SkMatrix& viewMatrix, |
648 const SkPath& devPath, | 646 const SkPath& devPath, |
649 SkMaskFilter* filter, | 647 SkMaskFilter* filter, |
650 const SkRegion& clip, | 648 const SkRegion& clip, |
651 GrPaint* grp, | 649 GrPaint* grp, |
652 SkPaint::Style style) { | 650 SkPaint::Style style) { |
653 SkMask srcM, dstM; | 651 SkMask srcM, dstM; |
654 | 652 |
655 if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), filter, &viewMatrix, &sr
cM, | 653 if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), filter, &viewMatrix, &sr
cM, |
656 SkMask::kComputeBoundsAndRenderImage_CreateMode, sty
le)) { | 654 SkMask::kComputeBoundsAndRenderImage_CreateMode, sty
le)) { |
(...skipping 21 matching lines...) Expand all Loading... |
678 SkAutoTUnref<GrTexture> texture( | 676 SkAutoTUnref<GrTexture> texture( |
679 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); | 677 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); |
680 if (!texture) { | 678 if (!texture) { |
681 return false; | 679 return false; |
682 } | 680 } |
683 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, | 681 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, |
684 dstM.fImage, dstM.fRowBytes); | 682 dstM.fImage, dstM.fRowBytes); |
685 | 683 |
686 SkRect maskRect = SkRect::Make(dstM.fBounds); | 684 SkRect maskRect = SkRect::Make(dstM.fBounds); |
687 | 685 |
688 return draw_mask(context, rt, viewMatrix, maskRect, grp, texture); | 686 return draw_mask(context, rt, clipData, viewMatrix, maskRect, grp, texture); |
689 } | 687 } |
690 | 688 |
691 // Create a mask of 'devPath' and place the result in 'mask'. | 689 // Create a mask of 'devPath' and place the result in 'mask'. |
692 GrTexture* create_mask_GPU(GrContext* context, | 690 GrTexture* create_mask_GPU(GrContext* context, |
693 GrRenderTarget* rt, | 691 GrRenderTarget* rt, |
694 const SkRect& maskRect, | 692 const SkRect& maskRect, |
695 const SkPath& devPath, | 693 const SkPath& devPath, |
696 const GrStrokeInfo& strokeInfo, | 694 const GrStrokeInfo& strokeInfo, |
697 bool doAA, | 695 bool doAA, |
698 int sampleCnt) { | 696 int sampleCnt) { |
(...skipping 11 matching lines...) Expand all Loading... |
710 desc.fConfig = kAlpha_8_GrPixelConfig; | 708 desc.fConfig = kAlpha_8_GrPixelConfig; |
711 } | 709 } |
712 | 710 |
713 GrTexture* mask = context->refScratchTexture(desc,GrContext::kApprox_Scratch
TexMatch); | 711 GrTexture* mask = context->refScratchTexture(desc,GrContext::kApprox_Scratch
TexMatch); |
714 if (NULL == mask) { | 712 if (NULL == mask) { |
715 return NULL; | 713 return NULL; |
716 } | 714 } |
717 | 715 |
718 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); | 716 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); |
719 | 717 |
720 GrContext::AutoClip ac(context, clipRect); | |
721 | |
722 context->clear(NULL, 0x0, true, mask->asRenderTarget()); | 718 context->clear(NULL, 0x0, true, mask->asRenderTarget()); |
723 | 719 |
724 GrPaint tempPaint; | 720 GrPaint tempPaint; |
725 tempPaint.setAntiAlias(doAA); | 721 tempPaint.setAntiAlias(doAA); |
726 tempPaint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op); | 722 tempPaint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op); |
727 | 723 |
| 724 // setup new clip |
| 725 GrClip clip(clipRect); |
| 726 |
728 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. | 727 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. |
729 SkMatrix translate; | 728 SkMatrix translate; |
730 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); | 729 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); |
731 context->drawPath(mask->asRenderTarget(), tempPaint, translate, devPath, str
okeInfo); | 730 context->drawPath(mask->asRenderTarget(), clip, tempPaint, translate, devPat
h, strokeInfo); |
732 return mask; | 731 return mask; |
733 } | 732 } |
734 | 733 |
735 SkBitmap wrap_texture(GrTexture* texture) { | 734 SkBitmap wrap_texture(GrTexture* texture) { |
736 SkBitmap result; | 735 SkBitmap result; |
737 result.setInfo(texture->surfacePriv().info()); | 736 result.setInfo(texture->surfacePriv().info()); |
738 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unre
f(); | 737 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unre
f(); |
739 return result; | 738 return result; |
740 } | 739 } |
741 | 740 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 SkIRect finalIRect; | 825 SkIRect finalIRect; |
827 maskRect.roundOut(&finalIRect); | 826 maskRect.roundOut(&finalIRect); |
828 if (draw.fClip->quickReject(finalIRect)) { | 827 if (draw.fClip->quickReject(finalIRect)) { |
829 // clipped out | 828 // clipped out |
830 return; | 829 return; |
831 } | 830 } |
832 | 831 |
833 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, | 832 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, |
834 fRenderTarget, | 833 fRenderTarget, |
835 &grPaint, | 834 &grPaint, |
| 835 fClip, |
836 viewMatrix, | 836 viewMatrix, |
837 stroke, | 837 stroke, |
838 *devPathPtr)) { | 838 *devPathPtr)) { |
839 // the mask filter was able to draw itself directly, so there's
nothing | 839 // the mask filter was able to draw itself directly, so there's
nothing |
840 // left to do. | 840 // left to do. |
841 return; | 841 return; |
842 } | 842 } |
843 | 843 |
844 | 844 |
845 SkAutoTUnref<GrTexture> mask(create_mask_GPU(fContext, | 845 SkAutoTUnref<GrTexture> mask(create_mask_GPU(fContext, |
846 fRenderTarget, | 846 fRenderTarget, |
847 maskRect, | 847 maskRect, |
848 *devPathPtr, | 848 *devPathPtr, |
849 strokeInfo, | 849 strokeInfo, |
850 grPaint.isAntiAlias(), | 850 grPaint.isAntiAlias(), |
851 fRenderTarget->numSampl
es())); | 851 fRenderTarget->numSampl
es())); |
852 if (mask) { | 852 if (mask) { |
853 GrTexture* filtered; | 853 GrTexture* filtered; |
854 | 854 |
855 if (paint.getMaskFilter()->filterMaskGPU(mask, viewMatrix, maskR
ect, &filtered, true)) { | 855 if (paint.getMaskFilter()->filterMaskGPU(mask, viewMatrix, maskR
ect, &filtered, true)) { |
856 // filterMaskGPU gives us ownership of a ref to the result | 856 // filterMaskGPU gives us ownership of a ref to the result |
857 SkAutoTUnref<GrTexture> atu(filtered); | 857 SkAutoTUnref<GrTexture> atu(filtered); |
858 if (draw_mask(fContext, fRenderTarget, viewMatrix, maskRect,
&grPaint, | 858 if (draw_mask(fContext, |
| 859 fRenderTarget, |
| 860 fClip, |
| 861 viewMatrix, |
| 862 maskRect, |
| 863 &grPaint, |
859 filtered)) { | 864 filtered)) { |
860 // This path is completely drawn | 865 // This path is completely drawn |
861 return; | 866 return; |
862 } | 867 } |
863 } | 868 } |
864 } | 869 } |
865 } | 870 } |
866 | 871 |
867 // draw the mask on the CPU - this is a fallthrough path in case the | 872 // draw the mask on the CPU - this is a fallthrough path in case the |
868 // GPU path fails | 873 // GPU path fails |
869 SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style
: | 874 SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style
: |
870 SkPaint::kFill_Style; | 875 SkPaint::kFill_Style; |
871 draw_with_mask_filter(fContext, fRenderTarget, viewMatrix, *devPathPtr, | 876 draw_with_mask_filter(fContext, fRenderTarget, fClip, viewMatrix, *devPa
thPtr, |
872 paint.getMaskFilter(), *draw.fClip, &grPaint, styl
e); | 877 paint.getMaskFilter(), *draw.fClip, &grPaint, styl
e); |
873 return; | 878 return; |
874 } | 879 } |
875 | 880 |
876 fContext->drawPath(fRenderTarget, grPaint, viewMatrix, *pathPtr, strokeInfo)
; | 881 fContext->drawPath(fRenderTarget, fClip, grPaint, viewMatrix, *pathPtr, stro
keInfo); |
877 } | 882 } |
878 | 883 |
879 static const int kBmpSmallTileSize = 1 << 10; | 884 static const int kBmpSmallTileSize = 1 << 10; |
880 | 885 |
881 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { | 886 static inline int get_tile_count(const SkIRect& srcRect, int tileSize) { |
882 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; | 887 int tilesX = (srcRect.fRight / tileSize) - (srcRect.fLeft / tileSize) + 1; |
883 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; | 888 int tilesY = (srcRect.fBottom / tileSize) - (srcRect.fTop / tileSize) + 1; |
884 return tilesX * tilesY; | 889 return tilesX * tilesY; |
885 } | 890 } |
886 | 891 |
(...skipping 12 matching lines...) Expand all Loading... |
899 return kBmpSmallTileSize; | 904 return kBmpSmallTileSize; |
900 } else { | 905 } else { |
901 return maxTileSize; | 906 return maxTileSize; |
902 } | 907 } |
903 } | 908 } |
904 | 909 |
905 // Given a bitmap, an optional src rect, and a context with a clip and matrix de
termine what | 910 // Given a bitmap, an optional src rect, and a context with a clip and matrix de
termine what |
906 // pixels from the bitmap are necessary. | 911 // pixels from the bitmap are necessary. |
907 static void determine_clipped_src_rect(const GrContext* context, | 912 static void determine_clipped_src_rect(const GrContext* context, |
908 const GrRenderTarget* rt, | 913 const GrRenderTarget* rt, |
| 914 const GrClip& clip, |
909 const SkMatrix& viewMatrix, | 915 const SkMatrix& viewMatrix, |
910 const SkBitmap& bitmap, | 916 const SkBitmap& bitmap, |
911 const SkRect* srcRectPtr, | 917 const SkRect* srcRectPtr, |
912 SkIRect* clippedSrcIRect) { | 918 SkIRect* clippedSrcIRect) { |
913 const GrClip* clip = context->getClip(); | 919 clip.getConservativeBounds(rt, clippedSrcIRect, NULL); |
914 clip->getConservativeBounds(rt, clippedSrcIRect, NULL); | |
915 SkMatrix inv; | 920 SkMatrix inv; |
916 if (!viewMatrix.invert(&inv)) { | 921 if (!viewMatrix.invert(&inv)) { |
917 clippedSrcIRect->setEmpty(); | 922 clippedSrcIRect->setEmpty(); |
918 return; | 923 return; |
919 } | 924 } |
920 SkRect clippedSrcRect = SkRect::Make(*clippedSrcIRect); | 925 SkRect clippedSrcRect = SkRect::Make(*clippedSrcIRect); |
921 inv.mapRect(&clippedSrcRect); | 926 inv.mapRect(&clippedSrcRect); |
922 if (srcRectPtr) { | 927 if (srcRectPtr) { |
923 // we've setup src space 0,0 to map to the top left of the src rect. | 928 // we've setup src space 0,0 to map to the top left of the src rect. |
924 clippedSrcRect.offset(srcRectPtr->fLeft, srcRectPtr->fTop); | 929 clippedSrcRect.offset(srcRectPtr->fLeft, srcRectPtr->fTop); |
(...skipping 16 matching lines...) Expand all Loading... |
941 int maxTileSize, | 946 int maxTileSize, |
942 int* tileSize, | 947 int* tileSize, |
943 SkIRect* clippedSrcRect) const { | 948 SkIRect* clippedSrcRect) const { |
944 // if bitmap is explictly texture backed then just use the texture | 949 // if bitmap is explictly texture backed then just use the texture |
945 if (bitmap.getTexture()) { | 950 if (bitmap.getTexture()) { |
946 return false; | 951 return false; |
947 } | 952 } |
948 | 953 |
949 // if it's larger than the max tile size, then we have no choice but tiling. | 954 // if it's larger than the max tile size, then we have no choice but tiling. |
950 if (bitmap.width() > maxTileSize || bitmap.height() > maxTileSize) { | 955 if (bitmap.width() > maxTileSize || bitmap.height() > maxTileSize) { |
951 determine_clipped_src_rect(fContext, fRenderTarget, viewMatrix, bitmap,
srcRectPtr, | 956 determine_clipped_src_rect(fContext, fRenderTarget, fClip, viewMatrix, b
itmap, |
952 clippedSrcRect); | 957 srcRectPtr, clippedSrcRect); |
953 *tileSize = determine_tile_size(bitmap, *clippedSrcRect, maxTileSize); | 958 *tileSize = determine_tile_size(bitmap, *clippedSrcRect, maxTileSize); |
954 return true; | 959 return true; |
955 } | 960 } |
956 | 961 |
957 if (bitmap.width() * bitmap.height() < 4 * kBmpSmallTileSize * kBmpSmallTile
Size) { | 962 if (bitmap.width() * bitmap.height() < 4 * kBmpSmallTileSize * kBmpSmallTile
Size) { |
958 return false; | 963 return false; |
959 } | 964 } |
960 | 965 |
961 // if the entire texture is already in our cache then no reason to tile it | 966 // if the entire texture is already in our cache then no reason to tile it |
962 if (GrIsBitmapInCache(fContext, bitmap, ¶ms)) { | 967 if (GrIsBitmapInCache(fContext, bitmap, ¶ms)) { |
963 return false; | 968 return false; |
964 } | 969 } |
965 | 970 |
966 // At this point we know we could do the draw by uploading the entire bitmap | 971 // At this point we know we could do the draw by uploading the entire bitmap |
967 // as a texture. However, if the texture would be large compared to the | 972 // as a texture. However, if the texture would be large compared to the |
968 // cache size and we don't require most of it for this draw then tile to | 973 // cache size and we don't require most of it for this draw then tile to |
969 // reduce the amount of upload and cache spill. | 974 // reduce the amount of upload and cache spill. |
970 | 975 |
971 // assumption here is that sw bitmap size is a good proxy for its size as | 976 // assumption here is that sw bitmap size is a good proxy for its size as |
972 // a texture | 977 // a texture |
973 size_t bmpSize = bitmap.getSize(); | 978 size_t bmpSize = bitmap.getSize(); |
974 size_t cacheSize; | 979 size_t cacheSize; |
975 fContext->getResourceCacheLimits(NULL, &cacheSize); | 980 fContext->getResourceCacheLimits(NULL, &cacheSize); |
976 if (bmpSize < cacheSize / 2) { | 981 if (bmpSize < cacheSize / 2) { |
977 return false; | 982 return false; |
978 } | 983 } |
979 | 984 |
980 // Figure out how much of the src we will need based on the src rect and cli
pping. | 985 // Figure out how much of the src we will need based on the src rect and cli
pping. |
981 determine_clipped_src_rect(fContext, fRenderTarget, viewMatrix, bitmap, srcR
ectPtr, | 986 determine_clipped_src_rect(fContext, fRenderTarget, fClip, viewMatrix, bitma
p, srcRectPtr, |
982 clippedSrcRect); | 987 clippedSrcRect); |
983 *tileSize = kBmpSmallTileSize; // already know whole bitmap fits in one max
sized tile. | 988 *tileSize = kBmpSmallTileSize; // already know whole bitmap fits in one max
sized tile. |
984 size_t usedTileBytes = get_tile_count(*clippedSrcRect, kBmpSmallTileSize) * | 989 size_t usedTileBytes = get_tile_count(*clippedSrcRect, kBmpSmallTileSize) * |
985 kBmpSmallTileSize * kBmpSmallTileSize; | 990 kBmpSmallTileSize * kBmpSmallTileSize; |
986 | 991 |
987 return usedTileBytes < 2 * bmpSize; | 992 return usedTileBytes < 2 * bmpSize; |
988 } | 993 } |
989 | 994 |
990 void SkGpuDevice::drawBitmap(const SkDraw& origDraw, | 995 void SkGpuDevice::drawBitmap(const SkDraw& origDraw, |
991 const SkBitmap& bitmap, | 996 const SkBitmap& bitmap, |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 | 1450 |
1446 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring | 1451 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring |
1447 // the rest from the SkPaint. | 1452 // the rest from the SkPaint. |
1448 GrPaint grPaint; | 1453 GrPaint grPaint; |
1449 grPaint.addColorProcessor(fp); | 1454 grPaint.addColorProcessor(fp); |
1450 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); | 1455 bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType()); |
1451 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()
) : | 1456 GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()
) : |
1452 SkColor2GrColor(paint.getColor()); | 1457 SkColor2GrColor(paint.getColor()); |
1453 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, paintColor, f
alse, &grPaint); | 1458 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, paintColor, f
alse, &grPaint); |
1454 | 1459 |
1455 fContext->drawNonAARectToRect(fRenderTarget, grPaint, viewMatrix, dstRect, p
aintRect); | 1460 fContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, viewMatrix, dst
Rect, |
| 1461 paintRect); |
1456 } | 1462 } |
1457 | 1463 |
1458 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, | 1464 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, |
1459 const SkImageFilter* filter, | 1465 const SkImageFilter* filter, |
1460 const SkImageFilter::Context& ctx, | 1466 const SkImageFilter::Context& ctx, |
1461 SkBitmap* result, SkIPoint* offset) { | 1467 SkBitmap* result, SkIPoint* offset) { |
1462 SkASSERT(filter); | 1468 SkASSERT(filter); |
1463 | 1469 |
1464 // FIXME: plumb actual surface props such that we don't have to lie about th
e flags here | 1470 // FIXME: plumb actual surface props such that we don't have to lie about th
e flags here |
1465 // (https://code.google.com/p/skia/issues/detail?id=3148). | 1471 // (https://code.google.com/p/skia/issues/detail?id=3148). |
1466 SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties().
pixelGeometry())); | 1472 SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties().
pixelGeometry())); |
1467 | 1473 |
1468 if (filter->canFilterImageGPU()) { | 1474 if (filter->canFilterImageGPU()) { |
1469 // Set the clip wide open and the matrix to identity. | |
1470 GrContext::AutoWideOpenIdentityDraw awo(context); | |
1471 return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result
, offset); | 1475 return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result
, offset); |
1472 } else { | 1476 } else { |
1473 return false; | 1477 return false; |
1474 } | 1478 } |
1475 } | 1479 } |
1476 | 1480 |
1477 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, | 1481 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, |
1478 int left, int top, const SkPaint& paint) { | 1482 int left, int top, const SkPaint& paint) { |
1479 // drawSprite is defined to be in device coords. | 1483 // drawSprite is defined to be in device coords. |
1480 CHECK_SHOULD_DRAW(draw); | 1484 CHECK_SHOULD_DRAW(draw); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 } | 1520 } |
1517 } | 1521 } |
1518 | 1522 |
1519 GrPaint grPaint; | 1523 GrPaint grPaint; |
1520 grPaint.addColorTextureProcessor(texture, SkMatrix::I()); | 1524 grPaint.addColorTextureProcessor(texture, SkMatrix::I()); |
1521 | 1525 |
1522 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, | 1526 SkPaint2GrPaintNoShader(this->context(), fRenderTarget, paint, |
1523 SkColor2GrColorJustAlpha(paint.getColor()), false, &
grPaint); | 1527 SkColor2GrColorJustAlpha(paint.getColor()), false, &
grPaint); |
1524 | 1528 |
1525 fContext->drawNonAARectToRect(fRenderTarget, | 1529 fContext->drawNonAARectToRect(fRenderTarget, |
| 1530 fClip, |
1526 grPaint, | 1531 grPaint, |
1527 SkMatrix::I(), | 1532 SkMatrix::I(), |
1528 SkRect::MakeXYWH(SkIntToScalar(left), | 1533 SkRect::MakeXYWH(SkIntToScalar(left), |
1529 SkIntToScalar(top), | 1534 SkIntToScalar(top), |
1530 SkIntToScalar(w), | 1535 SkIntToScalar(w), |
1531 SkIntToScalar(h)), | 1536 SkIntToScalar(h)), |
1532 SkRect::MakeXYWH(0, | 1537 SkRect::MakeXYWH(0, |
1533 0, | 1538 0, |
1534 SK_Scalar1 * w / texture->wid
th(), | 1539 SK_Scalar1 * w / texture->wid
th(), |
1535 SK_Scalar1 * h / texture->hei
ght())); | 1540 SK_Scalar1 * h / texture->hei
ght())); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), | 1643 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), |
1639 SkIntToScalar(y), | 1644 SkIntToScalar(y), |
1640 SkIntToScalar(w), | 1645 SkIntToScalar(w), |
1641 SkIntToScalar(h)); | 1646 SkIntToScalar(h)); |
1642 | 1647 |
1643 // The device being drawn may not fill up its texture (e.g. saveLayer uses a
pproximate | 1648 // The device being drawn may not fill up its texture (e.g. saveLayer uses a
pproximate |
1644 // scratch texture). | 1649 // scratch texture). |
1645 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), | 1650 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), |
1646 SK_Scalar1 * h / devTex->height()); | 1651 SK_Scalar1 * h / devTex->height()); |
1647 | 1652 |
1648 fContext->drawNonAARectToRect(fRenderTarget, grPaint, SkMatrix::I(), dstRect
, srcRect); | 1653 fContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, SkMatrix::I(),
dstRect, |
| 1654 srcRect); |
1649 } | 1655 } |
1650 | 1656 |
1651 bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { | 1657 bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { |
1652 return filter->canFilterImageGPU(); | 1658 return filter->canFilterImageGPU(); |
1653 } | 1659 } |
1654 | 1660 |
1655 bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, | 1661 bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, |
1656 const SkImageFilter::Context& ctx, | 1662 const SkImageFilter::Context& ctx, |
1657 SkBitmap* result, SkIPoint* offset) { | 1663 SkBitmap* result, SkIPoint* offset) { |
1658 // want explicitly our impl, so guard against a subclass of us overriding it | 1664 // want explicitly our impl, so guard against a subclass of us overriding it |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 for (int i = 0; i < vertexCount; ++i) { | 1778 for (int i = 0; i < vertexCount; ++i) { |
1773 color = colors[i]; | 1779 color = colors[i]; |
1774 if (paint.getAlpha() != 255) { | 1780 if (paint.getAlpha() != 255) { |
1775 color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color),
paint.getAlpha())); | 1781 color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color),
paint.getAlpha())); |
1776 } | 1782 } |
1777 convertedColors[i] = SkColor2GrColor(color); | 1783 convertedColors[i] = SkColor2GrColor(color); |
1778 } | 1784 } |
1779 colors = convertedColors.get(); | 1785 colors = convertedColors.get(); |
1780 } | 1786 } |
1781 fContext->drawVertices(fRenderTarget, | 1787 fContext->drawVertices(fRenderTarget, |
| 1788 fClip, |
1782 grPaint, | 1789 grPaint, |
1783 *draw.fMatrix, | 1790 *draw.fMatrix, |
1784 primType, | 1791 primType, |
1785 vertexCount, | 1792 vertexCount, |
1786 vertices, | 1793 vertices, |
1787 texs, | 1794 texs, |
1788 colors, | 1795 colors, |
1789 outIndices, | 1796 outIndices, |
1790 indexCount); | 1797 indexCount); |
1791 } | 1798 } |
1792 | 1799 |
1793 /////////////////////////////////////////////////////////////////////////////// | 1800 /////////////////////////////////////////////////////////////////////////////// |
1794 | 1801 |
1795 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, | 1802 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
1796 size_t byteLength, SkScalar x, SkScalar y, | 1803 size_t byteLength, SkScalar x, SkScalar y, |
1797 const SkPaint& paint) { | 1804 const SkPaint& paint) { |
1798 CHECK_SHOULD_DRAW(draw); | 1805 CHECK_SHOULD_DRAW(draw); |
1799 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); | 1806 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); |
1800 | 1807 |
1801 GrPaint grPaint; | 1808 GrPaint grPaint; |
1802 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 1809 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); |
1803 | 1810 |
1804 SkDEBUGCODE(this->validate();) | 1811 SkDEBUGCODE(this->validate();) |
1805 | 1812 |
1806 if (!fTextContext->drawText(fRenderTarget, grPaint, paint, *draw.fMatrix, (c
onst char *)text, | 1813 if (!fTextContext->drawText(fRenderTarget, fClip, grPaint, paint, *draw.fMat
rix, |
1807 byteLength, x, y)) { | 1814 (const char *)text, byteLength, x, y)) { |
1808 // this will just call our drawPath() | 1815 // this will just call our drawPath() |
1809 draw.drawText_asPaths((const char*)text, byteLength, x, y, paint); | 1816 draw.drawText_asPaths((const char*)text, byteLength, x, y, paint); |
1810 } | 1817 } |
1811 } | 1818 } |
1812 | 1819 |
1813 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, | 1820 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, |
1814 const SkScalar pos[], int scalarsPerPos, | 1821 const SkScalar pos[], int scalarsPerPos, |
1815 const SkPoint& offset, const SkPaint& paint) { | 1822 const SkPoint& offset, const SkPaint& paint) { |
1816 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext); | 1823 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext); |
1817 CHECK_SHOULD_DRAW(draw); | 1824 CHECK_SHOULD_DRAW(draw); |
1818 | 1825 |
1819 GrPaint grPaint; | 1826 GrPaint grPaint; |
1820 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); | 1827 SkPaint2GrPaintShader(this->context(), fRenderTarget, paint, *draw.fMatrix,
true, &grPaint); |
1821 | 1828 |
1822 SkDEBUGCODE(this->validate();) | 1829 SkDEBUGCODE(this->validate();) |
1823 | 1830 |
1824 if (!fTextContext->drawPosText(fRenderTarget, grPaint, paint, *draw.fMatrix,
(const char *)text, | 1831 if (!fTextContext->drawPosText(fRenderTarget, fClip, grPaint, paint, *draw.f
Matrix, |
1825 byteLength, pos, scalarsPerPos, offset)) { | 1832 (const char *)text, byteLength, pos, scalarsP
erPos, offset)) { |
1826 // this will just call our drawPath() | 1833 // this will just call our drawPath() |
1827 draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerP
os, offset, paint); | 1834 draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerP
os, offset, paint); |
1828 } | 1835 } |
1829 } | 1836 } |
1830 | 1837 |
1831 /////////////////////////////////////////////////////////////////////////////// | 1838 /////////////////////////////////////////////////////////////////////////////// |
1832 | 1839 |
1833 bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { | 1840 bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { |
1834 if (paint.getShader() || | 1841 if (paint.getShader() || |
1835 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode) || | 1842 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode) || |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 #endif | 1961 #endif |
1955 } | 1962 } |
1956 | 1963 |
1957 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1964 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1958 // We always return a transient cache, so it is freed after each | 1965 // We always return a transient cache, so it is freed after each |
1959 // filter traversal. | 1966 // filter traversal. |
1960 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1967 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1961 } | 1968 } |
1962 | 1969 |
1963 #endif | 1970 #endif |
OLD | NEW |