Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/SkGpuDevice_drawTexture.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 239 }
240 SkASSERT(nullptr != texture->asRenderTarget()); 240 SkASSERT(nullptr != texture->asRenderTarget());
241 return texture->asRenderTarget(); 241 return texture->asRenderTarget();
242 } 242 }
243 243
244 SkGpuDevice::~SkGpuDevice() { 244 SkGpuDevice::~SkGpuDevice() {
245 if (fDrawProcs) { 245 if (fDrawProcs) {
246 delete fDrawProcs; 246 delete fDrawProcs;
247 } 247 }
248 248
249 SkASSERT(!fRenderTarget->fromRawPixels2());
249 fRenderTarget->unref(); 250 fRenderTarget->unref();
250 fContext->unref(); 251 fContext->unref();
251 } 252 }
252 253
253 /////////////////////////////////////////////////////////////////////////////// 254 ///////////////////////////////////////////////////////////////////////////////
254 255
255 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes, 256 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes,
256 int x, int y) { 257 int x, int y) {
257 DO_DEFERRED_CLEAR(); 258 DO_DEFERRED_CLEAR();
258 259
(...skipping 15 matching lines...) Expand all
274 int x, int y) { 275 int x, int y) {
275 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels 276 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels
276 GrPixelConfig config = SkImageInfo2GrPixelConfig(info); 277 GrPixelConfig config = SkImageInfo2GrPixelConfig(info);
277 if (kUnknown_GrPixelConfig == config) { 278 if (kUnknown_GrPixelConfig == config) {
278 return false; 279 return false;
279 } 280 }
280 uint32_t flags = 0; 281 uint32_t flags = 0;
281 if (kUnpremul_SkAlphaType == info.alphaType()) { 282 if (kUnpremul_SkAlphaType == info.alphaType()) {
282 flags = GrContext::kUnpremul_PixelOpsFlag; 283 flags = GrContext::kUnpremul_PixelOpsFlag;
283 } 284 }
284 fRenderTarget->writePixels(x, y, info.width(), info.height(), config, pixels , rowBytes, flags); 285
286 fRenderTarget->writePixels(fDrawContext, x, y, info.width(), info.height(), config, pixels, rowBytes, flags);
285 287
286 // need to bump our genID for compatibility with clients that "know" we have a bitmap 288 // need to bump our genID for compatibility with clients that "know" we have a bitmap
287 fLegacyBitmap.notifyPixelsChanged(); 289 fLegacyBitmap.notifyPixelsChanged();
288 290
289 return true; 291 return true;
290 } 292 }
291 293
292 const SkBitmap& SkGpuDevice::onAccessBitmap() { 294 const SkBitmap& SkGpuDevice::onAccessBitmap() {
293 DO_DEFERRED_CLEAR(); 295 DO_DEFERRED_CLEAR();
294 return fLegacyBitmap; 296 return fLegacyBitmap;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam pleCnt)); 355 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam pleCnt));
354 356
355 if (nullptr == newRT) { 357 if (nullptr == newRT) {
356 return; 358 return;
357 } 359 }
358 360
359 if (shouldRetainContent) { 361 if (shouldRetainContent) {
360 if (fRenderTarget->wasDestroyed()) { 362 if (fRenderTarget->wasDestroyed()) {
361 return; 363 return;
362 } 364 }
365 SkASSERT(fRenderTarget->width() == newRT->width());
366 SkASSERT(fRenderTarget->height() == newRT->height());
367
363 this->context()->copySurface(newRT, fRenderTarget); 368 this->context()->copySurface(newRT, fRenderTarget);
364 } 369 }
365 370
366 SkASSERT(fRenderTarget != newRT); 371 SkASSERT(fRenderTarget != newRT);
367 372
368 fRenderTarget->unref(); 373 fRenderTarget->unref();
369 fRenderTarget = newRT.detach(); 374 fRenderTarget = newRT.detach();
370 375
371 #ifdef SK_DEBUG 376 #ifdef SK_DEBUG
372 SkImageInfo info = fRenderTarget->surfacePriv().info(fOpaque ? kOpaque_SkAlp haType : 377 SkImageInfo info = fRenderTarget->surfacePriv().info(fOpaque ? kOpaque_SkAlp haType :
373 kPremul_SkAlp haType); 378 kPremul_SkAlp haType);
374 SkASSERT(info == fLegacyBitmap.info()); 379 SkASSERT(info == fLegacyBitmap.info());
375 #endif 380 #endif
376 SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget); 381 SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget);
377 fLegacyBitmap.setPixelRef(pr)->unref(); 382 fLegacyBitmap.setPixelRef(pr)->unref();
378 383
379 fDrawContext.reset(this->context()->drawContext(fRenderTarget, &this->surfac eProps())); 384 fDrawContext.reset(this->context()->drawContext(fRenderTarget, &this->surfac eProps()));
380 } 385 }
381 386
382 /////////////////////////////////////////////////////////////////////////////// 387 ///////////////////////////////////////////////////////////////////////////////
383 388
384 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { 389 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
385 CHECK_SHOULD_DRAW(draw); 390 CHECK_SHOULD_DRAW(draw);
386 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); 391 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext);
387 392
388 GrPaint grPaint; 393 GrPaint grPaint;
389 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 394 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRend erTarget)) {
390 return; 395 return;
391 } 396 }
392 397
393 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix); 398 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix);
394 } 399 }
395 400
396 // must be in SkCanvas::PointMode order 401 // must be in SkCanvas::PointMode order
397 static const GrPrimitiveType gPointMode2PrimtiveType[] = { 402 static const GrPrimitiveType gPointMode2PrimtiveType[] = {
398 kPoints_GrPrimitiveType, 403 kPoints_GrPrimitiveType,
399 kLines_GrPrimitiveType, 404 kLines_GrPrimitiveType,
(...skipping 28 matching lines...) Expand all
428 CHECK_SHOULD_DRAW(draw); 433 CHECK_SHOULD_DRAW(draw);
429 434
430 SkScalar width = paint.getStrokeWidth(); 435 SkScalar width = paint.getStrokeWidth();
431 if (width < 0) { 436 if (width < 0) {
432 return; 437 return;
433 } 438 }
434 439
435 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod e) { 440 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod e) {
436 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); 441 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style);
437 GrPaint grPaint; 442 GrPaint grPaint;
438 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 443 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, f RenderTarget)) {
439 return; 444 return;
440 } 445 }
441 SkPath path; 446 SkPath path;
442 path.setIsVolatile(true); 447 path.setIsVolatile(true);
443 path.moveTo(pts[0]); 448 path.moveTo(pts[0]);
444 path.lineTo(pts[1]); 449 path.lineTo(pts[1]);
445 fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, strokeInfo); 450 fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, strokeInfo);
446 return; 451 return;
447 } 452 }
448 453
449 // we only handle non-antialiased hairlines and paints without path effects or mask filters, 454 // we only handle non-antialiased hairlines and paints without path effects or mask filters,
450 // else we let the SkDraw call our drawPath() 455 // else we let the SkDraw call our drawPath()
451 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() || 456 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() ||
452 (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) { 457 (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) {
453 draw.drawPoints(mode, count, pts, paint, true); 458 draw.drawPoints(mode, count, pts, paint, true);
454 return; 459 return;
455 } 460 }
456 461
457 GrPaint grPaint; 462 GrPaint grPaint;
458 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 463 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRend erTarget)) {
459 return; 464 return;
460 } 465 }
461 466
462 fDrawContext->drawVertices(fClip, 467 fDrawContext->drawVertices(fClip,
463 grPaint, 468 grPaint,
464 *draw.fMatrix, 469 *draw.fMatrix,
465 gPointMode2PrimtiveType[mode], 470 gPointMode2PrimtiveType[mode],
466 SkToS32(count), 471 SkToS32(count),
467 (SkPoint*)pts, 472 (SkPoint*)pts,
468 nullptr, 473 nullptr,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 515
511 if (usePath) { 516 if (usePath) {
512 SkPath path; 517 SkPath path;
513 path.setIsVolatile(true); 518 path.setIsVolatile(true);
514 path.addRect(rect); 519 path.addRect(rect);
515 this->drawPath(draw, path, paint, nullptr, true); 520 this->drawPath(draw, path, paint, nullptr, true);
516 return; 521 return;
517 } 522 }
518 523
519 GrPaint grPaint; 524 GrPaint grPaint;
520 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 525 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRend erTarget)) {
521 return; 526 return;
522 } 527 }
523 528
524 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); 529 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo);
525 } 530 }
526 531
527 /////////////////////////////////////////////////////////////////////////////// 532 ///////////////////////////////////////////////////////////////////////////////
528 533
529 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, 534 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
530 const SkPaint& paint) { 535 const SkPaint& paint) {
531 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext); 536 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext);
532 CHECK_FOR_ANNOTATION(paint); 537 CHECK_FOR_ANNOTATION(paint);
533 CHECK_SHOULD_DRAW(draw); 538 CHECK_SHOULD_DRAW(draw);
534 539
535 GrPaint grPaint; 540 GrPaint grPaint;
536 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 541 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRend erTarget)) {
537 return; 542 return;
538 } 543 }
539 544
540 GrStrokeInfo strokeInfo(paint); 545 GrStrokeInfo strokeInfo(paint);
541 if (paint.getMaskFilter()) { 546 if (paint.getMaskFilter()) {
542 // try to hit the fast path for drawing filtered round rects 547 // try to hit the fast path for drawing filtered round rects
543 548
544 SkRRect devRRect; 549 SkRRect devRRect;
545 if (rect.transform(*draw.fMatrix, &devRRect)) { 550 if (rect.transform(*draw.fMatrix, &devRRect)) {
546 if (devRRect.allCornersCircular()) { 551 if (devRRect.allCornersCircular()) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 601
597 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, 602 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
598 const SkRRect& inner, const SkPaint& paint) { 603 const SkRRect& inner, const SkPaint& paint) {
599 SkStrokeRec stroke(paint); 604 SkStrokeRec stroke(paint);
600 if (stroke.isFillStyle()) { 605 if (stroke.isFillStyle()) {
601 606
602 CHECK_FOR_ANNOTATION(paint); 607 CHECK_FOR_ANNOTATION(paint);
603 CHECK_SHOULD_DRAW(draw); 608 CHECK_SHOULD_DRAW(draw);
604 609
605 GrPaint grPaint; 610 GrPaint grPaint;
606 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 611 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, f RenderTarget)) {
607 return; 612 return;
608 } 613 }
609 614
610 if (nullptr == paint.getMaskFilter() && nullptr == paint.getPathEffect() ) { 615 if (nullptr == paint.getMaskFilter() && nullptr == paint.getPathEffect() ) {
611 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner ); 616 fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner );
612 return; 617 return;
613 } 618 }
614 } 619 }
615 620
616 SkPath path; 621 SkPath path;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 653
649 if (usePath) { 654 if (usePath) {
650 SkPath path; 655 SkPath path;
651 path.setIsVolatile(true); 656 path.setIsVolatile(true);
652 path.addOval(oval); 657 path.addOval(oval);
653 this->drawPath(draw, path, paint, nullptr, true); 658 this->drawPath(draw, path, paint, nullptr, true);
654 return; 659 return;
655 } 660 }
656 661
657 GrPaint grPaint; 662 GrPaint grPaint;
658 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 663 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRend erTarget)) {
659 return; 664 return;
660 } 665 }
661 666
662 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, strokeInfo); 667 fDrawContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, strokeInfo);
663 } 668 }
664 669
665 #include "SkMaskFilter.h" 670 #include "SkMaskFilter.h"
666 671
667 /////////////////////////////////////////////////////////////////////////////// 672 ///////////////////////////////////////////////////////////////////////////////
668 673
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 "Couldn't convert bitmap to texture."); 1004 "Couldn't convert bitmap to texture.");
1000 return; 1005 return;
1001 } 1006 }
1002 1007
1003 1008
1004 GrPaint grPaint; 1009 GrPaint grPaint;
1005 1010
1006 // Create and insert texture effect 1011 // Create and insert texture effect
1007 SkAutoTUnref<const GrFragmentProcessor> fp; 1012 SkAutoTUnref<const GrFragmentProcessor> fp;
1008 if (doBicubic) { 1013 if (doBicubic) {
1009 fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tm)); 1014 fp.reset(GrBicubicEffect::Create(texture,
1015 SkMatrix::I(),
1016 tm, renderTarget));
1010 } else { 1017 } else {
1011 fp.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params)); 1018 fp.reset(GrSimpleTextureEffect::Create(texture,
1019 SkMatrix::I(), params, kLocal_GrC oordSet, renderTarget));
1012 } 1020 }
1013 1021
1014 if (kAlpha_8_SkColorType == bitmapPtr->colorType()) { 1022 if (kAlpha_8_SkColorType == bitmapPtr->colorType()) {
1015 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); 1023 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
1016 } else { 1024 } else {
1017 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); 1025 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
1018 } 1026 }
1019 1027
1020 if (!SkPaintToGrPaintReplaceShader(context, paint, fp, &grPaint)) { 1028 if (!SkPaintToGrPaintReplaceShader(context, paint, fp, &grPaint, renderTarge t)) {
1021 return; 1029 return;
1022 } 1030 }
1023 1031
1024 // Setup dst rect and final matrix 1032 // Setup dst rect and final matrix
1025 SkRect dstRect = {0, 0, dstSize.fWidth, dstSize.fHeight}; 1033 SkRect dstRect = {0, 0, dstSize.fWidth, dstSize.fHeight};
1026 1034
1027 SkRect devRect; 1035 SkRect devRect;
1028 viewMatrix.mapRect(&devRect, dstRect); 1036 viewMatrix.mapRect(&devRect, dstRect);
1029 1037
1030 SkMatrix matrix; 1038 SkMatrix matrix;
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 } 1363 }
1356 if (srcRect.height() > SK_Scalar1) { 1364 if (srcRect.height() > SK_Scalar1) {
1357 SkScalar border = SK_ScalarHalf / texture->height(); 1365 SkScalar border = SK_ScalarHalf / texture->height();
1358 top = paintRect.top() + border; 1366 top = paintRect.top() + border;
1359 bottom = paintRect.bottom() - border; 1367 bottom = paintRect.bottom() - border;
1360 } else { 1368 } else {
1361 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); 1369 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom());
1362 } 1370 }
1363 textureDomain.setLTRB(left, top, right, bottom); 1371 textureDomain.setLTRB(left, top, right, bottom);
1364 if (bicubic) { 1372 if (bicubic) {
1365 fp.reset(GrBicubicEffect::Create(texture, texMatrix, textureDomain)) ; 1373
1374 fp.reset(GrBicubicEffect::Create(texture,
1375 SkMatrix::I(), textureDomain, fRend erTarget));
1366 } else { 1376 } else {
1367 fp.reset(GrTextureDomainEffect::Create(texture, 1377 fp.reset(GrTextureDomainEffect::Create(texture,
1368 texMatrix, 1378 texMatrix,
1369 textureDomain, 1379 textureDomain,
1370 GrTextureDomain::kClamp_Mode, 1380 GrTextureDomain::kClamp_Mode,
1371 params.filterMode())); 1381 params.filterMode(), kLocal_G rCoordSet, fRenderTarget));
1372 } 1382 }
1373 } else if (bicubic) { 1383 } else if (bicubic) {
1374 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); 1384 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
1375 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil eModeY() }; 1385 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil eModeY() };
1376 fp.reset(GrBicubicEffect::Create(texture, texMatrix, tileModes)); 1386 fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(),
1387 tileModes, fRenderTarget));
1377 } else { 1388 } else {
1378 fp.reset(GrSimpleTextureEffect::Create(texture, texMatrix, params)); 1389 fp.reset(GrSimpleTextureEffect::Create(texture,
1390 SkMatrix::I(), params, kLocal_GrC oordSet, fRenderTarget));
1379 } 1391 }
1380 1392
1381 SkAutoTUnref<const GrFragmentProcessor> shaderFP; 1393 SkAutoTUnref<const GrFragmentProcessor> shaderFP;
1382 1394
1383 if (kAlpha_8_SkColorType == bitmap.colorType()) { 1395 if (kAlpha_8_SkColorType == bitmap.colorType()) {
1384 if (const SkShader* shader = paint.getShader()) { 1396 if (const SkShader* shader = paint.getShader()) {
1385 shaderFP.reset(shader->asFragmentProcessor(this->context(), 1397 shaderFP.reset(shader->asFragmentProcessor(this->context(),
1386 viewMatrix, 1398 viewMatrix,
1387 nullptr, 1399 nullptr,
1388 paint.getFilterQuality()) ); 1400 paint.getFilterQuality(), fRenderTarget));
1389 if (!shaderFP) { 1401 if (!shaderFP) {
1390 return; 1402 return;
1391 } 1403 }
1392 const GrFragmentProcessor* fpSeries[] = { shaderFP.get(), fp.get() } ; 1404 const GrFragmentProcessor* fpSeries[] = { shaderFP.get(), fp.get() } ;
1393 fp.reset(GrFragmentProcessor::RunInSeries(fpSeries, 2)); 1405 fp.reset(GrFragmentProcessor::RunInSeries(fpSeries, 2));
1394 } else { 1406 } else {
1395 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); 1407 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
1396 } 1408 }
1397 } else { 1409 } else {
1398 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); 1410 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
1399 } 1411 }
1400 1412
1401 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { 1413 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint, fRe nderTarget)) {
1402 return; 1414 return;
1403 } 1415 }
1404 1416
1405 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { 1417 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) {
1406 // We don't have local coords in this case and have previously set the t ransform 1418 // We don't have local coords in this case and have previously set the t ransform
1407 // matrices directly on the texture processor. 1419 // matrices directly on the texture processor.
1408 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect); 1420 fDrawContext->drawRect(fClip, grPaint, viewMatrix, dstRect);
1409 } else { 1421 } else {
1410 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR ect); 1422 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR ect);
1411 } 1423 }
1412 } 1424 }
1413 1425
1414 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, 1426 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
1415 int width, int height, 1427 int width, int height,
1416 const SkImageFilter* filter, 1428 const SkImageFilter* filter,
1417 const SkImageFilter::Context& ctx, 1429 const SkImageFilter::Context& ctx,
1418 SkBitmap* result, SkIPoint* offset) { 1430 SkBitmap* result, SkIPoint* offset) {
1419 SkASSERT(filter); 1431 SkASSERT(filter);
1420 1432
1421 SkImageFilter::DeviceProxy proxy(this); 1433 if (filter->canFilterImageGPU()) {
1434 SkImageFilter::DeviceProxy proxy(this);
1422 1435
1423 if (filter->canFilterImageGPU()) {
1424 return filter->filterImageGPU(&proxy, wrap_texture(texture, width, heigh t), 1436 return filter->filterImageGPU(&proxy, wrap_texture(texture, width, heigh t),
1425 ctx, result, offset); 1437 ctx, result, offset);
1426 } else { 1438 } else {
1427 return false; 1439 return false;
1428 } 1440 }
1429 } 1441 }
1430 1442
1431 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, 1443 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
1432 int left, int top, const SkPaint& paint) { 1444 int left, int top, const SkPaint& paint) {
1433 // drawSprite is defined to be in device coords. 1445 // drawSprite is defined to be in device coords.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 top += offset.y(); 1484 top += offset.y();
1473 } else { 1485 } else {
1474 return; 1486 return;
1475 } 1487 }
1476 SkASSERT(!GrPixelConfigIsAlphaOnly(texture->config())); 1488 SkASSERT(!GrPixelConfigIsAlphaOnly(texture->config()));
1477 alphaOnly = false; 1489 alphaOnly = false;
1478 } 1490 }
1479 1491
1480 GrPaint grPaint; 1492 GrPaint grPaint;
1481 SkAutoTUnref<const GrFragmentProcessor> fp( 1493 SkAutoTUnref<const GrFragmentProcessor> fp(
1482 GrSimpleTextureEffect::Create(texture, SkMatrix::I())); 1494 GrSimpleTextureEffect::Create(texture, SkMatrix::I(),
1495 kLocal_GrCoordSet, fRenderTarget));
1483 if (alphaOnly) { 1496 if (alphaOnly) {
1484 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); 1497 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
1485 } else { 1498 } else {
1486 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); 1499 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
1487 } 1500 }
1488 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { 1501 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint, fRe nderTarget)) {
1489 return; 1502 return;
1490 } 1503 }
1491 1504
1492 fDrawContext->fillRectToRect(fClip, 1505 fDrawContext->fillRectToRect(fClip,
1493 grPaint, 1506 grPaint,
1494 SkMatrix::I(), 1507 SkMatrix::I(),
1495 SkRect::MakeXYWH(SkIntToScalar(left), 1508 SkRect::MakeXYWH(SkIntToScalar(left),
1496 SkIntToScalar(top), 1509 SkIntToScalar(top),
1497 SkIntToScalar(w), 1510 SkIntToScalar(w),
1498 SkIntToScalar(h)), 1511 SkIntToScalar(h)),
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDevice", fContext); 1575 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDevice", fContext);
1563 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); 1576 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device);
1564 1577
1565 // TODO: If the source device covers the whole of this device, we could 1578 // TODO: If the source device covers the whole of this device, we could
1566 // omit fNeedsClear -related flushing. 1579 // omit fNeedsClear -related flushing.
1567 // TODO: if source needs clear, we could maybe omit the draw fully. 1580 // TODO: if source needs clear, we could maybe omit the draw fully.
1568 1581
1569 // drawDevice is defined to be in device coords. 1582 // drawDevice is defined to be in device coords.
1570 CHECK_SHOULD_DRAW(draw); 1583 CHECK_SHOULD_DRAW(draw);
1571 1584
1572 GrRenderTarget* devRT = dev->accessRenderTarget(); 1585 GrRenderTarget* srcDevRT = dev->accessRenderTarget();
1573 GrTexture* devTex; 1586 GrTexture* srcDevTex;
1574 if (nullptr == (devTex = devRT->asTexture())) { 1587 if (nullptr == (srcDevTex = srcDevRT->asTexture())) {
1575 return; 1588 return;
1576 } 1589 }
1577 1590
1578 const SkImageInfo ii = dev->imageInfo(); 1591 const SkImageInfo ii = dev->imageInfo();
1579 int w = ii.width(); 1592 int w = ii.width();
1580 int h = ii.height(); 1593 int h = ii.height();
1581 1594
1582 SkImageFilter* filter = paint.getImageFilter(); 1595 SkImageFilter* filter = paint.getImageFilter();
1583 // This bitmap will own the filtered result as a texture. 1596 // This bitmap will own the filtered result as a texture.
1584 SkBitmap filteredBitmap; 1597 SkBitmap filteredBitmap;
1585 1598
1586 if (filter) { 1599 if (filter) {
1587 SkIPoint offset = SkIPoint::Make(0, 0); 1600 SkIPoint offset = SkIPoint::Make(0, 0);
1588 SkMatrix matrix(*draw.fMatrix); 1601 SkMatrix matrix(*draw.fMatrix);
1589 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); 1602 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
1590 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); 1603 SkIRect clipBounds = SkIRect::MakeWH(srcDevTex->width(), srcDevTex->heig ht());
1591 // This cache is transient, and is freed (along with all its contained 1604 // This cache is transient, and is freed (along with all its contained
1592 // textures) when it goes out of scope. 1605 // textures) when it goes out of scope.
1593 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); 1606 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache());
1594 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp prox_SizeConstraint); 1607 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp prox_SizeConstraint);
1595 if (this->filterTexture(fContext, devTex, device->width(), device->heigh t(), 1608 if (this->filterTexture(fContext, srcDevTex, device->width(), device->he ight(),
1596 filter, ctx, &filteredBitmap, &offset)) { 1609 filter, ctx, &filteredBitmap, &offset)) {
1597 devTex = filteredBitmap.getTexture(); 1610 srcDevTex = filteredBitmap.getTexture();
1611 srcDevRT = srcDevTex->asRenderTarget();
1598 w = filteredBitmap.width(); 1612 w = filteredBitmap.width();
1599 h = filteredBitmap.height(); 1613 h = filteredBitmap.height();
1600 x += offset.fX; 1614 x += offset.fX;
1601 y += offset.fY; 1615 y += offset.fY;
1602 } else { 1616 } else {
1603 return; 1617 return;
1604 } 1618 }
1605 } 1619 }
1606 1620
1607 GrPaint grPaint; 1621 GrPaint grPaint;
1608 SkAutoTUnref<const GrFragmentProcessor> fp( 1622 SkAutoTUnref<const GrFragmentProcessor> fp(
1609 GrSimpleTextureEffect::Create(devTex, SkMatrix::I())); 1623 GrSimpleTextureEffect::Create(srcDevTex, SkMatrix::I(),
1610 if (GrPixelConfigIsAlphaOnly(devTex->config())) { 1624 kLocal_GrCoordSet, fRenderTarget));
1625 if (GrPixelConfigIsAlphaOnly(srcDevTex->config())) {
1611 // Can this happen? 1626 // Can this happen?
1612 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); 1627 fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp));
1613 } else { 1628 } else {
1614 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); 1629 fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
1615 } 1630 }
1616 1631
1617 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint)) { 1632 if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, &grPaint, fRe nderTarget)) {
1618 return; 1633 return;
1619 } 1634 }
1620 1635
1621 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x), 1636 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(x),
1622 SkIntToScalar(y), 1637 SkIntToScalar(y),
1623 SkIntToScalar(w), 1638 SkIntToScalar(w),
1624 SkIntToScalar(h)); 1639 SkIntToScalar(h));
1625 1640
1626 // The device being drawn may not fill up its texture (e.g. saveLayer uses a pproximate 1641 // The device being drawn may not fill up its texture (e.g. saveLayer uses a pproximate
1627 // scratch texture). 1642 // scratch texture).
1628 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), 1643 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / srcDevTex->width(),
1629 SK_Scalar1 * h / devTex->height()); 1644 SK_Scalar1 * h / srcDevTex->height());
1630 1645
1631 fDrawContext->fillRectToRect(fClip, grPaint, SkMatrix::I(), dstRect, srcRect ); 1646 fDrawContext->fillRectToRect(fClip, grPaint, SkMatrix::I(), dstRect, srcRect );
1632 } 1647 }
1633 1648
1649 void SkGpuDevice::discard37() {
1650 fDrawContext->discard();
1651 // TODO: we need to close off the DrawTarget & create a new one
1652 }
1653
1634 bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { 1654 bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) {
1635 return filter->canFilterImageGPU(); 1655 return filter->canFilterImageGPU();
1636 } 1656 }
1637 1657
1638 bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, 1658 bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src,
1639 const SkImageFilter::Context& ctx, 1659 const SkImageFilter::Context& ctx,
1640 SkBitmap* result, SkIPoint* offset) { 1660 SkBitmap* result, SkIPoint* offset) {
1641 // want explicitly our impl, so guard against a subclass of us overriding it 1661 // want explicitly our impl, so guard against a subclass of us overriding it
1642 if (!this->SkGpuDevice::canHandleImageFilter(filter)) { 1662 if (!this->SkGpuDevice::canHandleImageFilter(filter)) {
1643 return false; 1663 return false;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), viewMatrix)) { 1737 if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), viewMatrix)) {
1718 // only support tiling as bitmap at the moment, so force raster-version 1738 // only support tiling as bitmap at the moment, so force raster-version
1719 if (!as_IB(image)->getROPixels(&bm)) { 1739 if (!as_IB(image)->getROPixels(&bm)) {
1720 return; 1740 return;
1721 } 1741 }
1722 } else { 1742 } else {
1723 if (!wrap_as_bm(this->context(), image, &bm)) { 1743 if (!wrap_as_bm(this->context(), image, &bm)) {
1724 return; 1744 return;
1725 } 1745 }
1726 } 1746 }
1747
1727 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); 1748 this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
1728 } 1749 }
1729 1750
1730 /////////////////////////////////////////////////////////////////////////////// 1751 ///////////////////////////////////////////////////////////////////////////////
1731 1752
1732 // must be in SkCanvas::VertexMode order 1753 // must be in SkCanvas::VertexMode order
1733 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { 1754 static const GrPrimitiveType gVertexMode2PrimitiveType[] = {
1734 kTriangles_GrPrimitiveType, 1755 kTriangles_GrPrimitiveType,
1735 kTriangleStrip_GrPrimitiveType, 1756 kTriangleStrip_GrPrimitiveType,
1736 kTriangleFan_GrPrimitiveType, 1757 kTriangleFan_GrPrimitiveType,
(...skipping 12 matching lines...) Expand all
1749 if ((nullptr == texs || nullptr == paint.getShader()) && nullptr == colors) { 1770 if ((nullptr == texs || nullptr == paint.getShader()) && nullptr == colors) {
1750 1771
1751 texs = nullptr; 1772 texs = nullptr;
1752 1773
1753 SkPaint copy(paint); 1774 SkPaint copy(paint);
1754 copy.setStyle(SkPaint::kStroke_Style); 1775 copy.setStyle(SkPaint::kStroke_Style);
1755 copy.setStrokeWidth(0); 1776 copy.setStrokeWidth(0);
1756 1777
1757 GrPaint grPaint; 1778 GrPaint grPaint;
1758 // we ignore the shader if texs is null. 1779 // we ignore the shader if texs is null.
1759 if (!SkPaintToGrPaintNoShader(this->context(), copy, &grPaint)) { 1780 if (!SkPaintToGrPaintNoShader(this->context(), copy, &grPaint, fRenderTa rget)) {
1760 return; 1781 return;
1761 } 1782 }
1762 1783
1763 int triangleCount = 0; 1784 int triangleCount = 0;
1764 int n = (nullptr == indices) ? vertexCount : indexCount; 1785 int n = (nullptr == indices) ? vertexCount : indexCount;
1765 switch (vmode) { 1786 switch (vmode) {
1766 case SkCanvas::kTriangles_VertexMode: 1787 case SkCanvas::kTriangles_VertexMode:
1767 triangleCount = n / 3; 1788 triangleCount = n / 3;
1768 break; 1789 break;
1769 case SkCanvas::kTriangleStrip_VertexMode: 1790 case SkCanvas::kTriangleStrip_VertexMode:
(...skipping 12 matching lines...) Expand all
1782 int i = 0; 1803 int i = 0;
1783 while (vertProc(&state)) { 1804 while (vertProc(&state)) {
1784 lineIndices[i] = state.f0; 1805 lineIndices[i] = state.f0;
1785 lineIndices[i + 1] = state.f1; 1806 lineIndices[i + 1] = state.f1;
1786 lineIndices[i + 2] = state.f1; 1807 lineIndices[i + 2] = state.f1;
1787 lineIndices[i + 3] = state.f2; 1808 lineIndices[i + 3] = state.f2;
1788 lineIndices[i + 4] = state.f2; 1809 lineIndices[i + 4] = state.f2;
1789 lineIndices[i + 5] = state.f0; 1810 lineIndices[i + 5] = state.f0;
1790 i += 6; 1811 i += 6;
1791 } 1812 }
1813
1792 fDrawContext->drawVertices(fClip, 1814 fDrawContext->drawVertices(fClip,
1793 grPaint, 1815 grPaint,
1794 *draw.fMatrix, 1816 *draw.fMatrix,
1795 kLines_GrPrimitiveType, 1817 kLines_GrPrimitiveType,
1796 vertexCount, 1818 vertexCount,
1797 vertices, 1819 vertices,
1798 texs, 1820 texs,
1799 colors, 1821 colors,
1800 lineIndices.get(), 1822 lineIndices.get(),
1801 indexCount); 1823 indexCount);
(...skipping 19 matching lines...) Expand all
1821 // xmode is defined to mean modulate. 1843 // xmode is defined to mean modulate.
1822 SkXfermode::Mode colorMode; 1844 SkXfermode::Mode colorMode;
1823 if (xmode) { 1845 if (xmode) {
1824 if (!xmode->asMode(&colorMode)) { 1846 if (!xmode->asMode(&colorMode)) {
1825 return; 1847 return;
1826 } 1848 }
1827 } else { 1849 } else {
1828 colorMode = SkXfermode::kModulate_Mode; 1850 colorMode = SkXfermode::kModulate_Mode;
1829 } 1851 }
1830 if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMat rix, colorMode, 1852 if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMat rix, colorMode,
1831 false, &grPaint)) { 1853 false, &grPaint, fRenderTarget)) {
1832 return; 1854 return;
1833 } 1855 }
1834 } else { 1856 } else {
1835 // We have a shader, but no colors to blend it against. 1857 // We have a shader, but no colors to blend it against.
1836 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPain t)) { 1858 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPain t, fRenderTarget)) {
1837 return; 1859 return;
1838 } 1860 }
1839 } 1861 }
1840 } else { 1862 } else {
1841 if (colors) { 1863 if (colors) {
1842 // We have colors, but either have no shader or no texture coords (w hich implies that 1864 // We have colors, but either have no shader or no texture coords (w hich implies that
1843 // we should ignore the shader). 1865 // we should ignore the shader).
1844 if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint, &grP aint)) { 1866 if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint, &grP aint, fRenderTarget)) {
1845 return; 1867 return;
1846 } 1868 }
1847 } else { 1869 } else {
1848 // No colors and no shaders. Just draw with the paint color. 1870 // No colors and no shaders. Just draw with the paint color.
1849 if (!SkPaintToGrPaintNoShader(this->context(), paint, &grPaint)) { 1871 if (!SkPaintToGrPaintNoShader(this->context(), paint, &grPaint, fRen derTarget)) {
1850 return; 1872 return;
1851 } 1873 }
1852 } 1874 }
1853 } 1875 }
1854 1876
1855 fDrawContext->drawVertices(fClip, 1877 fDrawContext->drawVertices(fClip,
1856 grPaint, 1878 grPaint,
1857 *draw.fMatrix, 1879 *draw.fMatrix,
1858 primType, 1880 primType,
1859 vertexCount, 1881 vertexCount,
(...skipping 14 matching lines...) Expand all
1874 return; 1896 return;
1875 } 1897 }
1876 1898
1877 CHECK_SHOULD_DRAW(draw); 1899 CHECK_SHOULD_DRAW(draw);
1878 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); 1900 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
1879 1901
1880 SkPaint p(paint); 1902 SkPaint p(paint);
1881 p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_Til eMode))->unref(); 1903 p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_Til eMode))->unref();
1882 1904
1883 GrPaint grPaint; 1905 GrPaint grPaint;
1906
1884 if (colors) { 1907 if (colors) {
1885 if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mod e, true, 1908 if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mod e, true,
1886 &grPaint)) { 1909 &grPaint, fRenderTarget)) {
1887 return; 1910 return;
1888 } 1911 }
1889 } else { 1912 } else {
1890 if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix, &grPaint)) { 1913 if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix, &grPaint, fRend erTarget)) {
1891 return; 1914 return;
1892 } 1915 }
1893 } 1916 }
1894 1917
1895 SkDEBUGCODE(this->validate();) 1918 SkDEBUGCODE(this->validate();)
1896 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect , colors); 1919 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect , colors);
1897 } 1920 }
1898 1921
1899 /////////////////////////////////////////////////////////////////////////////// 1922 ///////////////////////////////////////////////////////////////////////////////
1900 1923
1901 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, 1924 void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
1902 size_t byteLength, SkScalar x, SkScalar y, 1925 size_t byteLength, SkScalar x, SkScalar y,
1903 const SkPaint& paint) { 1926 const SkPaint& paint) {
1904 CHECK_SHOULD_DRAW(draw); 1927 CHECK_SHOULD_DRAW(draw);
1905 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext); 1928 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
1906 1929
1907 GrPaint grPaint; 1930 GrPaint grPaint;
1908 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 1931 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRend erTarget)) {
1909 return; 1932 return;
1910 } 1933 }
1911 1934
1912 SkDEBUGCODE(this->validate();) 1935 SkDEBUGCODE(this->validate();)
1913 1936
1914 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix, 1937 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix,
1915 (const char *)text, byteLength, x, y, draw.fClip->get Bounds()); 1938 (const char *)text, byteLength, x, y, draw.fClip->get Bounds());
1916 } 1939 }
1917 1940
1918 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL ength, 1941 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL ength,
1919 const SkScalar pos[], int scalarsPerPos, 1942 const SkScalar pos[], int scalarsPerPos,
1920 const SkPoint& offset, const SkPaint& paint) { 1943 const SkPoint& offset, const SkPaint& paint) {
1921 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext); 1944 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext);
1922 CHECK_SHOULD_DRAW(draw); 1945 CHECK_SHOULD_DRAW(draw);
1923 1946
1924 GrPaint grPaint; 1947 GrPaint grPaint;
1925 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { 1948 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint, fRend erTarget)) {
1926 return; 1949 return;
1927 } 1950 }
1928 1951
1929 SkDEBUGCODE(this->validate();) 1952 SkDEBUGCODE(this->validate();)
1930 1953
1931 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix, 1954 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix,
1932 (const char *)text, byteLength, pos, scalarsPerPos , offset, 1955 (const char *)text, byteLength, pos, scalarsPerPos , offset,
1933 draw.fClip->getBounds()); 1956 draw.fClip->getBounds());
1934 } 1957 }
1935 1958
1936 void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca lar x, SkScalar y, 1959 void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca lar x, SkScalar y,
1937 const SkPaint& paint, SkDrawFilter* drawFilter) { 1960 const SkPaint& paint, SkDrawFilter* drawFilter) {
1961 if (fContext->abandoned()) {
1962 return;
1963 }
1964
1938 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawTextBlob", fContext); 1965 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawTextBlob", fContext);
1939 CHECK_SHOULD_DRAW(draw); 1966 CHECK_SHOULD_DRAW(draw);
1940 1967
1941 SkDEBUGCODE(this->validate();) 1968 SkDEBUGCODE(this->validate();)
1942 1969
1943 fDrawContext->drawTextBlob(fClip, paint, *draw.fMatrix, 1970 fDrawContext->drawTextBlob(fClip, paint, *draw.fMatrix,
1944 blob, x, y, drawFilter, draw.fClip->getBounds()); 1971 blob, x, y, drawFilter, draw.fClip->getBounds());
1945 } 1972 }
1946 1973
1947 /////////////////////////////////////////////////////////////////////////////// 1974 ///////////////////////////////////////////////////////////////////////////////
1948 1975
1949 bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { 1976 bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const {
1950 return GrTextContext::ShouldDisableLCD(paint); 1977 return GrTextContext::ShouldDisableLCD(paint);
1951 } 1978 }
1952 1979
1953 void SkGpuDevice::flush() { 1980 void SkGpuDevice::flush() {
1954 DO_DEFERRED_CLEAR(); 1981 DO_DEFERRED_CLEAR();
1982
1955 fRenderTarget->prepareForExternalIO(); 1983 fRenderTarget->prepareForExternalIO();
1956 } 1984 }
1957 1985
1958 /////////////////////////////////////////////////////////////////////////////// 1986 ///////////////////////////////////////////////////////////////////////////////
1959 1987
1960 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint *) { 1988 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint *) {
1961 GrSurfaceDesc desc; 1989 GrSurfaceDesc desc;
1962 desc.fConfig = fRenderTarget->config(); 1990 desc.fConfig = fRenderTarget->config();
1963 desc.fFlags = kRenderTarget_GrSurfaceFlag; 1991 desc.fFlags = kRenderTarget_GrSurfaceFlag;
1964 desc.fWidth = cinfo.fInfo.width(); 1992 desc.fWidth = cinfo.fInfo.width();
(...skipping 24 matching lines...) Expand all
1989 } 2017 }
1990 } 2018 }
1991 2019
1992 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) { 2020 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) {
1993 // TODO: Change the signature of newSurface to take a budgeted parameter. 2021 // TODO: Change the signature of newSurface to take a budgeted parameter.
1994 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; 2022 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted;
1995 return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget-> desc().fSampleCnt, 2023 return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget-> desc().fSampleCnt,
1996 &props); 2024 &props);
1997 } 2025 }
1998 2026
2027 #define SK_IGNORE_GPU_LAYER_HOISTING 1
2028
1999 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture * mainPicture, 2029 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture * mainPicture,
2000 const SkMatrix* matrix, const SkPaint * paint) { 2030 const SkMatrix* matrix, const SkPaint * paint) {
2001 #ifndef SK_IGNORE_GPU_LAYER_HOISTING 2031 #ifndef SK_IGNORE_GPU_LAYER_HOISTING
2002 // todo: should handle this natively 2032 // todo: should handle this natively
2003 if (paint) { 2033 if (paint) {
2004 return false; 2034 return false;
2005 } 2035 }
2006 2036
2007 const SkBigPicture::AccelData* data = nullptr; 2037 const SkBigPicture::AccelData* data = nullptr;
2008 if (const SkBigPicture* bp = mainPicture->asSkBigPicture()) { 2038 if (const SkBigPicture* bp = mainPicture->asSkBigPicture()) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 2100 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
2071 } 2101 }
2072 2102
2073 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 2103 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
2074 // We always return a transient cache, so it is freed after each 2104 // We always return a transient cache, so it is freed after each
2075 // filter traversal. 2105 // filter traversal.
2076 return SkGpuDevice::NewImageFilterCache(); 2106 return SkGpuDevice::NewImageFilterCache();
2077 } 2107 }
2078 2108
2079 #endif 2109 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/SkGpuDevice_drawTexture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698