| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "SkXfermode.h" | 43 #include "SkXfermode.h" |
| 44 #include "batches/GrRectBatchFactory.h" | 44 #include "batches/GrRectBatchFactory.h" |
| 45 #include "effects/GrBicubicEffect.h" | 45 #include "effects/GrBicubicEffect.h" |
| 46 #include "effects/GrDashingEffect.h" | 46 #include "effects/GrDashingEffect.h" |
| 47 #include "effects/GrSimpleTextureEffect.h" | 47 #include "effects/GrSimpleTextureEffect.h" |
| 48 #include "effects/GrTextureDomain.h" | 48 #include "effects/GrTextureDomain.h" |
| 49 #include "text/GrTextContext.h" | 49 #include "text/GrTextContext.h" |
| 50 | 50 |
| 51 #if SK_SUPPORT_GPU | 51 #if SK_SUPPORT_GPU |
| 52 | 52 |
| 53 #define ASSERT_SINGLE_OWNER \ |
| 54 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fContext->debugSing
leOwner());) |
| 55 |
| 53 enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; | 56 enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; |
| 54 | 57 |
| 55 #if 0 | 58 #if 0 |
| 56 extern bool (*gShouldDrawProc)(); | 59 extern bool (*gShouldDrawProc)(); |
| 57 #define CHECK_SHOULD_DRAW(draw) \ | 60 #define CHECK_SHOULD_DRAW(draw) \ |
| 58 do { \ | 61 do { \ |
| 59 if (gShouldDrawProc && !gShouldDrawProc()) return; \ | 62 if (gShouldDrawProc && !gShouldDrawProc()) return; \ |
| 60 this->prepareDraw(draw); \ | 63 this->prepareDraw(draw); \ |
| 61 } while (0) | 64 } while (0) |
| 62 #else | 65 #else |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 return nullptr; | 223 return nullptr; |
| 221 } | 224 } |
| 222 SkASSERT(nullptr != texture->asRenderTarget()); | 225 SkASSERT(nullptr != texture->asRenderTarget()); |
| 223 return texture->asRenderTarget(); | 226 return texture->asRenderTarget(); |
| 224 } | 227 } |
| 225 | 228 |
| 226 /////////////////////////////////////////////////////////////////////////////// | 229 /////////////////////////////////////////////////////////////////////////////// |
| 227 | 230 |
| 228 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
_t dstRowBytes, | 231 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
_t dstRowBytes, |
| 229 int x, int y) { | 232 int x, int y) { |
| 233 ASSERT_SINGLE_OWNER |
| 230 DO_DEFERRED_CLEAR(); | 234 DO_DEFERRED_CLEAR(); |
| 231 | 235 |
| 232 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels | 236 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels |
| 233 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo); | 237 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo); |
| 234 if (kUnknown_GrPixelConfig == config) { | 238 if (kUnknown_GrPixelConfig == config) { |
| 235 return false; | 239 return false; |
| 236 } | 240 } |
| 237 | 241 |
| 238 uint32_t flags = 0; | 242 uint32_t flags = 0; |
| 239 if (kUnpremul_SkAlphaType == dstInfo.alphaType()) { | 243 if (kUnpremul_SkAlphaType == dstInfo.alphaType()) { |
| 240 flags = GrContext::kUnpremul_PixelOpsFlag; | 244 flags = GrContext::kUnpremul_PixelOpsFlag; |
| 241 } | 245 } |
| 242 return fRenderTarget->readPixels(x, y, dstInfo.width(), dstInfo.height(), co
nfig, dstPixels, | 246 return fRenderTarget->readPixels(x, y, dstInfo.width(), dstInfo.height(), co
nfig, dstPixels, |
| 243 dstRowBytes, flags); | 247 dstRowBytes, flags); |
| 244 } | 248 } |
| 245 | 249 |
| 246 bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz
e_t rowBytes, | 250 bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz
e_t rowBytes, |
| 247 int x, int y) { | 251 int x, int y) { |
| 252 ASSERT_SINGLE_OWNER |
| 248 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels | 253 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels |
| 249 GrPixelConfig config = SkImageInfo2GrPixelConfig(info); | 254 GrPixelConfig config = SkImageInfo2GrPixelConfig(info); |
| 250 if (kUnknown_GrPixelConfig == config) { | 255 if (kUnknown_GrPixelConfig == config) { |
| 251 return false; | 256 return false; |
| 252 } | 257 } |
| 253 uint32_t flags = 0; | 258 uint32_t flags = 0; |
| 254 if (kUnpremul_SkAlphaType == info.alphaType()) { | 259 if (kUnpremul_SkAlphaType == info.alphaType()) { |
| 255 flags = GrContext::kUnpremul_PixelOpsFlag; | 260 flags = GrContext::kUnpremul_PixelOpsFlag; |
| 256 } | 261 } |
| 257 fRenderTarget->writePixels(x, y, info.width(), info.height(), config, pixels
, rowBytes, flags); | 262 fRenderTarget->writePixels(x, y, info.width(), info.height(), config, pixels
, rowBytes, flags); |
| 258 | 263 |
| 259 // need to bump our genID for compatibility with clients that "know" we have
a bitmap | 264 // need to bump our genID for compatibility with clients that "know" we have
a bitmap |
| 260 fLegacyBitmap.notifyPixelsChanged(); | 265 fLegacyBitmap.notifyPixelsChanged(); |
| 261 | 266 |
| 262 return true; | 267 return true; |
| 263 } | 268 } |
| 264 | 269 |
| 265 const SkBitmap& SkGpuDevice::onAccessBitmap() { | 270 const SkBitmap& SkGpuDevice::onAccessBitmap() { |
| 271 ASSERT_SINGLE_OWNER |
| 266 DO_DEFERRED_CLEAR(); | 272 DO_DEFERRED_CLEAR(); |
| 267 return fLegacyBitmap; | 273 return fLegacyBitmap; |
| 268 } | 274 } |
| 269 | 275 |
| 270 bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) { | 276 bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) { |
| 277 ASSERT_SINGLE_OWNER |
| 271 DO_DEFERRED_CLEAR(); | 278 DO_DEFERRED_CLEAR(); |
| 272 // For compatibility with clients the know we're backed w/ a bitmap, and wan
t to inspect its | 279 // For compatibility with clients the know we're backed w/ a bitmap, and wan
t to inspect its |
| 273 // genID. When we can hide/remove that fact, we can eliminate this call to n
otify. | 280 // genID. When we can hide/remove that fact, we can eliminate this call to n
otify. |
| 274 // ... ugh. | 281 // ... ugh. |
| 275 fLegacyBitmap.notifyPixelsChanged(); | 282 fLegacyBitmap.notifyPixelsChanged(); |
| 276 return false; | 283 return false; |
| 277 } | 284 } |
| 278 | 285 |
| 279 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { | 286 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { |
| 287 ASSERT_SINGLE_OWNER |
| 280 INHERITED::onAttachToCanvas(canvas); | 288 INHERITED::onAttachToCanvas(canvas); |
| 281 | 289 |
| 282 // Canvas promises that this ptr is valid until onDetachFromCanvas is called | 290 // Canvas promises that this ptr is valid until onDetachFromCanvas is called |
| 283 fClipStack.reset(SkRef(canvas->getClipStack())); | 291 fClipStack.reset(SkRef(canvas->getClipStack())); |
| 284 } | 292 } |
| 285 | 293 |
| 286 void SkGpuDevice::onDetachFromCanvas() { | 294 void SkGpuDevice::onDetachFromCanvas() { |
| 295 ASSERT_SINGLE_OWNER |
| 287 INHERITED::onDetachFromCanvas(); | 296 INHERITED::onDetachFromCanvas(); |
| 288 fClip.reset(); | 297 fClip.reset(); |
| 289 fClipStack.reset(nullptr); | 298 fClipStack.reset(nullptr); |
| 290 } | 299 } |
| 291 | 300 |
| 292 // call this every draw call, to ensure that the context reflects our state, | 301 // call this every draw call, to ensure that the context reflects our state, |
| 293 // and not the state from some other canvas/device | 302 // and not the state from some other canvas/device |
| 294 void SkGpuDevice::prepareDraw(const SkDraw& draw) { | 303 void SkGpuDevice::prepareDraw(const SkDraw& draw) { |
| 304 ASSERT_SINGLE_OWNER |
| 295 SkASSERT(fClipStack.get()); | 305 SkASSERT(fClipStack.get()); |
| 296 | 306 |
| 297 SkASSERT(draw.fClipStack && draw.fClipStack == fClipStack); | 307 SkASSERT(draw.fClipStack && draw.fClipStack == fClipStack); |
| 298 | 308 |
| 299 fClip.setClipStack(fClipStack, &this->getOrigin()); | 309 fClip.setClipStack(fClipStack, &this->getOrigin()); |
| 300 | 310 |
| 301 DO_DEFERRED_CLEAR(); | 311 DO_DEFERRED_CLEAR(); |
| 302 } | 312 } |
| 303 | 313 |
| 304 GrRenderTarget* SkGpuDevice::accessRenderTarget() { | 314 GrRenderTarget* SkGpuDevice::accessRenderTarget() { |
| 315 ASSERT_SINGLE_OWNER |
| 305 DO_DEFERRED_CLEAR(); | 316 DO_DEFERRED_CLEAR(); |
| 306 return fRenderTarget; | 317 return fRenderTarget; |
| 307 } | 318 } |
| 308 | 319 |
| 309 void SkGpuDevice::clearAll() { | 320 void SkGpuDevice::clearAll() { |
| 321 ASSERT_SINGLE_OWNER |
| 310 GrColor color = 0; | 322 GrColor color = 0; |
| 311 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "clearAll", fContext); | 323 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "clearAll", fContext); |
| 312 SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); | 324 SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); |
| 313 fDrawContext->clear(&rect, color, true); | 325 fDrawContext->clear(&rect, color, true); |
| 314 fNeedClear = false; | 326 fNeedClear = false; |
| 315 } | 327 } |
| 316 | 328 |
| 317 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { | 329 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { |
| 330 ASSERT_SINGLE_OWNER |
| 318 // Caller must have accessed the render target, because it knows the rt must
be replaced. | 331 // Caller must have accessed the render target, because it knows the rt must
be replaced. |
| 319 SkASSERT(!fNeedClear); | 332 SkASSERT(!fNeedClear); |
| 320 | 333 |
| 321 SkSurface::Budgeted budgeted = | 334 SkSurface::Budgeted budgeted = |
| 322 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete
d | 335 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete
d |
| 323 : SkSurface::kNo_Budgeted
; | 336 : SkSurface::kNo_Budgeted
; |
| 324 | 337 |
| 325 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget( | 338 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget( |
| 326 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam
pleCnt)); | 339 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam
pleCnt)); |
| 327 | 340 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 347 #endif | 360 #endif |
| 348 SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget); | 361 SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget); |
| 349 fLegacyBitmap.setPixelRef(pr)->unref(); | 362 fLegacyBitmap.setPixelRef(pr)->unref(); |
| 350 | 363 |
| 351 fDrawContext.reset(this->context()->drawContext(fRenderTarget, &this->surfac
eProps())); | 364 fDrawContext.reset(this->context()->drawContext(fRenderTarget, &this->surfac
eProps())); |
| 352 } | 365 } |
| 353 | 366 |
| 354 /////////////////////////////////////////////////////////////////////////////// | 367 /////////////////////////////////////////////////////////////////////////////// |
| 355 | 368 |
| 356 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 369 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
| 370 ASSERT_SINGLE_OWNER |
| 357 CHECK_SHOULD_DRAW(draw); | 371 CHECK_SHOULD_DRAW(draw); |
| 358 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext); | 372 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext); |
| 359 | 373 |
| 360 GrPaint grPaint; | 374 GrPaint grPaint; |
| 361 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 375 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |
| 362 return; | 376 return; |
| 363 } | 377 } |
| 364 | 378 |
| 365 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix); | 379 fDrawContext->drawPaint(fClip, grPaint, *draw.fMatrix); |
| 366 } | 380 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 389 } | 403 } |
| 390 if (pts[0].fY == pts[1].fY) { | 404 if (pts[0].fY == pts[1].fY) { |
| 391 return ((int) pts[0].fY) != pts[0].fY; | 405 return ((int) pts[0].fY) != pts[0].fY; |
| 392 } | 406 } |
| 393 } | 407 } |
| 394 return true; | 408 return true; |
| 395 } | 409 } |
| 396 | 410 |
| 397 void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, | 411 void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, |
| 398 size_t count, const SkPoint pts[], const SkPaint& p
aint) { | 412 size_t count, const SkPoint pts[], const SkPaint& p
aint) { |
| 413 ASSERT_SINGLE_OWNER |
| 399 CHECK_FOR_ANNOTATION(paint); | 414 CHECK_FOR_ANNOTATION(paint); |
| 400 CHECK_SHOULD_DRAW(draw); | 415 CHECK_SHOULD_DRAW(draw); |
| 401 | 416 |
| 402 SkScalar width = paint.getStrokeWidth(); | 417 SkScalar width = paint.getStrokeWidth(); |
| 403 if (width < 0) { | 418 if (width < 0) { |
| 404 return; | 419 return; |
| 405 } | 420 } |
| 406 | 421 |
| 407 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod
e) { | 422 if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mod
e) { |
| 408 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); | 423 GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 439 (SkPoint*)pts, | 454 (SkPoint*)pts, |
| 440 nullptr, | 455 nullptr, |
| 441 nullptr, | 456 nullptr, |
| 442 nullptr, | 457 nullptr, |
| 443 0); | 458 0); |
| 444 } | 459 } |
| 445 | 460 |
| 446 /////////////////////////////////////////////////////////////////////////////// | 461 /////////////////////////////////////////////////////////////////////////////// |
| 447 | 462 |
| 448 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint
& paint) { | 463 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint
& paint) { |
| 464 ASSERT_SINGLE_OWNER |
| 449 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRect", fContext); | 465 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRect", fContext); |
| 450 CHECK_FOR_ANNOTATION(paint); | 466 CHECK_FOR_ANNOTATION(paint); |
| 451 CHECK_SHOULD_DRAW(draw); | 467 CHECK_SHOULD_DRAW(draw); |
| 452 | 468 |
| 453 bool doStroke = paint.getStyle() != SkPaint::kFill_Style; | 469 bool doStroke = paint.getStyle() != SkPaint::kFill_Style; |
| 454 SkScalar width = paint.getStrokeWidth(); | 470 SkScalar width = paint.getStrokeWidth(); |
| 455 | 471 |
| 456 /* | 472 /* |
| 457 We have special code for hairline strokes, miter-strokes, bevel-stroke | 473 We have special code for hairline strokes, miter-strokes, bevel-stroke |
| 458 and fills. Anything else we just call our path code. | 474 and fills. Anything else we just call our path code. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 485 | 501 |
| 486 GrStrokeInfo strokeInfo(paint); | 502 GrStrokeInfo strokeInfo(paint); |
| 487 | 503 |
| 488 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); | 504 fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); |
| 489 } | 505 } |
| 490 | 506 |
| 491 /////////////////////////////////////////////////////////////////////////////// | 507 /////////////////////////////////////////////////////////////////////////////// |
| 492 | 508 |
| 493 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 509 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |
| 494 const SkPaint& paint) { | 510 const SkPaint& paint) { |
| 511 ASSERT_SINGLE_OWNER |
| 495 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext); | 512 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext); |
| 496 CHECK_FOR_ANNOTATION(paint); | 513 CHECK_FOR_ANNOTATION(paint); |
| 497 CHECK_SHOULD_DRAW(draw); | 514 CHECK_SHOULD_DRAW(draw); |
| 498 | 515 |
| 499 GrPaint grPaint; | 516 GrPaint grPaint; |
| 500 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 517 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |
| 501 return; | 518 return; |
| 502 } | 519 } |
| 503 | 520 |
| 504 GrStrokeInfo strokeInfo(paint); | 521 GrStrokeInfo strokeInfo(paint); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 return; | 565 return; |
| 549 } | 566 } |
| 550 | 567 |
| 551 SkASSERT(!strokeInfo.isDashed()); | 568 SkASSERT(!strokeInfo.isDashed()); |
| 552 | 569 |
| 553 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); | 570 fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); |
| 554 } | 571 } |
| 555 | 572 |
| 556 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, | 573 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |
| 557 const SkRRect& inner, const SkPaint& paint) { | 574 const SkRRect& inner, const SkPaint& paint) { |
| 575 ASSERT_SINGLE_OWNER |
| 558 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDRRect", fContext); | 576 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDRRect", fContext); |
| 559 CHECK_FOR_ANNOTATION(paint); | 577 CHECK_FOR_ANNOTATION(paint); |
| 560 CHECK_SHOULD_DRAW(draw); | 578 CHECK_SHOULD_DRAW(draw); |
| 561 | 579 |
| 562 SkStrokeRec stroke(paint); | 580 SkStrokeRec stroke(paint); |
| 563 | 581 |
| 564 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()
) { | 582 if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()
) { |
| 565 GrPaint grPaint; | 583 GrPaint grPaint; |
| 566 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint))
{ | 584 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint))
{ |
| 567 return; | 585 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 580 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, | 598 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, |
| 581 fClip, path, paint, | 599 fClip, path, paint, |
| 582 *draw.fMatrix, nullptr, | 600 *draw.fMatrix, nullptr, |
| 583 draw.fClip->getBounds(), true); | 601 draw.fClip->getBounds(), true); |
| 584 } | 602 } |
| 585 | 603 |
| 586 | 604 |
| 587 ///////////////////////////////////////////////////////////////////////////// | 605 ///////////////////////////////////////////////////////////////////////////// |
| 588 | 606 |
| 589 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint
& paint) { | 607 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint
& paint) { |
| 608 ASSERT_SINGLE_OWNER |
| 590 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawOval", fContext); | 609 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawOval", fContext); |
| 591 CHECK_FOR_ANNOTATION(paint); | 610 CHECK_FOR_ANNOTATION(paint); |
| 592 CHECK_SHOULD_DRAW(draw); | 611 CHECK_SHOULD_DRAW(draw); |
| 593 | 612 |
| 594 // Presumably the path effect warps this to something other than an oval | 613 // Presumably the path effect warps this to something other than an oval |
| 595 if (paint.getPathEffect()) { | 614 if (paint.getPathEffect()) { |
| 596 SkPath path; | 615 SkPath path; |
| 597 path.setIsVolatile(true); | 616 path.setIsVolatile(true); |
| 598 path.addOval(oval); | 617 path.addOval(oval); |
| 599 this->drawPath(draw, path, paint, nullptr, true); | 618 this->drawPath(draw, path, paint, nullptr, true); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 624 static SkBitmap wrap_texture(GrTexture* texture, int width, int height) { | 643 static SkBitmap wrap_texture(GrTexture* texture, int width, int height) { |
| 625 SkBitmap result; | 644 SkBitmap result; |
| 626 result.setInfo(SkImageInfo::MakeN32Premul(width, height)); | 645 result.setInfo(SkImageInfo::MakeN32Premul(width, height)); |
| 627 result.setPixelRef(new SkGrPixelRef(result.info(), texture))->unref(); | 646 result.setPixelRef(new SkGrPixelRef(result.info(), texture))->unref(); |
| 628 return result; | 647 return result; |
| 629 } | 648 } |
| 630 | 649 |
| 631 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, | 650 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
| 632 const SkPaint& paint, const SkMatrix* prePathMatrix, | 651 const SkPaint& paint, const SkMatrix* prePathMatrix, |
| 633 bool pathIsMutable) { | 652 bool pathIsMutable) { |
| 653 ASSERT_SINGLE_OWNER |
| 634 if (!origSrcPath.isInverseFillType() && !paint.getPathEffect() && !prePathMa
trix) { | 654 if (!origSrcPath.isInverseFillType() && !paint.getPathEffect() && !prePathMa
trix) { |
| 635 bool isClosed; | 655 bool isClosed; |
| 636 SkRect rect; | 656 SkRect rect; |
| 637 if (origSrcPath.isRect(&rect, &isClosed) && isClosed) { | 657 if (origSrcPath.isRect(&rect, &isClosed) && isClosed) { |
| 638 this->drawRect(draw, rect, paint); | 658 this->drawRect(draw, rect, paint); |
| 639 return; | 659 return; |
| 640 } | 660 } |
| 641 if (origSrcPath.isOval(&rect)) { | 661 if (origSrcPath.isOval(&rect)) { |
| 642 this->drawOval(draw, rect, paint); | 662 this->drawOval(draw, rect, paint); |
| 643 return; | 663 return; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 } | 736 } |
| 717 } | 737 } |
| 718 | 738 |
| 719 bool SkGpuDevice::shouldTileImageID(uint32_t imageID, const SkIRect& imageRect, | 739 bool SkGpuDevice::shouldTileImageID(uint32_t imageID, const SkIRect& imageRect, |
| 720 const SkMatrix& viewMatrix, | 740 const SkMatrix& viewMatrix, |
| 721 const GrTextureParams& params, | 741 const GrTextureParams& params, |
| 722 const SkRect* srcRectPtr, | 742 const SkRect* srcRectPtr, |
| 723 int maxTileSize, | 743 int maxTileSize, |
| 724 int* tileSize, | 744 int* tileSize, |
| 725 SkIRect* clippedSubset) const { | 745 SkIRect* clippedSubset) const { |
| 746 ASSERT_SINGLE_OWNER |
| 726 // if it's larger than the max tile size, then we have no choice but tiling. | 747 // if it's larger than the max tile size, then we have no choice but tiling. |
| 727 if (imageRect.width() > maxTileSize || imageRect.height() > maxTileSize) { | 748 if (imageRect.width() > maxTileSize || imageRect.height() > maxTileSize) { |
| 728 determine_clipped_src_rect(fRenderTarget, fClip, viewMatrix, imageRect.s
ize(), | 749 determine_clipped_src_rect(fRenderTarget, fClip, viewMatrix, imageRect.s
ize(), |
| 729 srcRectPtr, clippedSubset); | 750 srcRectPtr, clippedSubset); |
| 730 *tileSize = determine_tile_size(*clippedSubset, maxTileSize); | 751 *tileSize = determine_tile_size(*clippedSubset, maxTileSize); |
| 731 return true; | 752 return true; |
| 732 } | 753 } |
| 733 | 754 |
| 734 // If the image would only produce 4 tiles of the smaller size, don't bother
tiling it. | 755 // If the image would only produce 4 tiles of the smaller size, don't bother
tiling it. |
| 735 const size_t area = imageRect.width() * imageRect.height(); | 756 const size_t area = imageRect.width() * imageRect.height(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 762 return usedTileBytes < 2 * bmpSize; | 783 return usedTileBytes < 2 * bmpSize; |
| 763 } | 784 } |
| 764 | 785 |
| 765 bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap, | 786 bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap, |
| 766 const SkMatrix& viewMatrix, | 787 const SkMatrix& viewMatrix, |
| 767 const GrTextureParams& params, | 788 const GrTextureParams& params, |
| 768 const SkRect* srcRectPtr, | 789 const SkRect* srcRectPtr, |
| 769 int maxTileSize, | 790 int maxTileSize, |
| 770 int* tileSize, | 791 int* tileSize, |
| 771 SkIRect* clippedSrcRect) const { | 792 SkIRect* clippedSrcRect) const { |
| 793 ASSERT_SINGLE_OWNER |
| 772 // if bitmap is explictly texture backed then just use the texture | 794 // if bitmap is explictly texture backed then just use the texture |
| 773 if (bitmap.getTexture()) { | 795 if (bitmap.getTexture()) { |
| 774 return false; | 796 return false; |
| 775 } | 797 } |
| 776 | 798 |
| 777 return this->shouldTileImageID(bitmap.getGenerationID(), bitmap.getSubset(),
viewMatrix, params, | 799 return this->shouldTileImageID(bitmap.getGenerationID(), bitmap.getSubset(),
viewMatrix, params, |
| 778 srcRectPtr, maxTileSize, tileSize, clippedSrc
Rect); | 800 srcRectPtr, maxTileSize, tileSize, clippedSrc
Rect); |
| 779 } | 801 } |
| 780 | 802 |
| 781 bool SkGpuDevice::shouldTileImage(const SkImage* image, const SkRect* srcRectPtr
, | 803 bool SkGpuDevice::shouldTileImage(const SkImage* image, const SkRect* srcRectPtr
, |
| 782 SkCanvas::SrcRectConstraint constraint, SkFilt
erQuality quality, | 804 SkCanvas::SrcRectConstraint constraint, SkFilt
erQuality quality, |
| 783 const SkMatrix& viewMatrix) const { | 805 const SkMatrix& viewMatrix) const { |
| 806 ASSERT_SINGLE_OWNER |
| 784 // if image is explictly texture backed then just use the texture | 807 // if image is explictly texture backed then just use the texture |
| 785 if (as_IB(image)->peekTexture()) { | 808 if (as_IB(image)->peekTexture()) { |
| 786 return false; | 809 return false; |
| 787 } | 810 } |
| 788 | 811 |
| 789 GrTextureParams params; | 812 GrTextureParams params; |
| 790 bool doBicubic; | 813 bool doBicubic; |
| 791 GrTextureParams::FilterMode textureFilterMode = | 814 GrTextureParams::FilterMode textureFilterMode = |
| 792 GrSkFilterQualityToGrFilterMode(quality, viewMatrix, SkMatri
x::I(), &doBicubic); | 815 GrSkFilterQualityToGrFilterMode(quality, viewMatrix, SkMatri
x::I(), &doBicubic); |
| 793 | 816 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 808 SkIRect outClippedSrcRect; | 831 SkIRect outClippedSrcRect; |
| 809 | 832 |
| 810 return this->shouldTileImageID(image->unique(), image->bounds(), viewMatrix,
params, srcRectPtr, | 833 return this->shouldTileImageID(image->unique(), image->bounds(), viewMatrix,
params, srcRectPtr, |
| 811 maxTileSize, &outTileSize, &outClippedSrcRect
); | 834 maxTileSize, &outTileSize, &outClippedSrcRect
); |
| 812 } | 835 } |
| 813 | 836 |
| 814 void SkGpuDevice::drawBitmap(const SkDraw& origDraw, | 837 void SkGpuDevice::drawBitmap(const SkDraw& origDraw, |
| 815 const SkBitmap& bitmap, | 838 const SkBitmap& bitmap, |
| 816 const SkMatrix& m, | 839 const SkMatrix& m, |
| 817 const SkPaint& paint) { | 840 const SkPaint& paint) { |
| 841 ASSERT_SINGLE_OWNER |
| 818 CHECK_SHOULD_DRAW(origDraw); | 842 CHECK_SHOULD_DRAW(origDraw); |
| 819 SkMatrix viewMatrix; | 843 SkMatrix viewMatrix; |
| 820 viewMatrix.setConcat(*origDraw.fMatrix, m); | 844 viewMatrix.setConcat(*origDraw.fMatrix, m); |
| 821 if (bitmap.getTexture()) { | 845 if (bitmap.getTexture()) { |
| 822 GrBitmapTextureAdjuster adjuster(&bitmap); | 846 GrBitmapTextureAdjuster adjuster(&bitmap); |
| 823 // We can use kFast here because we know texture-backed bitmaps don't su
pport extractSubset. | 847 // We can use kFast here because we know texture-backed bitmaps don't su
pport extractSubset. |
| 824 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S
rcRectConstraint, | 848 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S
rcRectConstraint, |
| 825 viewMatrix, fClip, paint); | 849 viewMatrix, fClip, paint); |
| 826 return; | 850 return; |
| 827 } | 851 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 // been determined to be too large to fit in VRAM | 932 // been determined to be too large to fit in VRAM |
| 909 void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap, | 933 void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap, |
| 910 const SkMatrix& viewMatrix, | 934 const SkMatrix& viewMatrix, |
| 911 const SkRect& srcRect, | 935 const SkRect& srcRect, |
| 912 const SkIRect& clippedSrcIRect, | 936 const SkIRect& clippedSrcIRect, |
| 913 const GrTextureParams& params, | 937 const GrTextureParams& params, |
| 914 const SkPaint& origPaint, | 938 const SkPaint& origPaint, |
| 915 SkCanvas::SrcRectConstraint constraint, | 939 SkCanvas::SrcRectConstraint constraint, |
| 916 int tileSize, | 940 int tileSize, |
| 917 bool bicubic) { | 941 bool bicubic) { |
| 942 ASSERT_SINGLE_OWNER |
| 918 // The following pixel lock is technically redundant, but it is desirable | 943 // The following pixel lock is technically redundant, but it is desirable |
| 919 // to lock outside of the tile loop to prevent redecoding the whole image | 944 // to lock outside of the tile loop to prevent redecoding the whole image |
| 920 // at each tile in cases where 'bitmap' holds an SkDiscardablePixelRef that | 945 // at each tile in cases where 'bitmap' holds an SkDiscardablePixelRef that |
| 921 // is larger than the limit of the discardable memory pool. | 946 // is larger than the limit of the discardable memory pool. |
| 922 SkAutoLockPixels alp(bitmap); | 947 SkAutoLockPixels alp(bitmap); |
| 923 | 948 |
| 924 const SkPaint* paint = &origPaint; | 949 const SkPaint* paint = &origPaint; |
| 925 SkPaint tempPaint; | 950 SkPaint tempPaint; |
| 926 if (origPaint.isAntiAlias() && !fRenderTarget->isUnifiedMultisampled()) { | 951 if (origPaint.isAntiAlias() && !fRenderTarget->isUnifiedMultisampled()) { |
| 927 // Drop antialiasing to avoid seams at tile boundaries. | 952 // Drop antialiasing to avoid seams at tile boundaries. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 } else { | 1125 } else { |
| 1101 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR
ect); | 1126 fDrawContext->fillRectToRect(fClip, grPaint, viewMatrix, dstRect, paintR
ect); |
| 1102 } | 1127 } |
| 1103 } | 1128 } |
| 1104 | 1129 |
| 1105 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, | 1130 bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, |
| 1106 int width, int height, | 1131 int width, int height, |
| 1107 const SkImageFilter* filter, | 1132 const SkImageFilter* filter, |
| 1108 const SkImageFilter::Context& ctx, | 1133 const SkImageFilter::Context& ctx, |
| 1109 SkBitmap* result, SkIPoint* offset) { | 1134 SkBitmap* result, SkIPoint* offset) { |
| 1135 ASSERT_SINGLE_OWNER |
| 1110 SkASSERT(filter); | 1136 SkASSERT(filter); |
| 1111 | 1137 |
| 1112 SkImageFilter::DeviceProxy proxy(this); | 1138 SkImageFilter::DeviceProxy proxy(this); |
| 1113 | 1139 |
| 1114 if (filter->canFilterImageGPU()) { | 1140 if (filter->canFilterImageGPU()) { |
| 1115 return filter->filterImageGPU(&proxy, wrap_texture(texture, width, heigh
t), | 1141 return filter->filterImageGPU(&proxy, wrap_texture(texture, width, heigh
t), |
| 1116 ctx, result, offset); | 1142 ctx, result, offset); |
| 1117 } else { | 1143 } else { |
| 1118 return false; | 1144 return false; |
| 1119 } | 1145 } |
| 1120 } | 1146 } |
| 1121 | 1147 |
| 1122 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, | 1148 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, |
| 1123 int left, int top, const SkPaint& paint) { | 1149 int left, int top, const SkPaint& paint) { |
| 1150 ASSERT_SINGLE_OWNER |
| 1124 // drawSprite is defined to be in device coords. | 1151 // drawSprite is defined to be in device coords. |
| 1125 CHECK_SHOULD_DRAW(draw); | 1152 CHECK_SHOULD_DRAW(draw); |
| 1126 | 1153 |
| 1127 SkAutoLockPixels alp(bitmap, !bitmap.getTexture()); | 1154 SkAutoLockPixels alp(bitmap, !bitmap.getTexture()); |
| 1128 if (!bitmap.getTexture() && !bitmap.readyToDraw()) { | 1155 if (!bitmap.getTexture() && !bitmap.readyToDraw()) { |
| 1129 return; | 1156 return; |
| 1130 } | 1157 } |
| 1131 | 1158 |
| 1132 int w = bitmap.width(); | 1159 int w = bitmap.width(); |
| 1133 int h = bitmap.height(); | 1160 int h = bitmap.height(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 SkIntToScalar(h)), | 1220 SkIntToScalar(h)), |
| 1194 SkRect::MakeXYWH(0, | 1221 SkRect::MakeXYWH(0, |
| 1195 0, | 1222 0, |
| 1196 SK_Scalar1 * w / texture->widt
h(), | 1223 SK_Scalar1 * w / texture->widt
h(), |
| 1197 SK_Scalar1 * h / texture->heig
ht())); | 1224 SK_Scalar1 * h / texture->heig
ht())); |
| 1198 } | 1225 } |
| 1199 | 1226 |
| 1200 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, | 1227 void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, |
| 1201 const SkRect* src, const SkRect& origDst, | 1228 const SkRect* src, const SkRect& origDst, |
| 1202 const SkPaint& paint, SkCanvas::SrcRectConstrai
nt constraint) { | 1229 const SkPaint& paint, SkCanvas::SrcRectConstrai
nt constraint) { |
| 1230 ASSERT_SINGLE_OWNER |
| 1203 if (bitmap.getTexture()) { | 1231 if (bitmap.getTexture()) { |
| 1204 CHECK_SHOULD_DRAW(draw); | 1232 CHECK_SHOULD_DRAW(draw); |
| 1205 GrBitmapTextureAdjuster adjuster(&bitmap); | 1233 GrBitmapTextureAdjuster adjuster(&bitmap); |
| 1206 this->drawTextureProducer(&adjuster, src, &origDst, constraint, *draw.fM
atrix, fClip, | 1234 this->drawTextureProducer(&adjuster, src, &origDst, constraint, *draw.fM
atrix, fClip, |
| 1207 paint); | 1235 paint); |
| 1208 return; | 1236 return; |
| 1209 } | 1237 } |
| 1210 // The src rect is inferred to be the bmp bounds if not provided. Otherwise,
the src rect must | 1238 // The src rect is inferred to be the bmp bounds if not provided. Otherwise,
the src rect must |
| 1211 // be clipped to the bmp bounds. To determine tiling parameters we need the
filter mode which | 1239 // be clipped to the bmp bounds. To determine tiling parameters we need the
filter mode which |
| 1212 // in turn requires knowing the src-to-dst mapping. If the src was clipped t
o the bmp bounds | 1240 // in turn requires knowing the src-to-dst mapping. If the src was clipped t
o the bmp bounds |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 constraint, tileSize, doBicubic); | 1307 constraint, tileSize, doBicubic); |
| 1280 return; | 1308 return; |
| 1281 } | 1309 } |
| 1282 } | 1310 } |
| 1283 GrBitmapTextureMaker maker(fContext, bitmap); | 1311 GrBitmapTextureMaker maker(fContext, bitmap); |
| 1284 this->drawTextureProducer(&maker, src, dst, constraint, *draw.fMatrix, fClip
, paint); | 1312 this->drawTextureProducer(&maker, src, dst, constraint, *draw.fMatrix, fClip
, paint); |
| 1285 } | 1313 } |
| 1286 | 1314 |
| 1287 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, | 1315 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, |
| 1288 int x, int y, const SkPaint& paint) { | 1316 int x, int y, const SkPaint& paint) { |
| 1317 ASSERT_SINGLE_OWNER |
| 1289 // clear of the source device must occur before CHECK_SHOULD_DRAW | 1318 // clear of the source device must occur before CHECK_SHOULD_DRAW |
| 1290 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext); | 1319 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawDevice", fContext); |
| 1291 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); | 1320 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); |
| 1292 | 1321 |
| 1293 // TODO: If the source device covers the whole of this device, we could | 1322 // TODO: If the source device covers the whole of this device, we could |
| 1294 // omit fNeedsClear -related flushing. | 1323 // omit fNeedsClear -related flushing. |
| 1295 // TODO: if source needs clear, we could maybe omit the draw fully. | 1324 // TODO: if source needs clear, we could maybe omit the draw fully. |
| 1296 | 1325 |
| 1297 // drawDevice is defined to be in device coords. | 1326 // drawDevice is defined to be in device coords. |
| 1298 CHECK_SHOULD_DRAW(draw); | 1327 CHECK_SHOULD_DRAW(draw); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 | 1386 |
| 1358 // The device being drawn may not fill up its texture (e.g. saveLayer uses a
pproximate | 1387 // The device being drawn may not fill up its texture (e.g. saveLayer uses a
pproximate |
| 1359 // scratch texture). | 1388 // scratch texture). |
| 1360 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), | 1389 SkRect srcRect = SkRect::MakeWH(SK_Scalar1 * w / devTex->width(), |
| 1361 SK_Scalar1 * h / devTex->height()); | 1390 SK_Scalar1 * h / devTex->height()); |
| 1362 | 1391 |
| 1363 fDrawContext->fillRectToRect(fClip, grPaint, SkMatrix::I(), dstRect, srcRect
); | 1392 fDrawContext->fillRectToRect(fClip, grPaint, SkMatrix::I(), dstRect, srcRect
); |
| 1364 } | 1393 } |
| 1365 | 1394 |
| 1366 bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { | 1395 bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { |
| 1396 ASSERT_SINGLE_OWNER |
| 1367 return filter->canFilterImageGPU(); | 1397 return filter->canFilterImageGPU(); |
| 1368 } | 1398 } |
| 1369 | 1399 |
| 1370 bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, | 1400 bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, |
| 1371 const SkImageFilter::Context& ctx, | 1401 const SkImageFilter::Context& ctx, |
| 1372 SkBitmap* result, SkIPoint* offset) { | 1402 SkBitmap* result, SkIPoint* offset) { |
| 1403 ASSERT_SINGLE_OWNER |
| 1373 // want explicitly our impl, so guard against a subclass of us overriding it | 1404 // want explicitly our impl, so guard against a subclass of us overriding it |
| 1374 if (!this->SkGpuDevice::canHandleImageFilter(filter)) { | 1405 if (!this->SkGpuDevice::canHandleImageFilter(filter)) { |
| 1375 return false; | 1406 return false; |
| 1376 } | 1407 } |
| 1377 | 1408 |
| 1378 SkAutoLockPixels alp(src, !src.getTexture()); | 1409 SkAutoLockPixels alp(src, !src.getTexture()); |
| 1379 if (!src.getTexture() && !src.readyToDraw()) { | 1410 if (!src.getTexture() && !src.readyToDraw()) { |
| 1380 return false; | 1411 return false; |
| 1381 } | 1412 } |
| 1382 | 1413 |
| 1383 GrTexture* texture; | 1414 GrTexture* texture; |
| 1384 // We assume here that the filter will not attempt to tile the src. Otherwis
e, this cache lookup | 1415 // We assume here that the filter will not attempt to tile the src. Otherwis
e, this cache lookup |
| 1385 // must be pushed upstack. | 1416 // must be pushed upstack. |
| 1386 AutoBitmapTexture abt(fContext, src, GrTextureParams::ClampNoFilter(), &text
ure); | 1417 AutoBitmapTexture abt(fContext, src, GrTextureParams::ClampNoFilter(), &text
ure); |
| 1387 if (!texture) { | 1418 if (!texture) { |
| 1388 return false; | 1419 return false; |
| 1389 } | 1420 } |
| 1390 | 1421 |
| 1391 return this->filterTexture(fContext, texture, src.width(), src.height(), | 1422 return this->filterTexture(fContext, texture, src.width(), src.height(), |
| 1392 filter, ctx, result, offset); | 1423 filter, ctx, result, offset); |
| 1393 } | 1424 } |
| 1394 | 1425 |
| 1395 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x
, SkScalar y, | 1426 void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x
, SkScalar y, |
| 1396 const SkPaint& paint) { | 1427 const SkPaint& paint) { |
| 1428 ASSERT_SINGLE_OWNER |
| 1397 SkMatrix viewMatrix = *draw.fMatrix; | 1429 SkMatrix viewMatrix = *draw.fMatrix; |
| 1398 viewMatrix.preTranslate(x, y); | 1430 viewMatrix.preTranslate(x, y); |
| 1399 if (as_IB(image)->peekTexture()) { | 1431 if (as_IB(image)->peekTexture()) { |
| 1400 CHECK_SHOULD_DRAW(draw); | 1432 CHECK_SHOULD_DRAW(draw); |
| 1401 GrImageTextureAdjuster adjuster(as_IB(image)); | 1433 GrImageTextureAdjuster adjuster(as_IB(image)); |
| 1402 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S
rcRectConstraint, | 1434 this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_S
rcRectConstraint, |
| 1403 viewMatrix, fClip, paint); | 1435 viewMatrix, fClip, paint); |
| 1404 return; | 1436 return; |
| 1405 } else { | 1437 } else { |
| 1406 SkBitmap bm; | 1438 SkBitmap bm; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1418 viewMatrix, fClip, paint); | 1450 viewMatrix, fClip, paint); |
| 1419 } else if (as_IB(image)->getROPixels(&bm)) { | 1451 } else if (as_IB(image)->getROPixels(&bm)) { |
| 1420 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); | 1452 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); |
| 1421 } | 1453 } |
| 1422 } | 1454 } |
| 1423 } | 1455 } |
| 1424 | 1456 |
| 1425 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
SkRect* src, | 1457 void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
SkRect* src, |
| 1426 const SkRect& dst, const SkPaint& paint, | 1458 const SkRect& dst, const SkPaint& paint, |
| 1427 SkCanvas::SrcRectConstraint constraint) { | 1459 SkCanvas::SrcRectConstraint constraint) { |
| 1460 ASSERT_SINGLE_OWNER |
| 1428 if (as_IB(image)->peekTexture()) { | 1461 if (as_IB(image)->peekTexture()) { |
| 1429 CHECK_SHOULD_DRAW(draw); | 1462 CHECK_SHOULD_DRAW(draw); |
| 1430 GrImageTextureAdjuster adjuster(as_IB(image)); | 1463 GrImageTextureAdjuster adjuster(as_IB(image)); |
| 1431 this->drawTextureProducer(&adjuster, src, &dst, constraint, *draw.fMatri
x, fClip, paint); | 1464 this->drawTextureProducer(&adjuster, src, &dst, constraint, *draw.fMatri
x, fClip, paint); |
| 1432 return; | 1465 return; |
| 1433 } | 1466 } |
| 1434 SkBitmap bm; | 1467 SkBitmap bm; |
| 1435 SkMatrix totalMatrix = *draw.fMatrix; | 1468 SkMatrix totalMatrix = *draw.fMatrix; |
| 1436 totalMatrix.preScale(dst.width() / (src ? src->width() : image->width()), | 1469 totalMatrix.preScale(dst.width() / (src ? src->width() : image->width()), |
| 1437 dst.height() / (src ? src->height() : image->height()))
; | 1470 dst.height() / (src ? src->height() : image->height()))
; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 producer->isAlphaOnly(), &grPaint)) { | 1518 producer->isAlphaOnly(), &grPaint)) { |
| 1486 return; | 1519 return; |
| 1487 } | 1520 } |
| 1488 | 1521 |
| 1489 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width()
, | 1522 fDrawContext->drawImageNine(fClip, grPaint, *draw.fMatrix, producer->width()
, |
| 1490 producer->height(), center, dst); | 1523 producer->height(), center, dst); |
| 1491 } | 1524 } |
| 1492 | 1525 |
| 1493 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, | 1526 void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, |
| 1494 const SkIRect& center, const SkRect& dst, const
SkPaint& paint) { | 1527 const SkIRect& center, const SkRect& dst, const
SkPaint& paint) { |
| 1528 ASSERT_SINGLE_OWNER |
| 1495 if (as_IB(image)->peekTexture()) { | 1529 if (as_IB(image)->peekTexture()) { |
| 1496 GrImageTextureAdjuster adjuster(as_IB(image)); | 1530 GrImageTextureAdjuster adjuster(as_IB(image)); |
| 1497 this->drawProducerNine(draw, &adjuster, center, dst, paint); | 1531 this->drawProducerNine(draw, &adjuster, center, dst, paint); |
| 1498 } else { | 1532 } else { |
| 1499 SkBitmap bm; | 1533 SkBitmap bm; |
| 1500 if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) { | 1534 if (SkImageCacherator* cacher = as_IB(image)->peekCacherator()) { |
| 1501 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C
achingHint); | 1535 GrImageTextureMaker maker(fContext, cacher, image, SkImage::kAllow_C
achingHint); |
| 1502 this->drawProducerNine(draw, &maker, center, dst, paint); | 1536 this->drawProducerNine(draw, &maker, center, dst, paint); |
| 1503 } else if (as_IB(image)->getROPixels(&bm)) { | 1537 } else if (as_IB(image)->getROPixels(&bm)) { |
| 1504 this->drawBitmapNine(draw, bm, center, dst, paint); | 1538 this->drawBitmapNine(draw, bm, center, dst, paint); |
| 1505 } | 1539 } |
| 1506 } | 1540 } |
| 1507 } | 1541 } |
| 1508 | 1542 |
| 1509 void SkGpuDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, con
st SkIRect& center, | 1543 void SkGpuDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, con
st SkIRect& center, |
| 1510 const SkRect& dst, const SkPaint& paint) { | 1544 const SkRect& dst, const SkPaint& paint) { |
| 1545 ASSERT_SINGLE_OWNER |
| 1511 if (bitmap.getTexture()) { | 1546 if (bitmap.getTexture()) { |
| 1512 GrBitmapTextureAdjuster adjuster(&bitmap); | 1547 GrBitmapTextureAdjuster adjuster(&bitmap); |
| 1513 this->drawProducerNine(draw, &adjuster, center, dst, paint); | 1548 this->drawProducerNine(draw, &adjuster, center, dst, paint); |
| 1514 } else { | 1549 } else { |
| 1515 GrBitmapTextureMaker maker(fContext, bitmap); | 1550 GrBitmapTextureMaker maker(fContext, bitmap); |
| 1516 this->drawProducerNine(draw, &maker, center, dst, paint); | 1551 this->drawProducerNine(draw, &maker, center, dst, paint); |
| 1517 } | 1552 } |
| 1518 } | 1553 } |
| 1519 | 1554 |
| 1520 /////////////////////////////////////////////////////////////////////////////// | 1555 /////////////////////////////////////////////////////////////////////////////// |
| 1521 | 1556 |
| 1522 // must be in SkCanvas::VertexMode order | 1557 // must be in SkCanvas::VertexMode order |
| 1523 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { | 1558 static const GrPrimitiveType gVertexMode2PrimitiveType[] = { |
| 1524 kTriangles_GrPrimitiveType, | 1559 kTriangles_GrPrimitiveType, |
| 1525 kTriangleStrip_GrPrimitiveType, | 1560 kTriangleStrip_GrPrimitiveType, |
| 1526 kTriangleFan_GrPrimitiveType, | 1561 kTriangleFan_GrPrimitiveType, |
| 1527 }; | 1562 }; |
| 1528 | 1563 |
| 1529 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, | 1564 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, |
| 1530 int vertexCount, const SkPoint vertices[], | 1565 int vertexCount, const SkPoint vertices[], |
| 1531 const SkPoint texs[], const SkColor colors[], | 1566 const SkPoint texs[], const SkColor colors[], |
| 1532 SkXfermode* xmode, | 1567 SkXfermode* xmode, |
| 1533 const uint16_t indices[], int indexCount, | 1568 const uint16_t indices[], int indexCount, |
| 1534 const SkPaint& paint) { | 1569 const SkPaint& paint) { |
| 1570 ASSERT_SINGLE_OWNER |
| 1535 CHECK_SHOULD_DRAW(draw); | 1571 CHECK_SHOULD_DRAW(draw); |
| 1536 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawVertices", fContext); | 1572 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawVertices", fContext); |
| 1537 | 1573 |
| 1538 // If both textures and vertex-colors are nullptr, strokes hairlines with th
e paint's color. | 1574 // If both textures and vertex-colors are nullptr, strokes hairlines with th
e paint's color. |
| 1539 if ((nullptr == texs || nullptr == paint.getShader()) && nullptr == colors)
{ | 1575 if ((nullptr == texs || nullptr == paint.getShader()) && nullptr == colors)
{ |
| 1540 | 1576 |
| 1541 texs = nullptr; | 1577 texs = nullptr; |
| 1542 | 1578 |
| 1543 SkPaint copy(paint); | 1579 SkPaint copy(paint); |
| 1544 copy.setStyle(SkPaint::kStroke_Style); | 1580 copy.setStyle(SkPaint::kStroke_Style); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 colors, | 1688 colors, |
| 1653 indices, | 1689 indices, |
| 1654 indexCount); | 1690 indexCount); |
| 1655 } | 1691 } |
| 1656 | 1692 |
| 1657 /////////////////////////////////////////////////////////////////////////////// | 1693 /////////////////////////////////////////////////////////////////////////////// |
| 1658 | 1694 |
| 1659 void SkGpuDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRS
Xform xform[], | 1695 void SkGpuDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRS
Xform xform[], |
| 1660 const SkRect texRect[], const SkColor colors[], int
count, | 1696 const SkRect texRect[], const SkColor colors[], int
count, |
| 1661 SkXfermode::Mode mode, const SkPaint& paint) { | 1697 SkXfermode::Mode mode, const SkPaint& paint) { |
| 1698 ASSERT_SINGLE_OWNER |
| 1662 if (paint.isAntiAlias()) { | 1699 if (paint.isAntiAlias()) { |
| 1663 this->INHERITED::drawAtlas(draw, atlas, xform, texRect, colors, count, m
ode, paint); | 1700 this->INHERITED::drawAtlas(draw, atlas, xform, texRect, colors, count, m
ode, paint); |
| 1664 return; | 1701 return; |
| 1665 } | 1702 } |
| 1666 | 1703 |
| 1667 CHECK_SHOULD_DRAW(draw); | 1704 CHECK_SHOULD_DRAW(draw); |
| 1668 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); | 1705 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); |
| 1669 | 1706 |
| 1670 SkPaint p(paint); | 1707 SkPaint p(paint); |
| 1671 p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_Til
eMode))->unref(); | 1708 p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_Til
eMode))->unref(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1684 | 1721 |
| 1685 SkDEBUGCODE(this->validate();) | 1722 SkDEBUGCODE(this->validate();) |
| 1686 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect
, colors); | 1723 fDrawContext->drawAtlas(fClip, grPaint, *draw.fMatrix, count, xform, texRect
, colors); |
| 1687 } | 1724 } |
| 1688 | 1725 |
| 1689 /////////////////////////////////////////////////////////////////////////////// | 1726 /////////////////////////////////////////////////////////////////////////////// |
| 1690 | 1727 |
| 1691 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, | 1728 void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
| 1692 size_t byteLength, SkScalar x, SkScalar y, | 1729 size_t byteLength, SkScalar x, SkScalar y, |
| 1693 const SkPaint& paint) { | 1730 const SkPaint& paint) { |
| 1731 ASSERT_SINGLE_OWNER |
| 1694 CHECK_SHOULD_DRAW(draw); | 1732 CHECK_SHOULD_DRAW(draw); |
| 1695 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); | 1733 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawText", fContext); |
| 1696 | 1734 |
| 1697 GrPaint grPaint; | 1735 GrPaint grPaint; |
| 1698 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 1736 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |
| 1699 return; | 1737 return; |
| 1700 } | 1738 } |
| 1701 | 1739 |
| 1702 SkDEBUGCODE(this->validate();) | 1740 SkDEBUGCODE(this->validate();) |
| 1703 | 1741 |
| 1704 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix, | 1742 fDrawContext->drawText(fClip, grPaint, paint, *draw.fMatrix, |
| 1705 (const char *)text, byteLength, x, y, draw.fClip->get
Bounds()); | 1743 (const char *)text, byteLength, x, y, draw.fClip->get
Bounds()); |
| 1706 } | 1744 } |
| 1707 | 1745 |
| 1708 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, | 1746 void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
ength, |
| 1709 const SkScalar pos[], int scalarsPerPos, | 1747 const SkScalar pos[], int scalarsPerPos, |
| 1710 const SkPoint& offset, const SkPaint& paint) { | 1748 const SkPoint& offset, const SkPaint& paint) { |
| 1749 ASSERT_SINGLE_OWNER |
| 1711 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPosText", fContext); | 1750 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPosText", fContext); |
| 1712 CHECK_SHOULD_DRAW(draw); | 1751 CHECK_SHOULD_DRAW(draw); |
| 1713 | 1752 |
| 1714 GrPaint grPaint; | 1753 GrPaint grPaint; |
| 1715 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 1754 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |
| 1716 return; | 1755 return; |
| 1717 } | 1756 } |
| 1718 | 1757 |
| 1719 SkDEBUGCODE(this->validate();) | 1758 SkDEBUGCODE(this->validate();) |
| 1720 | 1759 |
| 1721 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix, | 1760 fDrawContext->drawPosText(fClip, grPaint, paint, *draw.fMatrix, |
| 1722 (const char *)text, byteLength, pos, scalarsPerPos
, offset, | 1761 (const char *)text, byteLength, pos, scalarsPerPos
, offset, |
| 1723 draw.fClip->getBounds()); | 1762 draw.fClip->getBounds()); |
| 1724 } | 1763 } |
| 1725 | 1764 |
| 1726 void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca
lar x, SkScalar y, | 1765 void SkGpuDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSca
lar x, SkScalar y, |
| 1727 const SkPaint& paint, SkDrawFilter* drawFilter) { | 1766 const SkPaint& paint, SkDrawFilter* drawFilter) { |
| 1767 ASSERT_SINGLE_OWNER |
| 1728 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawTextBlob", fContext); | 1768 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawTextBlob", fContext); |
| 1729 CHECK_SHOULD_DRAW(draw); | 1769 CHECK_SHOULD_DRAW(draw); |
| 1730 | 1770 |
| 1731 SkDEBUGCODE(this->validate();) | 1771 SkDEBUGCODE(this->validate();) |
| 1732 | 1772 |
| 1733 fDrawContext->drawTextBlob(fClip, paint, *draw.fMatrix, | 1773 fDrawContext->drawTextBlob(fClip, paint, *draw.fMatrix, |
| 1734 blob, x, y, drawFilter, draw.fClip->getBounds()); | 1774 blob, x, y, drawFilter, draw.fClip->getBounds()); |
| 1735 } | 1775 } |
| 1736 | 1776 |
| 1737 /////////////////////////////////////////////////////////////////////////////// | 1777 /////////////////////////////////////////////////////////////////////////////// |
| 1738 | 1778 |
| 1739 bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { | 1779 bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { |
| 1740 return GrTextContext::ShouldDisableLCD(paint); | 1780 return GrTextContext::ShouldDisableLCD(paint); |
| 1741 } | 1781 } |
| 1742 | 1782 |
| 1743 void SkGpuDevice::flush() { | 1783 void SkGpuDevice::flush() { |
| 1784 ASSERT_SINGLE_OWNER |
| 1744 DO_DEFERRED_CLEAR(); | 1785 DO_DEFERRED_CLEAR(); |
| 1745 fRenderTarget->prepareForExternalIO(); | 1786 fRenderTarget->prepareForExternalIO(); |
| 1746 | 1787 |
| 1747 // Clear batch debugging output | 1788 // Clear batch debugging output |
| 1748 if (GR_BATCH_DEBUGGING_OUTPUT) { | 1789 if (GR_BATCH_DEBUGGING_OUTPUT) { |
| 1749 SkDebugf("%s\n", fContext->getAuditTrail()->toJson().c_str()); | 1790 SkDebugf("%s\n", fContext->getAuditTrail()->toJson().c_str()); |
| 1750 GR_AUDIT_TRAIL_RESET(fContext->getAuditTrail()); | 1791 GR_AUDIT_TRAIL_RESET(fContext->getAuditTrail()); |
| 1751 } | 1792 } |
| 1752 } | 1793 } |
| 1753 | 1794 |
| 1754 /////////////////////////////////////////////////////////////////////////////// | 1795 /////////////////////////////////////////////////////////////////////////////// |
| 1755 | 1796 |
| 1756 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
*) { | 1797 SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
*) { |
| 1798 ASSERT_SINGLE_OWNER |
| 1757 GrSurfaceDesc desc; | 1799 GrSurfaceDesc desc; |
| 1758 desc.fConfig = fRenderTarget->config(); | 1800 desc.fConfig = fRenderTarget->config(); |
| 1759 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 1801 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 1760 desc.fWidth = cinfo.fInfo.width(); | 1802 desc.fWidth = cinfo.fInfo.width(); |
| 1761 desc.fHeight = cinfo.fInfo.height(); | 1803 desc.fHeight = cinfo.fInfo.height(); |
| 1762 desc.fSampleCnt = fRenderTarget->desc().fSampleCnt; | 1804 desc.fSampleCnt = fRenderTarget->desc().fSampleCnt; |
| 1763 | 1805 |
| 1764 SkAutoTUnref<GrTexture> texture; | 1806 SkAutoTUnref<GrTexture> texture; |
| 1765 // Skia's convention is to only clear a device if it is non-opaque. | 1807 // Skia's convention is to only clear a device if it is non-opaque. |
| 1766 InitContents init = cinfo.fInfo.isOpaque() ? kUninit_InitContents : kClear_I
nitContents; | 1808 InitContents init = cinfo.fInfo.isOpaque() ? kUninit_InitContents : kClear_I
nitContents; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1779 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height()
, &props, init); | 1821 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height()
, &props, init); |
| 1780 } else { | 1822 } else { |
| 1781 SkErrorInternals::SetError( kInternalError_SkError, | 1823 SkErrorInternals::SetError( kInternalError_SkError, |
| 1782 "---- failed to create gpu device texture [%
d %d]\n", | 1824 "---- failed to create gpu device texture [%
d %d]\n", |
| 1783 cinfo.fInfo.width(), cinfo.fInfo.height()); | 1825 cinfo.fInfo.width(), cinfo.fInfo.height()); |
| 1784 return nullptr; | 1826 return nullptr; |
| 1785 } | 1827 } |
| 1786 } | 1828 } |
| 1787 | 1829 |
| 1788 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps
& props) { | 1830 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps
& props) { |
| 1831 ASSERT_SINGLE_OWNER |
| 1789 // TODO: Change the signature of newSurface to take a budgeted parameter. | 1832 // TODO: Change the signature of newSurface to take a budgeted parameter. |
| 1790 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; | 1833 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; |
| 1791 return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget->
desc().fSampleCnt, | 1834 return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget->
desc().fSampleCnt, |
| 1792 &props); | 1835 &props); |
| 1793 } | 1836 } |
| 1794 | 1837 |
| 1795 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
* mainPicture, | 1838 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
* mainPicture, |
| 1796 const SkMatrix* matrix, const SkPaint
* paint) { | 1839 const SkMatrix* matrix, const SkPaint
* paint) { |
| 1840 ASSERT_SINGLE_OWNER |
| 1797 #ifndef SK_IGNORE_GPU_LAYER_HOISTING | 1841 #ifndef SK_IGNORE_GPU_LAYER_HOISTING |
| 1798 // todo: should handle this natively | 1842 // todo: should handle this natively |
| 1799 if (paint) { | 1843 if (paint) { |
| 1800 return false; | 1844 return false; |
| 1801 } | 1845 } |
| 1802 | 1846 |
| 1803 const SkBigPicture::AccelData* data = nullptr; | 1847 const SkBigPicture::AccelData* data = nullptr; |
| 1804 if (const SkBigPicture* bp = mainPicture->asSkBigPicture()) { | 1848 if (const SkBigPicture* bp = mainPicture->asSkBigPicture()) { |
| 1805 data = bp->accelData(); | 1849 data = bp->accelData(); |
| 1806 } | 1850 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 #else | 1904 #else |
| 1861 return false; | 1905 return false; |
| 1862 #endif | 1906 #endif |
| 1863 } | 1907 } |
| 1864 | 1908 |
| 1865 SkImageFilter::Cache* SkGpuDevice::NewImageFilterCache() { | 1909 SkImageFilter::Cache* SkGpuDevice::NewImageFilterCache() { |
| 1866 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1910 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
| 1867 } | 1911 } |
| 1868 | 1912 |
| 1869 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1913 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
| 1914 ASSERT_SINGLE_OWNER |
| 1870 // We always return a transient cache, so it is freed after each | 1915 // We always return a transient cache, so it is freed after each |
| 1871 // filter traversal. | 1916 // filter traversal. |
| 1872 return SkGpuDevice::NewImageFilterCache(); | 1917 return SkGpuDevice::NewImageFilterCache(); |
| 1873 } | 1918 } |
| 1874 | 1919 |
| 1875 #endif | 1920 #endif |
| OLD | NEW |