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

Side by Side Diff: tests/PictureTest.cpp

Issue 551853002: Turn on the save-layer optimization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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/core/SkRecordOpts.cpp ('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 2012 Google Inc. 2 * Copyright 2012 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 "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 c->restore(); 928 c->restore();
929 c->restore(); 929 c->restore();
930 930
931 // 3) 931 // 3)
932 { 932 {
933 SkPaint p; 933 SkPaint p;
934 p.setColor(SK_ColorRED); 934 p.setColor(SK_ColorRED);
935 c->saveLayer(NULL, &p); // layer #3 935 c->saveLayer(NULL, &p); // layer #3
936 c->restore(); 936 c->restore();
937 } 937 }
938
939 SkPaint layerPaint;
940 layerPaint.setColor(SK_ColorRED); // Non-alpha only to avoid SaveLa yerDrawRestoreNooper
938 // 4) 941 // 4)
939 { 942 {
940 c->saveLayer(NULL, NULL); // layer #4 943 c->saveLayer(NULL, &layerPaint); // layer #4
941 c->drawPicture(child); // layer #5 inside picture 944 c->drawPicture(child); // layer #5 inside picture
942 c->restore(); 945 c->restore();
943 } 946 }
944 // 5 947 // 5
945 { 948 {
946 SkPaint p; 949 SkPaint picturePaint;
947 SkMatrix trans; 950 SkMatrix trans;
948 trans.setTranslate(10, 10); 951 trans.setTranslate(10, 10);
949 952
950 c->saveLayer(NULL, NULL); // layer #6 953 c->saveLayer(NULL, &layerPaint); // layer #6
951 c->drawPicture(child, &trans, &p); // layer #7 inside pictur e 954 c->drawPicture(child, &trans, &picturePaint); // layer #7 in side picture
952 c->restore(); 955 c->restore();
953 } 956 }
954 957
955 pict.reset(recorder.endRecording()); 958 pict.reset(recorder.endRecording());
956 } 959 }
957 960
958 // Now test out the SaveLayer extraction 961 // Now test out the SaveLayer extraction
959 { 962 {
960 SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight); 963 SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
961 964
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 REPORTER_ASSERT(reporter, 0 == info3.fOffset.fX && 0 == info3.fOffse t.fY); 1028 REPORTER_ASSERT(reporter, 0 == info3.fOffset.fX && 0 == info3.fOffse t.fY);
1026 REPORTER_ASSERT(reporter, info3.fPaint); 1029 REPORTER_ASSERT(reporter, info3.fPaint);
1027 REPORTER_ASSERT(reporter, !info3.fIsNested && !info3.fHasNestedLayer s); 1030 REPORTER_ASSERT(reporter, !info3.fIsNested && !info3.fHasNestedLayer s);
1028 1031
1029 REPORTER_ASSERT(reporter, info4.fValid); 1032 REPORTER_ASSERT(reporter, info4.fValid);
1030 REPORTER_ASSERT(reporter, pict->uniqueID() == info4.fPictureID); 1033 REPORTER_ASSERT(reporter, pict->uniqueID() == info4.fPictureID);
1031 REPORTER_ASSERT(reporter, kWidth == info4.fSize.fWidth && 1034 REPORTER_ASSERT(reporter, kWidth == info4.fSize.fWidth &&
1032 kHeight == info4.fSize.fHeight); 1035 kHeight == info4.fSize.fHeight);
1033 REPORTER_ASSERT(reporter, 0 == info4.fOffset.fX && 0 == info4.fOffse t.fY); 1036 REPORTER_ASSERT(reporter, 0 == info4.fOffset.fX && 0 == info4.fOffse t.fY);
1034 REPORTER_ASSERT(reporter, info4.fOriginXform.isIdentity()); 1037 REPORTER_ASSERT(reporter, info4.fOriginXform.isIdentity());
1035 REPORTER_ASSERT(reporter, NULL == info4.fPaint); 1038 REPORTER_ASSERT(reporter, info4.fPaint);
1036 REPORTER_ASSERT(reporter, !info4.fIsNested && 1039 REPORTER_ASSERT(reporter, !info4.fIsNested &&
1037 info4.fHasNestedLayers); // has a nested S L 1040 info4.fHasNestedLayers); // has a nested S L
1038 1041
1039 REPORTER_ASSERT(reporter, info5.fValid); 1042 REPORTER_ASSERT(reporter, info5.fValid);
1040 REPORTER_ASSERT(reporter, child->uniqueID() == info5.fPictureID); // in a child picture 1043 REPORTER_ASSERT(reporter, child->uniqueID() == info5.fPictureID); // in a child picture
1041 REPORTER_ASSERT(reporter, kWidth == info5.fSize.fWidth && 1044 REPORTER_ASSERT(reporter, kWidth == info5.fSize.fWidth &&
1042 kHeight == info5.fSize.fHeight); 1045 kHeight == info5.fSize.fHeight);
1043 REPORTER_ASSERT(reporter, 0 == info5.fOffset.fX && 0 == info5.fOffse t.fY); 1046 REPORTER_ASSERT(reporter, 0 == info5.fOffset.fX && 0 == info5.fOffse t.fY);
1044 REPORTER_ASSERT(reporter, info5.fOriginXform.isIdentity()); 1047 REPORTER_ASSERT(reporter, info5.fOriginXform.isIdentity());
1045 REPORTER_ASSERT(reporter, NULL == info5.fPaint); 1048 REPORTER_ASSERT(reporter, NULL == info5.fPaint);
1046 REPORTER_ASSERT(reporter, info5.fIsNested && !info5.fHasNestedLayers ); // is nested 1049 REPORTER_ASSERT(reporter, info5.fIsNested && !info5.fHasNestedLayers ); // is nested
1047 1050
1048 REPORTER_ASSERT(reporter, info6.fValid); 1051 REPORTER_ASSERT(reporter, info6.fValid);
1049 REPORTER_ASSERT(reporter, pict->uniqueID() == info6.fPictureID); 1052 REPORTER_ASSERT(reporter, pict->uniqueID() == info6.fPictureID);
1050 REPORTER_ASSERT(reporter, kWidth == info6.fSize.fWidth && 1053 REPORTER_ASSERT(reporter, kWidth == info6.fSize.fWidth &&
1051 kHeight == info6.fSize.fHeight); 1054 kHeight == info6.fSize.fHeight);
1052 REPORTER_ASSERT(reporter, 0 == info6.fOffset.fX && 0 == info6.fOffse t.fY); 1055 REPORTER_ASSERT(reporter, 0 == info6.fOffset.fX && 0 == info6.fOffse t.fY);
1053 REPORTER_ASSERT(reporter, info6.fOriginXform.isIdentity()); 1056 REPORTER_ASSERT(reporter, info6.fOriginXform.isIdentity());
1054 REPORTER_ASSERT(reporter, NULL == info6.fPaint); 1057 REPORTER_ASSERT(reporter, info6.fPaint);
1055 REPORTER_ASSERT(reporter, !info6.fIsNested && 1058 REPORTER_ASSERT(reporter, !info6.fIsNested &&
1056 info6.fHasNestedLayers); // has a nested S L 1059 info6.fHasNestedLayers); // has a nested S L
1057 1060
1058 REPORTER_ASSERT(reporter, info7.fValid); 1061 REPORTER_ASSERT(reporter, info7.fValid);
1059 REPORTER_ASSERT(reporter, child->uniqueID() == info7.fPictureID); // in a child picture 1062 REPORTER_ASSERT(reporter, child->uniqueID() == info7.fPictureID); // in a child picture
1060 REPORTER_ASSERT(reporter, kWidth == info7.fSize.fWidth && 1063 REPORTER_ASSERT(reporter, kWidth == info7.fSize.fWidth &&
1061 kHeight == info7.fSize.fHeight); 1064 kHeight == info7.fSize.fHeight);
1062 REPORTER_ASSERT(reporter, 0 == info7.fOffset.fX && 0 == info7.fOffse t.fY); 1065 REPORTER_ASSERT(reporter, 0 == info7.fOffset.fX && 0 == info7.fOffse t.fY);
1063 REPORTER_ASSERT(reporter, info7.fOriginXform.isIdentity()); 1066 REPORTER_ASSERT(reporter, info7.fOriginXform.isIdentity());
1064 REPORTER_ASSERT(reporter, NULL == info7.fPaint); 1067 REPORTER_ASSERT(reporter, NULL == info7.fPaint);
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 1946
1944 // The picture shares the immutable pixels but copies the mutable ones. 1947 // The picture shares the immutable pixels but copies the mutable ones.
1945 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1948 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1946 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); 1949 REPORTER_ASSERT(r, !immut.pixelRef()->unique());
1947 1950
1948 // When the picture goes away, it's just our bitmaps holding the refs. 1951 // When the picture goes away, it's just our bitmaps holding the refs.
1949 pic.reset(NULL); 1952 pic.reset(NULL);
1950 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1953 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1951 REPORTER_ASSERT(r, immut.pixelRef()->unique()); 1954 REPORTER_ASSERT(r, immut.pixelRef()->unique());
1952 } 1955 }
OLDNEW
« no previous file with comments | « src/core/SkRecordOpts.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698