| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   462                                SkToS32(count), |   462                                SkToS32(count), | 
|   463                                (SkPoint*)pts, |   463                                (SkPoint*)pts, | 
|   464                                nullptr, |   464                                nullptr, | 
|   465                                nullptr, |   465                                nullptr, | 
|   466                                nullptr, |   466                                nullptr, | 
|   467                                0); |   467                                0); | 
|   468 } |   468 } | 
|   469  |   469  | 
|   470 /////////////////////////////////////////////////////////////////////////////// |   470 /////////////////////////////////////////////////////////////////////////////// | 
|   471  |   471  | 
|   472 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, |   472 void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint
      & paint) { | 
|   473                            const SkPaint& paint) { |  | 
|   474     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRect", fContext); |   473     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRect", fContext); | 
|   475  |   474  | 
|   476     CHECK_FOR_ANNOTATION(paint); |   475     CHECK_FOR_ANNOTATION(paint); | 
|   477     CHECK_SHOULD_DRAW(draw); |   476     CHECK_SHOULD_DRAW(draw); | 
|   478  |   477  | 
|   479     bool doStroke = paint.getStyle() != SkPaint::kFill_Style; |   478     bool doStroke = paint.getStyle() != SkPaint::kFill_Style; | 
|   480     SkScalar width = paint.getStrokeWidth(); |   479     SkScalar width = paint.getStrokeWidth(); | 
|   481  |   480  | 
|   482     /* |   481     /* | 
|   483         We have special code for hairline strokes, miter-strokes, bevel-stroke |   482         We have special code for hairline strokes, miter-strokes, bevel-stroke | 
|   484         and fills. Anything else we just call our path code. |   483         and fills. Anything else we just call our path code. | 
|   485      */ |   484      */ | 
|   486     bool usePath = doStroke && width > 0 && |   485     bool usePath = doStroke && width > 0 && | 
|   487                    (paint.getStrokeJoin() == SkPaint::kRound_Join || |   486                    (paint.getStrokeJoin() == SkPaint::kRound_Join || | 
|   488                     (paint.getStrokeJoin() == SkPaint::kBevel_Join && rect.isEmp
      ty())); |   487                     (paint.getStrokeJoin() == SkPaint::kBevel_Join && rect.isEmp
      ty())); | 
|   489  |   488  | 
|   490     // a few other reasons we might need to call drawPath... |   489     // a few other reasons we might need to call drawPath... | 
|   491     if (paint.getMaskFilter() || |   490     if (paint.getMaskFilter() || paint.getPathEffect() || | 
|   492         paint.getStyle() == SkPaint::kStrokeAndFill_Style) { // we can't both st
      roke and fill rects |   491         paint.getStyle() == SkPaint::kStrokeAndFill_Style) { // we can't both st
      roke and fill rects | 
|   493         usePath = true; |   492         usePath = true; | 
|   494     } |   493     } | 
|   495  |   494  | 
|   496     if (!usePath && paint.isAntiAlias() && !draw.fMatrix->rectStaysRect()) { |   495     if (!usePath && paint.isAntiAlias() && !draw.fMatrix->rectStaysRect()) { | 
|   497         usePath = true; |   496         usePath = true; | 
|   498     } |   497     } | 
|   499  |   498  | 
|   500     GrStrokeInfo strokeInfo(paint); |  | 
|   501  |  | 
|   502     const SkPathEffect* pe = paint.getPathEffect(); |  | 
|   503     if (!usePath && pe && !strokeInfo.isDashed()) { |  | 
|   504         usePath = true; |  | 
|   505     } |  | 
|   506  |  | 
|   507     if (usePath) { |   499     if (usePath) { | 
|   508         SkPath path; |   500         SkPath path; | 
|   509         path.setIsVolatile(true); |   501         path.setIsVolatile(true); | 
|   510         path.addRect(rect); |   502         path.addRect(rect); | 
|   511         this->drawPath(draw, path, paint, nullptr, true); |   503         GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarge
      t, | 
 |   504                                             fClip, path, paint, | 
 |   505                                             *draw.fMatrix, nullptr, | 
 |   506                                             draw.fClip->getBounds(), true); | 
|   512         return; |   507         return; | 
|   513     } |   508     } | 
|   514  |   509  | 
|   515     GrPaint grPaint; |   510     GrPaint grPaint; | 
|   516     if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { |   511     if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) { | 
|   517         return; |   512         return; | 
|   518     } |   513     } | 
|   519  |   514  | 
 |   515     GrStrokeInfo strokeInfo(paint); | 
 |   516  | 
|   520     fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); |   517     fDrawContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &strokeInfo); | 
|   521 } |   518 } | 
|   522  |   519  | 
|   523 /////////////////////////////////////////////////////////////////////////////// |   520 /////////////////////////////////////////////////////////////////////////////// | 
|   524  |   521  | 
|   525 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, |   522 void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, | 
|   526                             const SkPaint& paint) { |   523                             const SkPaint& paint) { | 
|   527     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext); |   524     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext); | 
|   528     CHECK_FOR_ANNOTATION(paint); |   525     CHECK_FOR_ANNOTATION(paint); | 
|   529     CHECK_SHOULD_DRAW(draw); |   526     CHECK_SHOULD_DRAW(draw); | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
|   557                                                                         fClip, |   554                                                                         fClip, | 
|   558                                                                         *draw.fM
      atrix, |   555                                                                         *draw.fM
      atrix, | 
