| OLD | NEW | 
|     1 /* |     1 /* | 
|     2  * Copyright 2015 Google Inc. |     2  * Copyright 2015 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 "GrBatchTest.h" |     8 #include "GrBatchTest.h" | 
|     9 #include "GrColor.h" |     9 #include "GrColor.h" | 
|    10 #include "GrDrawContext.h" |    10 #include "GrDrawContext.h" | 
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   294     AutoCheckFlush acf(fDrawingManager); |   294     AutoCheckFlush acf(fDrawingManager); | 
|   295  |   295  | 
|   296     const SkStrokeRec& stroke = style->strokeRec(); |   296     const SkStrokeRec& stroke = style->strokeRec(); | 
|   297     SkScalar width = stroke.getWidth(); |   297     SkScalar width = stroke.getWidth(); | 
|   298  |   298  | 
|   299     // Check if this is a full RT draw and can be replaced with a clear. We don'
      t bother checking |   299     // Check if this is a full RT draw and can be replaced with a clear. We don'
      t bother checking | 
|   300     // cases where the RT is fully inside a stroke. |   300     // cases where the RT is fully inside a stroke. | 
|   301     if (width < 0) { |   301     if (width < 0) { | 
|   302         SkRect rtRect; |   302         SkRect rtRect; | 
|   303         fRenderTarget->getBoundsRect(&rtRect); |   303         fRenderTarget->getBoundsRect(&rtRect); | 
|   304         SkRect clipSpaceRTRect = rtRect; |  | 
|   305         bool checkClip = GrClip::kWideOpen_ClipType != clip.clipType(); |  | 
|   306         if (checkClip) { |  | 
|   307             clipSpaceRTRect.offset(SkIntToScalar(clip.origin().fX), |  | 
|   308                                    SkIntToScalar(clip.origin().fY)); |  | 
|   309         } |  | 
|   310         // Does the clip contain the entire RT? |   304         // Does the clip contain the entire RT? | 
|   311         if (!checkClip || clip.quickContains(clipSpaceRTRect)) { |   305         if (clip.quickContains(rtRect)) { | 
|   312             SkMatrix invM; |   306             SkMatrix invM; | 
|   313             if (!viewMatrix.invert(&invM)) { |   307             if (!viewMatrix.invert(&invM)) { | 
|   314                 return; |   308                 return; | 
|   315             } |   309             } | 
|   316             // Does the rect bound the RT? |   310             // Does the rect bound the RT? | 
|   317             SkPoint srcSpaceRTQuad[4]; |   311             SkPoint srcSpaceRTQuad[4]; | 
|   318             invM.mapRectToQuad(srcSpaceRTQuad, rtRect); |   312             invM.mapRectToQuad(srcSpaceRTQuad, rtRect); | 
|   319             if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && |   313             if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && | 
|   320                 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && |   314                 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && | 
|   321                 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && |   315                 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   367         this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |   361         this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); | 
|   368         return; |   362         return; | 
|   369     } |   363     } | 
|   370  |   364  | 
|   371     SkPath path; |   365     SkPath path; | 
|   372     path.setIsVolatile(true); |   366     path.setIsVolatile(true); | 
|   373     path.addRect(rect); |   367     path.addRect(rect); | 
|   374     this->internalDrawPath(clip, paint, viewMatrix, path, *style); |   368     this->internalDrawPath(clip, paint, viewMatrix, path, *style); | 
|   375 } |   369 } | 
|   376  |   370  | 
|   377 bool GrDrawContextPriv::drawAndStencilRect(const GrClip& clip, |   371 bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, | 
|   378                                            const GrUserStencilSettings* ss, |   372                                            const GrUserStencilSettings* ss, | 
|   379                                            SkRegion::Op op, |   373                                            SkRegion::Op op, | 
|   380                                            bool invert, |   374                                            bool invert, | 
|   381                                            bool doAA, |   375                                            bool doAA, | 
|   382                                            const SkMatrix& viewMatrix, |   376                                            const SkMatrix& viewMatrix, | 
|   383                                            const SkRect& rect) { |   377                                            const SkRect& rect) { | 
|   384     ASSERT_SINGLE_OWNER_PRIV |   378     ASSERT_SINGLE_OWNER_PRIV | 
|   385     RETURN_FALSE_IF_ABANDONED_PRIV |   379     RETURN_FALSE_IF_ABANDONED_PRIV | 
|   386     SkDEBUGCODE(fDrawContext->validate();) |   380     SkDEBUGCODE(fDrawContext->validate();) | 
|   387     GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
      Rect"); |   381     GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
      Rect"); | 
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   832     } |   826     } | 
|   833  |   827  | 
|   834     // Note that internalDrawPath may sw-rasterize the path into a scratch textu
      re. |   828     // Note that internalDrawPath may sw-rasterize the path into a scratch textu
      re. | 
|   835     // Scratch textures can be recycled after they are returned to the texture |   829     // Scratch textures can be recycled after they are returned to the texture | 
|   836     // cache. This presents a potential hazard for buffered drawing. However, |   830     // cache. This presents a potential hazard for buffered drawing. However, | 
|   837     // the writePixels that uploads to the scratch will perform a flush so we're |   831     // the writePixels that uploads to the scratch will perform a flush so we're | 
|   838     // OK. |   832     // OK. | 
|   839     this->internalDrawPath(clip, paint, viewMatrix, path, style); |   833     this->internalDrawPath(clip, paint, viewMatrix, path, style); | 
|   840 } |   834 } | 
|   841  |   835  | 
|   842 bool GrDrawContextPriv::drawAndStencilPath(const GrClip& clip, |   836 bool GrDrawContextPriv::drawAndStencilPath(const GrFixedClip& clip, | 
|   843                                            const GrUserStencilSettings* ss, |   837                                            const GrUserStencilSettings* ss, | 
|   844                                            SkRegion::Op op, |   838                                            SkRegion::Op op, | 
|   845                                            bool invert, |   839                                            bool invert, | 
|   846                                            bool doAA, |   840                                            bool doAA, | 
|   847                                            const SkMatrix& viewMatrix, |   841                                            const SkMatrix& viewMatrix, | 
|   848                                            const SkPath& path) { |   842                                            const SkPath& path) { | 
|   849     ASSERT_SINGLE_OWNER_PRIV |   843     ASSERT_SINGLE_OWNER_PRIV | 
|   850     RETURN_FALSE_IF_ABANDONED_PRIV |   844     RETURN_FALSE_IF_ABANDONED_PRIV | 
|   851     SkDEBUGCODE(fDrawContext->validate();) |   845     SkDEBUGCODE(fDrawContext->validate();) | 
|   852     GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat
      h"); |   846     GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat
      h"); | 
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1014  |  1008  | 
|  1015 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, const GrClip& 
      clip, |  1009 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, const GrClip& 
      clip, | 
|  1016                               GrDrawBatch* batch) { |  1010                               GrDrawBatch* batch) { | 
|  1017     ASSERT_SINGLE_OWNER |  1011     ASSERT_SINGLE_OWNER | 
|  1018     RETURN_IF_ABANDONED |  1012     RETURN_IF_ABANDONED | 
|  1019     SkDEBUGCODE(this->validate();) |  1013     SkDEBUGCODE(this->validate();) | 
|  1020     GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |  1014     GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 
|  1021  |  1015  | 
|  1022     this->getDrawTarget()->drawBatch(*pipelineBuilder, clip, batch); |  1016     this->getDrawTarget()->drawBatch(*pipelineBuilder, clip, batch); | 
|  1023 } |  1017 } | 
| OLD | NEW |