OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <cmath> | 6 #include <cmath> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include <GLES2/gl2.h> | 10 #include <GLES2/gl2.h> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 attributes, lose_context_when_out_of_memory); | 61 attributes, lose_context_when_out_of_memory); |
62 context_->InitializeOnCurrentThread(); | 62 context_->InitializeOnCurrentThread(); |
63 context_support_ = context_->GetContextSupport(); | 63 context_support_ = context_->GetContextSupport(); |
64 helper_.reset( | 64 helper_.reset( |
65 new content::GLHelper(context_->GetGLInterface(), context_support_)); | 65 new content::GLHelper(context_->GetGLInterface(), context_support_)); |
66 helper_scaling_.reset(new content::GLHelperScaling( | 66 helper_scaling_.reset(new content::GLHelperScaling( |
67 context_->GetGLInterface(), helper_.get())); | 67 context_->GetGLInterface(), helper_.get())); |
68 } | 68 } |
69 | 69 |
70 virtual void TearDown() { | 70 virtual void TearDown() { |
71 helper_scaling_.reset(NULL); | 71 helper_scaling_.reset(nullptr); |
72 helper_.reset(NULL); | 72 helper_.reset(nullptr); |
73 context_.reset(NULL); | 73 context_.reset(nullptr); |
74 } | 74 } |
75 | 75 |
76 void StartTracing(const std::string& filter) { | 76 void StartTracing(const std::string& filter) { |
77 base::debug::TraceLog::GetInstance()->SetEnabled( | 77 base::debug::TraceLog::GetInstance()->SetEnabled( |
78 base::debug::CategoryFilter(filter), | 78 base::debug::CategoryFilter(filter), |
79 base::debug::TraceLog::RECORDING_MODE, | 79 base::debug::TraceLog::RECORDING_MODE, |
80 base::debug::TraceOptions( | 80 base::debug::TraceOptions( |
81 base::debug::RECORD_UNTIL_FULL)); | 81 base::debug::RECORD_UNTIL_FULL)); |
82 } | 82 } |
83 | 83 |
(...skipping 21 matching lines...) Expand all Loading... |
105 base::Bind(&GLHelperTest::TraceDataCB, | 105 base::Bind(&GLHelperTest::TraceDataCB, |
106 run_loop.QuitClosure(), | 106 run_loop.QuitClosure(), |
107 base::Unretained(&json_data))); | 107 base::Unretained(&json_data))); |
108 run_loop.Run(); | 108 run_loop.Run(); |
109 json_data.append("]"); | 109 json_data.append("]"); |
110 | 110 |
111 scoped_ptr<base::Value> trace_data(base::JSONReader::Read(json_data)); | 111 scoped_ptr<base::Value> trace_data(base::JSONReader::Read(json_data)); |
112 base::ListValue* list; | 112 base::ListValue* list; |
113 CHECK(trace_data->GetAsList(&list)); | 113 CHECK(trace_data->GetAsList(&list)); |
114 for (size_t i = 0; i < list->GetSize(); i++) { | 114 for (size_t i = 0; i < list->GetSize(); i++) { |
115 base::Value* item = NULL; | 115 base::Value* item = nullptr; |
116 if (list->Get(i, &item)) { | 116 if (list->Get(i, &item)) { |
117 base::DictionaryValue* dict; | 117 base::DictionaryValue* dict; |
118 CHECK(item->GetAsDictionary(&dict)); | 118 CHECK(item->GetAsDictionary(&dict)); |
119 std::string name; | 119 std::string name; |
120 CHECK(dict->GetString("name", &name)); | 120 CHECK(dict->GetString("name", &name)); |
121 std::string trace_type; | 121 std::string trace_type; |
122 CHECK(dict->GetString("ph", &trace_type)); | 122 CHECK(dict->GetString("ph", &trace_type)); |
123 // Count all except END traces, as they come in BEGIN/END pairs. | 123 // Count all except END traces, as they come in BEGIN/END pairs. |
124 if (trace_type != "E") | 124 if (trace_type != "E") |
125 (*event_counts)[name]++; | 125 (*event_counts)[name]++; |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 // CropScaleReadbackAndCleanTexture flips the pixels. Flip them back. | 765 // CropScaleReadbackAndCleanTexture flips the pixels. Flip them back. |
766 FlipSKBitmap(&output_pixels); | 766 FlipSKBitmap(&output_pixels); |
767 | 767 |
768 // If the bitmap shouldn't have changed - compare against input. | 768 // If the bitmap shouldn't have changed - compare against input. |
769 if (xsize == scaled_xsize && ysize == scaled_ysize && | 769 if (xsize == scaled_xsize && ysize == scaled_ysize && |
770 out_color_type != kAlpha_8_SkColorType) { | 770 out_color_type != kAlpha_8_SkColorType) { |
771 const std::vector<GLHelperScaling::ScalerStage> dummy_stages; | 771 const std::vector<GLHelperScaling::ScalerStage> dummy_stages; |
772 Compare(input_pixels.get(), | 772 Compare(input_pixels.get(), |
773 &output_pixels, | 773 &output_pixels, |
774 0, | 774 0, |
775 NULL, | 775 nullptr, |
776 dummy_stages, | 776 dummy_stages, |
777 message + " comparing against input"); | 777 message + " comparing against input"); |
778 return; | 778 return; |
779 } | 779 } |
780 | 780 |
781 // Now transform the bitmap using the reference implementation. | 781 // Now transform the bitmap using the reference implementation. |
782 SkBitmap scaled_pixels; | 782 SkBitmap scaled_pixels; |
783 scaled_pixels.allocPixels(SkImageInfo::Make(scaled_xsize, | 783 scaled_pixels.allocPixels(SkImageInfo::Make(scaled_xsize, |
784 scaled_ysize, | 784 scaled_ysize, |
785 kRGBA_8888_SkColorType, | 785 kRGBA_8888_SkColorType, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 if (flip) { | 872 if (flip) { |
873 // Flip the pixels back. | 873 // Flip the pixels back. |
874 FlipSKBitmap(&output_pixels); | 874 FlipSKBitmap(&output_pixels); |
875 } | 875 } |
876 | 876 |
877 // If the bitmap shouldn't have changed - compare against input. | 877 // If the bitmap shouldn't have changed - compare against input. |
878 if (xsize == scaled_xsize && ysize == scaled_ysize) { | 878 if (xsize == scaled_xsize && ysize == scaled_ysize) { |
879 Compare(input_pixels.get(), | 879 Compare(input_pixels.get(), |
880 &output_pixels, | 880 &output_pixels, |
881 0, | 881 0, |
882 NULL, | 882 nullptr, |
883 stages, | 883 stages, |
884 message + " comparing against input"); | 884 message + " comparing against input"); |
885 return; | 885 return; |
886 } | 886 } |
887 | 887 |
888 // Now scale the bitmap using the reference implementation. | 888 // Now scale the bitmap using the reference implementation. |
889 SkBitmap truth_pixels; | 889 SkBitmap truth_pixels; |
890 truth_pixels.allocPixels(SkImageInfo::Make(scaled_xsize, | 890 truth_pixels.allocPixels(SkImageInfo::Make(scaled_xsize, |
891 scaled_ysize, | 891 scaled_ysize, |
892 kRGBA_8888_SkColorType, | 892 kRGBA_8888_SkColorType, |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 base::CommandLine::Init(argc, argv); | 1958 base::CommandLine::Init(argc, argv); |
1959 base::TestSuite* suite = new content::ContentTestSuite(argc, argv); | 1959 base::TestSuite* suite = new content::ContentTestSuite(argc, argv); |
1960 #if defined(OS_MACOSX) | 1960 #if defined(OS_MACOSX) |
1961 base::mac::ScopedNSAutoreleasePool pool; | 1961 base::mac::ScopedNSAutoreleasePool pool; |
1962 #endif | 1962 #endif |
1963 | 1963 |
1964 content::UnitTestTestSuite runner(suite); | 1964 content::UnitTestTestSuite runner(suite); |
1965 base::MessageLoop message_loop; | 1965 base::MessageLoop message_loop; |
1966 return runner.Run(); | 1966 return runner.Run(); |
1967 } | 1967 } |
OLD | NEW |