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

Side by Side Diff: src/gpu/batches/GrCopySurfaceBatch.cpp

Issue 1684313002: Make copySurface work for texture dsts, return a bool, & add unit test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try again Created 4 years, 10 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
« no previous file with comments | « src/gpu/batches/GrCopySurfaceBatch.h ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include "GrCopySurfaceBatch.h" 9 #include "GrCopySurfaceBatch.h"
10 10
11 // returns true if the read/written rect intersects the src/dst and false if not . 11 // returns true if the read/written rect intersects the src/dst and false if not .
12 static bool clip_srcrect_and_dstpoint(const GrSurface* dst, 12 bool GrCopySurfaceBatch::ClipSrcRectAndDstPoint(const GrSurface* dst,
13 const GrSurface* src, 13 const GrSurface* src,
14 const SkIRect& srcRect, 14 const SkIRect& srcRect,
15 const SkIPoint& dstPoint, 15 const SkIPoint& dstPoint,
16 SkIRect* clippedSrcRect, 16 SkIRect* clippedSrcRect,
17 SkIPoint* clippedDstPoint) { 17 SkIPoint* clippedDstPoint) {
18 *clippedSrcRect = srcRect; 18 *clippedSrcRect = srcRect;
19 *clippedDstPoint = dstPoint; 19 *clippedDstPoint = dstPoint;
20 20
21 // clip the left edge to src and dst bounds, adjusting dstPoint if necessary 21 // clip the left edge to src and dst bounds, adjusting dstPoint if necessary
22 if (clippedSrcRect->fLeft < 0) { 22 if (clippedSrcRect->fLeft < 0) {
23 clippedDstPoint->fX -= clippedSrcRect->fLeft; 23 clippedDstPoint->fX -= clippedSrcRect->fLeft;
24 clippedSrcRect->fLeft = 0; 24 clippedSrcRect->fLeft = 0;
25 } 25 }
26 if (clippedDstPoint->fX < 0) { 26 if (clippedDstPoint->fX < 0) {
27 clippedSrcRect->fLeft -= clippedDstPoint->fX; 27 clippedSrcRect->fLeft -= clippedDstPoint->fX;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 61
62 GrBatch* GrCopySurfaceBatch::Create(GrSurface* dst, GrSurface* src, const SkIRec t& srcRect, 62 GrBatch* GrCopySurfaceBatch::Create(GrSurface* dst, GrSurface* src, const SkIRec t& srcRect,
63 const SkIPoint& dstPoint) { 63 const SkIPoint& dstPoint) {
64 SkASSERT(dst); 64 SkASSERT(dst);
65 SkASSERT(src); 65 SkASSERT(src);
66 66
67 SkIRect clippedSrcRect; 67 SkIRect clippedSrcRect;
68 SkIPoint clippedDstPoint; 68 SkIPoint clippedDstPoint;
69 // If the rect is outside the src or dst then we've already succeeded. 69 // If the rect is outside the src or dst then we've already succeeded.
70 if (!clip_srcrect_and_dstpoint(dst, 70 if (!ClipSrcRectAndDstPoint(dst, src, srcRect, dstPoint, &clippedSrcRect, &c lippedDstPoint)) {
71 src,
72 srcRect,
73 dstPoint,
74 &clippedSrcRect,
75 &clippedDstPoint)) {
76 return nullptr; 71 return nullptr;
77 } 72 }
78 return new GrCopySurfaceBatch(dst, src, clippedSrcRect, clippedDstPoint); 73 return new GrCopySurfaceBatch(dst, src, clippedSrcRect, clippedDstPoint);
79 } 74 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrCopySurfaceBatch.h ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698