LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/gpu/ops - GrCopySurfaceOp.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 41 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2015 Google Inc.
       3             :  *
       4             :  * Use of this source code is governed by a BSD-style license that can be
       5             :  * found in the LICENSE file.
       6             :  */
       7             : 
       8             : #include "GrCopySurfaceOp.h"
       9             : 
      10             : // returns true if the read/written rect intersects the src/dst and false if not.
      11           0 : static bool clip_src_rect_and_dst_point(const GrSurfaceProxy* dst,
      12             :                                         const GrSurfaceProxy* src,
      13             :                                         const SkIRect& srcRect,
      14             :                                         const SkIPoint& dstPoint,
      15             :                                         SkIRect* clippedSrcRect,
      16             :                                         SkIPoint* clippedDstPoint) {
      17           0 :     *clippedSrcRect = srcRect;
      18           0 :     *clippedDstPoint = dstPoint;
      19             : 
      20             :     // clip the left edge to src and dst bounds, adjusting dstPoint if necessary
      21           0 :     if (clippedSrcRect->fLeft < 0) {
      22           0 :         clippedDstPoint->fX -= clippedSrcRect->fLeft;
      23           0 :         clippedSrcRect->fLeft = 0;
      24             :     }
      25           0 :     if (clippedDstPoint->fX < 0) {
      26           0 :         clippedSrcRect->fLeft -= clippedDstPoint->fX;
      27           0 :         clippedDstPoint->fX = 0;
      28             :     }
      29             : 
      30             :     // clip the top edge to src and dst bounds, adjusting dstPoint if necessary
      31           0 :     if (clippedSrcRect->fTop < 0) {
      32           0 :         clippedDstPoint->fY -= clippedSrcRect->fTop;
      33           0 :         clippedSrcRect->fTop = 0;
      34             :     }
      35           0 :     if (clippedDstPoint->fY < 0) {
      36           0 :         clippedSrcRect->fTop -= clippedDstPoint->fY;
      37           0 :         clippedDstPoint->fY = 0;
      38             :     }
      39             : 
      40             :     // clip the right edge to the src and dst bounds.
      41           0 :     if (clippedSrcRect->fRight > src->width()) {
      42           0 :         clippedSrcRect->fRight = src->width();
      43             :     }
      44           0 :     if (clippedDstPoint->fX + clippedSrcRect->width() > dst->width()) {
      45           0 :         clippedSrcRect->fRight = clippedSrcRect->fLeft + dst->width() - clippedDstPoint->fX;
      46             :     }
      47             : 
      48             :     // clip the bottom edge to the src and dst bounds.
      49           0 :     if (clippedSrcRect->fBottom > src->height()) {
      50           0 :         clippedSrcRect->fBottom = src->height();
      51             :     }
      52           0 :     if (clippedDstPoint->fY + clippedSrcRect->height() > dst->height()) {
      53           0 :         clippedSrcRect->fBottom = clippedSrcRect->fTop + dst->height() - clippedDstPoint->fY;
      54             :     }
      55             : 
      56             :     // The above clipping steps may have inverted the rect if it didn't intersect either the src or
      57             :     // dst bounds.
      58           0 :     return !clippedSrcRect->isEmpty();
      59             : }
      60             : 
      61           0 : std::unique_ptr<GrOp> GrCopySurfaceOp::Make(GrResourceProvider* resourceProvider,
      62             :                                             GrSurfaceProxy* dstProxy, GrSurfaceProxy* srcProxy,
      63             :                                             const SkIRect& srcRect,
      64             :                                             const SkIPoint& dstPoint) {
      65           0 :     SkASSERT(dstProxy);
      66           0 :     SkASSERT(srcProxy);
      67           0 :     if (GrPixelConfigIsSint(dstProxy->config()) != GrPixelConfigIsSint(srcProxy->config())) {
      68           0 :         return nullptr;
      69             :     }
      70           0 :     if (GrPixelConfigIsCompressed(dstProxy->config())) {
      71           0 :         return nullptr;
      72             :     }
      73             :     SkIRect clippedSrcRect;
      74             :     SkIPoint clippedDstPoint;
      75             :     // If the rect is outside the srcProxy or dstProxy then we've already succeeded.
      76           0 :     if (!clip_src_rect_and_dst_point(dstProxy, srcProxy, srcRect, dstPoint,
      77             :                                      &clippedSrcRect, &clippedDstPoint)) {
      78           0 :         return nullptr;
      79             :     }
      80             : 
      81             :     // MDB TODO: remove this instantiation
      82           0 :     GrSurface* dstTex = dstProxy->instantiate(resourceProvider);
      83           0 :     if (!dstTex) {
      84           0 :         return nullptr;
      85             :     }
      86           0 :     GrSurface* srcTex = srcProxy->instantiate(resourceProvider);
      87           0 :     if (!srcTex) {
      88           0 :         return nullptr;
      89             :     }
      90             : 
      91             :     return std::unique_ptr<GrOp>(new GrCopySurfaceOp(dstTex, srcTex,
      92           0 :                                                      dstProxy->uniqueID(), srcProxy->uniqueID(),
      93           0 :                                                      clippedSrcRect, clippedDstPoint));
      94             : }

Generated by: LCOV version 1.13