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

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

Issue 694933002: Temporary fix to remove drawrect call from GpuGL (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanupcontext
Patch Set: cleanup Created 6 years, 1 month 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/GrInOrderDrawBuffer.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 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 909
910 SkIRect clippedSrcRect; 910 SkIRect clippedSrcRect;
911 SkIPoint clippedDstPoint; 911 SkIPoint clippedDstPoint;
912 // If the rect is outside the src or dst then we've already succeeded. 912 // If the rect is outside the src or dst then we've already succeeded.
913 if (!clip_srcrect_and_dstpoint(dst, 913 if (!clip_srcrect_and_dstpoint(dst,
914 src, 914 src,
915 srcRect, 915 srcRect,
916 dstPoint, 916 dstPoint,
917 &clippedSrcRect, 917 &clippedSrcRect,
918 &clippedDstPoint)) { 918 &clippedDstPoint)) {
919 SkASSERT(this->canCopySurface(dst, src, srcRect, dstPoint)); 919 SkASSERT(GrDrawTarget::canCopySurface(dst, src, srcRect, dstPoint));
920 return true; 920 return true;
921 } 921 }
922 922
923 bool result = this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint) ; 923 if (!GrDrawTarget::canCopySurface(dst, src, clippedSrcRect, clippedDstPoint) ) {
924 SkASSERT(result == this->canCopySurface(dst, src, clippedSrcRect, clippedDst Point)); 924 return false;
925 return result; 925 }
926
927 GrRenderTarget* rt = dst->asRenderTarget();
928 GrTexture* tex = src->asTexture();
929
930 GrDrawTarget::AutoStateRestore asr(this, kReset_ASRInit);
931 this->drawState()->setRenderTarget(rt);
932 SkMatrix matrix;
933 matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX) ,
934 SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY)) ;
935 matrix.postIDiv(tex->width(), tex->height());
936 this->drawState()->addColorTextureProcessor(tex, matrix);
937 SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX,
938 clippedDstPoint.fY,
939 clippedSrcRect.width(),
940 clippedSrcRect.height());
941 this->drawSimpleRect(dstRect);
942 return true;
926 } 943 }
927 944
928 bool GrDrawTarget::canCopySurface(GrSurface* dst, 945 bool GrDrawTarget::canCopySurface(GrSurface* dst,
929 GrSurface* src, 946 GrSurface* src,
930 const SkIRect& srcRect, 947 const SkIRect& srcRect,
931 const SkIPoint& dstPoint) { 948 const SkIPoint& dstPoint) {
932 SkASSERT(dst); 949 SkASSERT(dst);
933 SkASSERT(src); 950 SkASSERT(src);
934 951
935 SkIRect clippedSrcRect; 952 SkIRect clippedSrcRect;
936 SkIPoint clippedDstPoint; 953 SkIPoint clippedDstPoint;
937 // If the rect is outside the src or dst then we're guaranteed success 954 // If the rect is outside the src or dst then we're guaranteed success
938 if (!clip_srcrect_and_dstpoint(dst, 955 if (!clip_srcrect_and_dstpoint(dst,
939 src, 956 src,
940 srcRect, 957 srcRect,
941 dstPoint, 958 dstPoint,
942 &clippedSrcRect, 959 &clippedSrcRect,
943 &clippedDstPoint)) { 960 &clippedDstPoint)) {
944 return true; 961 return true;
945 } 962 }
946 return this->onCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
947 }
948 963
949 bool GrDrawTarget::onCanCopySurface(GrSurface* dst,
950 GrSurface* src,
951 const SkIRect& srcRect,
952 const SkIPoint& dstPoint) {
953 // Check that the read/write rects are contained within the src/dst bounds. 964 // Check that the read/write rects are contained within the src/dst bounds.
954 SkASSERT(!srcRect.isEmpty()); 965 SkASSERT(!clippedSrcRect.isEmpty());
955 SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(srcRect)); 966 SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(clippedSrcRec t));
956 SkASSERT(dstPoint.fX >= 0 && dstPoint.fY >= 0); 967 SkASSERT(clippedDstPoint.fX >= 0 && clippedDstPoint.fY >= 0);
957 SkASSERT(dstPoint.fX + srcRect.width() <= dst->width() && 968 SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() &&
958 dstPoint.fY + srcRect.height() <= dst->height()); 969 clippedDstPoint.fY + clippedSrcRect.height() <= dst->height());
959 970
960 return !dst->surfacePriv().isSameAs(src) && dst->asRenderTarget() && src->as Texture(); 971 return !dst->surfacePriv().isSameAs(src) && dst->asRenderTarget() && src->as Texture();
961 } 972 }
962 973
963 bool GrDrawTarget::onCopySurface(GrSurface* dst,
964 GrSurface* src,
965 const SkIRect& srcRect,
966 const SkIPoint& dstPoint) {
967 if (!GrDrawTarget::onCanCopySurface(dst, src, srcRect, dstPoint)) {
968 return false;
969 }
970
971 GrRenderTarget* rt = dst->asRenderTarget();
972 GrTexture* tex = src->asTexture();
973
974 GrDrawTarget::AutoStateRestore asr(this, kReset_ASRInit);
975 this->drawState()->setRenderTarget(rt);
976 SkMatrix matrix;
977 matrix.setTranslate(SkIntToScalar(srcRect.fLeft - dstPoint.fX),
978 SkIntToScalar(srcRect.fTop - dstPoint.fY));
979 matrix.postIDiv(tex->width(), tex->height());
980 this->drawState()->addColorTextureProcessor(tex, matrix);
981 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX,
982 dstPoint.fY,
983 srcRect.width(),
984 srcRect.height());
985 this->drawSimpleRect(dstRect);
986 return true;
987 }
988
989 void GrDrawTarget::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* d esc) { 974 void GrDrawTarget::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* d esc) {
990 // Make the dst of the copy be a render target because the default copySurfa ce draws to the dst. 975 // Make the dst of the copy be a render target because the default copySurfa ce draws to the dst.
991 desc->fOrigin = kDefault_GrSurfaceOrigin; 976 desc->fOrigin = kDefault_GrSurfaceOrigin;
992 desc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag; 977 desc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag;
993 desc->fConfig = src->config(); 978 desc->fConfig = src->config();
994 } 979 }
995 980
996 /////////////////////////////////////////////////////////////////////////////// 981 ///////////////////////////////////////////////////////////////////////////////
997 982
998 void GrDrawTargetCaps::reset() { 983 void GrDrawTargetCaps::reset() {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 1128
1144 uint32_t GrDrawTargetCaps::CreateUniqueID() { 1129 uint32_t GrDrawTargetCaps::CreateUniqueID() {
1145 static int32_t gUniqueID = SK_InvalidUniqueID; 1130 static int32_t gUniqueID = SK_InvalidUniqueID;
1146 uint32_t id; 1131 uint32_t id;
1147 do { 1132 do {
1148 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); 1133 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
1149 } while (id == SK_InvalidUniqueID); 1134 } while (id == SK_InvalidUniqueID);
1150 return id; 1135 return id;
1151 } 1136 }
1152 1137
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698