OLD | NEW |
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 Loading... |
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)); |
924 return true; | 925 return true; |
925 } | 926 } |
926 | 927 |
927 if (this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint)) { | 928 if (!GrDrawTarget::canCopySurface(dst, src, clippedSrcRect, clippedDstPoint)
) { |
928 return true; | 929 return false; |
929 } | 930 } |
930 | 931 |
931 GrRenderTarget* rt = dst->asRenderTarget(); | 932 GrRenderTarget* rt = dst->asRenderTarget(); |
932 GrTexture* tex = src->asTexture(); | 933 GrTexture* tex = src->asTexture(); |
933 | 934 |
934 if ((dst != src) && rt && tex) { | |
935 return false; | |
936 } | |
937 | |
938 GrDrawState drawState; | 935 GrDrawState drawState; |
939 drawState.setRenderTarget(rt); | 936 drawState.setRenderTarget(rt); |
940 SkMatrix matrix; | 937 SkMatrix matrix; |
941 matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX)
, | 938 matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX)
, |
942 SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY))
; | 939 SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY))
; |
943 matrix.postIDiv(tex->width(), tex->height()); | 940 matrix.postIDiv(tex->width(), tex->height()); |
944 drawState.addColorTextureProcessor(tex, matrix); | 941 drawState.addColorTextureProcessor(tex, matrix); |
945 SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX, | 942 SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX, |
946 clippedDstPoint.fY, | 943 clippedDstPoint.fY, |
947 clippedSrcRect.width(), | 944 clippedSrcRect.width(), |
(...skipping 13 matching lines...) Expand all Loading... |
961 SkIPoint clippedDstPoint; | 958 SkIPoint clippedDstPoint; |
962 // If the rect is outside the src or dst then we're guaranteed success | 959 // If the rect is outside the src or dst then we're guaranteed success |
963 if (!clip_srcrect_and_dstpoint(dst, | 960 if (!clip_srcrect_and_dstpoint(dst, |
964 src, | 961 src, |
965 srcRect, | 962 srcRect, |
966 dstPoint, | 963 dstPoint, |
967 &clippedSrcRect, | 964 &clippedSrcRect, |
968 &clippedDstPoint)) { | 965 &clippedDstPoint)) { |
969 return true; | 966 return true; |
970 } | 967 } |
971 return this->internalCanCopySurface(dst, src, clippedSrcRect, clippedDstPoin
t); | |
972 } | |
973 | 968 |
974 bool GrDrawTarget::internalCanCopySurface(const GrSurface* dst, | |
975 const GrSurface* src, | |
976 const SkIRect& clippedSrcRect, | |
977 const SkIPoint& clippedDstPoint) { | |
978 // Check that the read/write rects are contained within the src/dst bounds. | 969 // Check that the read/write rects are contained within the src/dst bounds. |
979 SkASSERT(!clippedSrcRect.isEmpty()); | 970 SkASSERT(!clippedSrcRect.isEmpty()); |
980 SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(clippedSrcRec
t)); | 971 SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(clippedSrcRec
t)); |
981 SkASSERT(clippedDstPoint.fX >= 0 && clippedDstPoint.fY >= 0); | 972 SkASSERT(clippedDstPoint.fX >= 0 && clippedDstPoint.fY >= 0); |
982 SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() && | 973 SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() && |
983 clippedDstPoint.fY + clippedSrcRect.height() <= dst->height()); | 974 clippedDstPoint.fY + clippedSrcRect.height() <= dst->height()); |
984 | 975 |
985 // The base class can do it as a draw or the subclass may be able to handle
it. | 976 return (dst != src) && dst->asRenderTarget() && src->asTexture(); |
986 return ((dst != src) && dst->asRenderTarget() && src->asTexture()) || | 977 } |
987 this->onCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint); | 978 |
| 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(); |
988 } | 984 } |
989 | 985 |
990 /////////////////////////////////////////////////////////////////////////////// | 986 /////////////////////////////////////////////////////////////////////////////// |
991 | 987 |
992 void GrDrawTargetCaps::reset() { | 988 void GrDrawTargetCaps::reset() { |
993 fMipMapSupport = false; | 989 fMipMapSupport = false; |
994 fNPOTTextureTileSupport = false; | 990 fNPOTTextureTileSupport = false; |
995 fTwoSidedStencilSupport = false; | 991 fTwoSidedStencilSupport = false; |
996 fStencilWrapOpsSupport = false; | 992 fStencilWrapOpsSupport = false; |
997 fHWAALineSupport = false; | 993 fHWAALineSupport = false; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 GrDrawState::AutoRestoreStencil* ars, | 1155 GrDrawState::AutoRestoreStencil* ars, |
1160 GrDrawState* ds, | 1156 GrDrawState* ds, |
1161 GrClipMaskManager::ScissorState* scissorState) { | 1157 GrClipMaskManager::ScissorState* scissorState) { |
1162 return fClipMaskManager.setupClipping(ds, | 1158 return fClipMaskManager.setupClipping(ds, |
1163 are, | 1159 are, |
1164 ars, | 1160 ars, |
1165 scissorState, | 1161 scissorState, |
1166 this->getClip(), | 1162 this->getClip(), |
1167 devBounds); | 1163 devBounds); |
1168 } | 1164 } |
OLD | NEW |