OLD | NEW |
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 #include "SampleCode.h" | 7 #include "SampleCode.h" |
8 #include "Sk1DPathEffect.h" | 8 #include "Sk1DPathEffect.h" |
9 #include "Sk2DPathEffect.h" | 9 #include "Sk2DPathEffect.h" |
10 #include "SkAlphaThresholdFilter.h" | 10 #include "SkAlphaThresholdFilter.h" |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 break; | 731 break; |
732 } | 732 } |
733 default: | 733 default: |
734 break; | 734 break; |
735 } | 735 } |
736 return (filter || canBeNull) ? filter : make_image_filter(canBeNull); | 736 return (filter || canBeNull) ? filter : make_image_filter(canBeNull); |
737 } | 737 } |
738 | 738 |
739 static SkImageFilter* make_serialized_image_filter() { | 739 static SkImageFilter* make_serialized_image_filter() { |
740 sk_sp<SkImageFilter> filter(make_image_filter(false)); | 740 sk_sp<SkImageFilter> filter(make_image_filter(false)); |
741 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter.get())); | 741 sk_sp<SkData> data(SkValidatingSerializeFlattenable(filter.get())); |
742 const unsigned char* ptr = static_cast<const unsigned char*>(data->data()); | 742 const unsigned char* ptr = static_cast<const unsigned char*>(data->data()); |
743 size_t len = data->size(); | 743 size_t len = data->size(); |
744 #ifdef SK_ADD_RANDOM_BIT_FLIPS | 744 #ifdef SK_ADD_RANDOM_BIT_FLIPS |
745 unsigned char* p = const_cast<unsigned char*>(ptr); | 745 unsigned char* p = const_cast<unsigned char*>(ptr); |
746 for (size_t i = 0; i < len; ++i, ++p) { | 746 for (size_t i = 0; i < len; ++i, ++p) { |
747 if (R(250) == 1) { // 0.4% of the time, flip a bit or byte | 747 if (R(250) == 1) { // 0.4% of the time, flip a bit or byte |
748 if (R(10) == 1) { // Then 10% of the time, change a whole byte | 748 if (R(10) == 1) { // Then 10% of the time, change a whole byte |
749 switch(R(3)) { | 749 switch(R(3)) { |
750 case 0: | 750 case 0: |
751 *p ^= 0xFF; // Flip entire byte | 751 *p ^= 0xFF; // Flip entire byte |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 } | 826 } |
827 | 827 |
828 private: | 828 private: |
829 typedef SkView INHERITED; | 829 typedef SkView INHERITED; |
830 }; | 830 }; |
831 | 831 |
832 ////////////////////////////////////////////////////////////////////////////// | 832 ////////////////////////////////////////////////////////////////////////////// |
833 | 833 |
834 static SkView* MyFactory() { return new ImageFilterFuzzView; } | 834 static SkView* MyFactory() { return new ImageFilterFuzzView; } |
835 static SkViewRegister reg(MyFactory); | 835 static SkViewRegister reg(MyFactory); |
OLD | NEW |