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

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

Issue 749903003: some cleanup around GrGpu/GrDrawTarget copySurface (Closed) Base URL: https://skia.googlesource.com/skia.git@isSameAs
Patch Set: fix regression Created 6 years 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/GrDrawTarget.h ('k') | src/gpu/GrGpu.h » ('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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 10
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 914
915 SkIRect clippedSrcRect; 915 SkIRect clippedSrcRect;
916 SkIPoint clippedDstPoint; 916 SkIPoint clippedDstPoint;
917 // If the rect is outside the src or dst then we've already succeeded. 917 // If the rect is outside the src or dst then we've already succeeded.
918 if (!clip_srcrect_and_dstpoint(dst, 918 if (!clip_srcrect_and_dstpoint(dst,
919 src, 919 src,
920 srcRect, 920 srcRect,
921 dstPoint, 921 dstPoint,
922 &clippedSrcRect, 922 &clippedSrcRect,
923 &clippedDstPoint)) { 923 &clippedDstPoint)) {
924 SkASSERT(GrDrawTarget::canCopySurface(dst, src, srcRect, dstPoint));
925 return true; 924 return true;
926 } 925 }
927 926
928 if (!GrDrawTarget::canCopySurface(dst, src, clippedSrcRect, clippedDstPoint) ) { 927 if (this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint)) {
929 return false; 928 return true;
930 } 929 }
931 930
932 GrRenderTarget* rt = dst->asRenderTarget(); 931 GrRenderTarget* rt = dst->asRenderTarget();
933 GrTexture* tex = src->asTexture(); 932 GrTexture* tex = src->asTexture();
934 933
934 if ((dst == src) || !rt || !tex) {
935 return false;
936 }
937
935 GrDrawState drawState; 938 GrDrawState drawState;
936 drawState.setRenderTarget(rt); 939 drawState.setRenderTarget(rt);
937 SkMatrix matrix; 940 SkMatrix matrix;
938 matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX) , 941 matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX) ,
939 SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY)) ; 942 SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY)) ;
940 matrix.postIDiv(tex->width(), tex->height()); 943 matrix.postIDiv(tex->width(), tex->height());
941 drawState.addColorTextureProcessor(tex, matrix); 944 drawState.addColorTextureProcessor(tex, matrix);
942 SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX, 945 SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX,
943 clippedDstPoint.fY, 946 clippedDstPoint.fY,
944 clippedSrcRect.width(), 947 clippedSrcRect.width(),
(...skipping 13 matching lines...) Expand all
958 SkIPoint clippedDstPoint; 961 SkIPoint clippedDstPoint;
959 // If the rect is outside the src or dst then we're guaranteed success 962 // If the rect is outside the src or dst then we're guaranteed success
960 if (!clip_srcrect_and_dstpoint(dst, 963 if (!clip_srcrect_and_dstpoint(dst,
961 src, 964 src,
962 srcRect, 965 srcRect,
963 dstPoint, 966 dstPoint,
964 &clippedSrcRect, 967 &clippedSrcRect,
965 &clippedDstPoint)) { 968 &clippedDstPoint)) {
966 return true; 969 return true;
967 } 970 }
971 return this->internalCanCopySurface(dst, src, clippedSrcRect, clippedDstPoin t);
972 }
968 973
974 bool GrDrawTarget::internalCanCopySurface(const GrSurface* dst,
975 const GrSurface* src,
976 const SkIRect& clippedSrcRect,
977 const SkIPoint& clippedDstPoint) {
969 // Check that the read/write rects are contained within the src/dst bounds. 978 // Check that the read/write rects are contained within the src/dst bounds.
970 SkASSERT(!clippedSrcRect.isEmpty()); 979 SkASSERT(!clippedSrcRect.isEmpty());
971 SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(clippedSrcRec t)); 980 SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(clippedSrcRec t));
972 SkASSERT(clippedDstPoint.fX >= 0 && clippedDstPoint.fY >= 0); 981 SkASSERT(clippedDstPoint.fX >= 0 && clippedDstPoint.fY >= 0);
973 SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() && 982 SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() &&
974 clippedDstPoint.fY + clippedSrcRect.height() <= dst->height()); 983 clippedDstPoint.fY + clippedSrcRect.height() <= dst->height());
975 984
976 return (dst != src) && dst->asRenderTarget() && src->asTexture(); 985 // The base class can do it as a draw or the subclass may be able to handle it.
977 } 986 return ((dst != src) && dst->asRenderTarget() && src->asTexture()) ||
978 987 this->onCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
979 void GrDrawTarget::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* d esc) {
980 // Make the dst of the copy be a render target because the default copySurfa ce draws to the dst.
981 desc->fOrigin = kDefault_GrSurfaceOrigin;
982 desc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag;
983 desc->fConfig = src->config();
984 } 988 }
985 989
986 /////////////////////////////////////////////////////////////////////////////// 990 ///////////////////////////////////////////////////////////////////////////////
987 991
988 void GrDrawTargetCaps::reset() { 992 void GrDrawTargetCaps::reset() {
989 fMipMapSupport = false; 993 fMipMapSupport = false;
990 fNPOTTextureTileSupport = false; 994 fNPOTTextureTileSupport = false;
991 fTwoSidedStencilSupport = false; 995 fTwoSidedStencilSupport = false;
992 fStencilWrapOpsSupport = false; 996 fStencilWrapOpsSupport = false;
993 fHWAALineSupport = false; 997 fHWAALineSupport = false;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 GrDrawState::AutoRestoreStencil* ars, 1159 GrDrawState::AutoRestoreStencil* ars,
1156 GrDrawState* ds, 1160 GrDrawState* ds,
1157 GrClipMaskManager::ScissorState* scissorState) { 1161 GrClipMaskManager::ScissorState* scissorState) {
1158 return fClipMaskManager.setupClipping(ds, 1162 return fClipMaskManager.setupClipping(ds,
1159 are, 1163 are,
1160 ars, 1164 ars,
1161 scissorState, 1165 scissorState,
1162 this->getClip(), 1166 this->getClip(),
1163 devBounds); 1167 devBounds);
1164 } 1168 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698