|   559                                                                         strokeIn
      fo, |   556                                                                         strokeIn
      fo, | 
|   560                                                                         devRRect
      )) { |   557                                                                         devRRect
      )) { | 
|   561                         return; |   558                         return; | 
|   562                     } |   559                     } | 
|   563                 } |   560                 } | 
|   564  |   561  | 
|   565             } |   562             } | 
|   566         } |   563         } | 
|   567  |  | 
|   568     } |   564     } | 
|   569  |   565  | 
|   570     if (paint.getMaskFilter() || paint.getPathEffect()) { |   566     if (paint.getMaskFilter() || paint.getPathEffect()) { | 
 |   567         // The only mask filter the native rrect drawing code could've handle wa
      s taken | 
 |   568         // care of above. | 
 |   569         // A path effect will presumably transform this rrect into something els
      e. | 
|   571         SkPath path; |   570         SkPath path; | 
|   572         path.setIsVolatile(true); |   571         path.setIsVolatile(true); | 
|   573         path.addRRect(rect); |   572         path.addRRect(rect); | 
|   574         this->drawPath(draw, path, paint, nullptr, true); |   573         GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarge
      t, | 
 |   574                                             fClip, path, paint, | 
 |   575                                             *draw.fMatrix, nullptr, | 
 |   576                                             draw.fClip->getBounds(), true); | 
|   575         return; |   577         return; | 
|   576     } |   578     } | 
|   577  |   579  | 
|   578     SkASSERT(!strokeInfo.isDashed()); |   580     SkASSERT(!strokeInfo.isDashed()); | 
|   579  |   581  | 
|   580     fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); |   582     fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, strokeInfo); | 
|   581 } |   583 } | 
|   582  |   584  | 
|   583 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, |   585 void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, | 
|   584                              const SkRRect& inner, const SkPaint& paint) { |   586                              const SkRRect& inner, const SkPaint& paint) { | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   649 static SkBitmap wrap_texture(GrTexture* texture, int width, int height) { |   651 static SkBitmap wrap_texture(GrTexture* texture, int width, int height) { | 
|   650     SkBitmap result; |   652     SkBitmap result; | 
|   651     result.setInfo(SkImageInfo::MakeN32Premul(width, height)); |   653     result.setInfo(SkImageInfo::MakeN32Premul(width, height)); | 
|   652     result.setPixelRef(new SkGrPixelRef(result.info(), texture))->unref(); |   654     result.setPixelRef(new SkGrPixelRef(result.info(), texture))->unref(); | 
|   653     return result; |   655     return result; | 
|   654 } |   656 } | 
|   655  |   657  | 
|   656 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |   658 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, | 
|   657                            const SkPaint& paint, const SkMatrix* prePathMatrix, |   659                            const SkPaint& paint, const SkMatrix* prePathMatrix, | 
|   658                            bool pathIsMutable) { |   660                            bool pathIsMutable) { | 
 |   661     if (!origSrcPath.isInverseFillType() && !paint.getPathEffect() && !prePathMa
      trix) { | 
 |   662         bool isClosed; | 
 |   663         SkRect rect; | 
 |   664         if (origSrcPath.isRect(&rect, &isClosed) && isClosed) { | 
 |   665             this->drawRect(draw, rect, paint); | 
 |   666             return; | 
 |   667         } | 
 |   668         if (origSrcPath.isOval(&rect)) { | 
 |   669             this->drawOval(draw, rect, paint); | 
 |   670             return; | 
 |   671         } | 
 |   672         SkRRect rrect; | 
 |   673         if (origSrcPath.isRRect(&rrect)) { | 
 |   674             this->drawRRect(draw, rrect, paint); | 
 |   675             return; | 
 |   676         } | 
 |   677     } | 
 |   678  | 
|   659     CHECK_FOR_ANNOTATION(paint); |   679     CHECK_FOR_ANNOTATION(paint); | 
|   660     CHECK_SHOULD_DRAW(draw); |   680     CHECK_SHOULD_DRAW(draw); | 
|   661     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext); |   681     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext); | 
|   662  |   682  | 
|   663     GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarget, |   683     GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarget, | 
|   664                                         fClip, origSrcPath, paint, |   684                                         fClip, origSrcPath, paint, | 
|   665                                         *draw.fMatrix, prePathMatrix, |   685                                         *draw.fMatrix, prePathMatrix, | 
|   666                                         draw.fClip->getBounds(), pathIsMutable); |   686                                         draw.fClip->getBounds(), pathIsMutable); | 
|   667 } |   687 } | 
|   668  |   688  | 
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1862     return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |  1882     return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 
|  1863 } |  1883 } | 
|  1864  |  1884  | 
|  1865 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |  1885 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 
|  1866     // We always return a transient cache, so it is freed after each |  1886     // We always return a transient cache, so it is freed after each | 
|  1867     // filter traversal. |  1887     // filter traversal. | 
|  1868     return SkGpuDevice::NewImageFilterCache(); |  1888     return SkGpuDevice::NewImageFilterCache(); | 
|  1869 } |  1889 } | 
|  1870  |  1890  | 
|  1871 #endif |  1891 #endif | 
| OLD | NEW |