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

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

Issue 2267273006: GPU implementation of drawRegion() (Closed) Base URL: https://skia.googlesource.com/skia.git@drawregion
Patch Set: Keep fixing stuff Created 4 years, 3 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
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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 519
520 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext.get(), 520 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext.get(),
521 fClip, path, paint, 521 fClip, path, paint,
522 *draw.fMatrix, nullptr, 522 *draw.fMatrix, nullptr,
523 draw.fRC->getBounds(), true); 523 draw.fRC->getBounds(), true);
524 } 524 }
525 525
526 526
527 ///////////////////////////////////////////////////////////////////////////// 527 /////////////////////////////////////////////////////////////////////////////
528 528
529 static inline bool is_int(float x) {
530 return x == (float) sk_float_round2int(x);
531 }
532
533 void SkGpuDevice::drawRegion(const SkDraw& draw, const SkRegion& region, const S kPaint& paint) {
534 bool isNonTranslate = draw.fMatrix->getType() & ~(SkMatrix::kTranslate_Mask) ;
bsalomon 2016/08/25 17:49:02 I think we should handle all the matrix, aa, and s
msarett 2016/08/25 20:51:42 SGTM, done.
535 bool complexPaint = paint.getStyle() != SkPaint::kFill_Style || paint.getMas kFilter() ||
536 paint.getPathEffect();
537 bool antiAlias = paint.isAntiAlias() && (!is_int(draw.fMatrix->getTranslateX ()) ||
538 !is_int(draw.fMatrix->getTranslateY ()));
539 if (isNonTranslate || complexPaint || antiAlias) {
540 SkPath path;
541 region.getBoundaryPath(&path);
542 return this->drawPath(draw, path, paint, nullptr, false);
543 }
544
545 GrPaint grPaint;
546 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.fMat rix, &grPaint)) {
547 return;
548 }
549
550 fDrawContext->drawRegion(fClip, grPaint, *draw.fMatrix, region);
551 }
552
529 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint & paint) { 553 void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint & paint) {
530 ASSERT_SINGLE_OWNER 554 ASSERT_SINGLE_OWNER
531 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawOval", fContext); 555 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawOval", fContext);
532 CHECK_SHOULD_DRAW(draw); 556 CHECK_SHOULD_DRAW(draw);
533 557
534 // Presumably the path effect warps this to something other than an oval 558 // Presumably the path effect warps this to something other than an oval
535 if (paint.getPathEffect()) { 559 if (paint.getPathEffect()) {
536 SkPath path; 560 SkPath path;
537 path.setIsVolatile(true); 561 path.setIsVolatile(true);
538 path.addOval(oval); 562 path.addOval(oval);
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 } 1831 }
1808 1832
1809 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { 1833 SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
1810 ASSERT_SINGLE_OWNER 1834 ASSERT_SINGLE_OWNER
1811 // We always return a transient cache, so it is freed after each 1835 // We always return a transient cache, so it is freed after each
1812 // filter traversal. 1836 // filter traversal.
1813 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); 1837 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize);
1814 } 1838 }
1815 1839
1816 #endif 1840 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698