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

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

Issue 310483010: Fall back to using clip effect for outer rrect in drawdrrect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test to ignored-tests.txt Created 6 years, 6 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/GrDrawState.h ('k') | no next file » | 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 2013 Google Inc. 2 * Copyright 2013 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 #include "GrOvalRenderer.h" 8 #include "GrOvalRenderer.h"
9 9
10 #include "GrEffect.h" 10 #include "GrEffect.h"
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 #endif 877 #endif
878 fRRectIndexBuffer->updateData(gRRectIndices, 878 fRRectIndexBuffer->updateData(gRRectIndices,
879 sizeof(gRRectIndices)); 879 sizeof(gRRectIndices));
880 GR_DEBUGASSERT(updated); 880 GR_DEBUGASSERT(updated);
881 } 881 }
882 } 882 }
883 return fRRectIndexBuffer; 883 return fRRectIndexBuffer;
884 } 884 }
885 885
886 bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, GrContext* context, bool u seAA, 886 bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, GrContext* context, bool u seAA,
887 const SkRRect& outer, const SkRRect& origInner) { 887 const SkRRect& origOuter, const SkRRect& origInn er) {
888 bool applyAA = useAA &&
889 !target->getDrawState().getRenderTarget()->isMultisampled() & &
890 !target->shouldDisableCoverageAAForBlend();
888 GrDrawState::AutoRestoreEffects are; 891 GrDrawState::AutoRestoreEffects are;
889 if (!origInner.isEmpty()) { 892 if (!origInner.isEmpty()) {
890 SkTCopyOnFirstWrite<SkRRect> inner(origInner); 893 SkTCopyOnFirstWrite<SkRRect> inner(origInner);
891 if (!context->getMatrix().isIdentity()) { 894 if (!context->getMatrix().isIdentity()) {
892 if (!origInner.transform(context->getMatrix(), inner.writable())) { 895 if (!origInner.transform(context->getMatrix(), inner.writable())) {
893 return false; 896 return false;
894 } 897 }
895 } 898 }
896 bool applyAA = useAA &&
897 !target->getDrawState().getRenderTarget()->isMultisampled () &&
898 !target->shouldDisableCoverageAAForBlend();
899 GrEffectEdgeType edgeType = applyAA ? kInverseFillAA_GrEffectEdgeType : 899 GrEffectEdgeType edgeType = applyAA ? kInverseFillAA_GrEffectEdgeType :
900 kInverseFillBW_GrEffectEdgeType; 900 kInverseFillBW_GrEffectEdgeType;
901 GrEffectRef* effect = GrRRectEffect::Create(edgeType, *inner); 901 GrEffectRef* effect = GrRRectEffect::Create(edgeType, *inner);
902 if (NULL == effect) { 902 if (NULL == effect) {
903 return false; 903 return false;
904 } 904 }
905 are.set(target->drawState()); 905 are.set(target->drawState());
906 target->drawState()->addCoverageEffect(effect)->unref(); 906 target->drawState()->addCoverageEffect(effect)->unref();
907 } 907 }
908 908
909 SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle); 909 SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle);
910 return this->drawRRect(target, context, useAA, outer, fillRec); 910 if (this->drawRRect(target, context, useAA, origOuter, fillRec)) {
911 return true;
912 }
913
914 SkASSERT(!origOuter.isEmpty());
915 SkTCopyOnFirstWrite<SkRRect> outer(origOuter);
916 if (!context->getMatrix().isIdentity()) {
917 if (!origOuter.transform(context->getMatrix(), outer.writable())) {
918 return false;
919 }
920 }
921 GrEffectEdgeType edgeType = applyAA ? kFillAA_GrEffectEdgeType :
922 kFillBW_GrEffectEdgeType;
923 GrEffectRef* effect = GrRRectEffect::Create(edgeType, *outer);
924 if (NULL == effect) {
925 return false;
926 }
927 if (!are.isSet()) {
928 are.set(target->drawState());
929 }
930 GrDrawState::AutoViewMatrixRestore avmr;
931 if (!avmr.setIdentity(target->drawState())) {
932 return false;
933 }
934 target->drawState()->addCoverageEffect(effect)->unref();
935 SkRect bounds = outer->getBounds();
936 if (applyAA) {
937 bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
938 }
939 target->drawRect(bounds, NULL, NULL, NULL);
940 return true;
911 } 941 }
912 942
913 bool GrOvalRenderer::drawRRect(GrDrawTarget* target, GrContext* context, bool us eAA, 943 bool GrOvalRenderer::drawRRect(GrDrawTarget* target, GrContext* context, bool us eAA,
914 const SkRRect& rrect, const SkStrokeRec& stroke) { 944 const SkRRect& rrect, const SkStrokeRec& stroke) {
915 if (rrect.isOval()) { 945 if (rrect.isOval()) {
916 return this->drawOval(target, context, useAA, rrect.getBounds(), stroke) ; 946 return this->drawOval(target, context, useAA, rrect.getBounds(), stroke) ;
917 } 947 }
918 948
919 bool useCoverageAA = useAA && 949 bool useCoverageAA = useAA &&
920 !target->getDrawState().getRenderTarget()->isMultisampled() && 950 !target->getDrawState().getRenderTarget()->isMultisampled() &&
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 1215
1186 // drop out the middle quad if we're stroked 1216 // drop out the middle quad if we're stroked
1187 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : 1217 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
1188 SK_ARRAY_COUNT(gRRectIndices); 1218 SK_ARRAY_COUNT(gRRectIndices);
1189 target->setIndexSourceToBuffer(indexBuffer); 1219 target->setIndexSourceToBuffer(indexBuffer);
1190 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou nds); 1220 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou nds);
1191 } 1221 }
1192 1222
1193 return true; 1223 return true;
1194 } 1224 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698