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

Side by Side Diff: content/common/gpu/client/gl_helper_benchmark.cc

Issue 841773006: Extract WebGraphicsContext3DInProcessCommandBufferImpl from webkit/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file looks like a unit test, but it contains benchmarks and test 5 // This file looks like a unit test, but it contains benchmarks and test
6 // utilities intended for manual evaluation of the scalers in 6 // utilities intended for manual evaluation of the scalers in
7 // gl_helper*. These tests produce output in the form of files and printouts, 7 // gl_helper*. These tests produce output in the form of files and printouts,
8 // but cannot really "fail". There is no point in making these tests part 8 // but cannot really "fail". There is no point in making these tests part
9 // of any test automation run. 9 // of any test automation run.
10 10
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <cmath> 12 #include <cmath>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include <GLES2/gl2.h> 16 #include <GLES2/gl2.h>
17 #include <GLES2/gl2ext.h> 17 #include <GLES2/gl2ext.h>
18 #include <GLES2/gl2extchromium.h> 18 #include <GLES2/gl2extchromium.h>
19 19
20 #include "base/at_exit.h" 20 #include "base/at_exit.h"
21 #include "base/command_line.h" 21 #include "base/command_line.h"
22 #include "base/files/file_util.h" 22 #include "base/files/file_util.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "content/common/gpu/client/gl_helper.h" 25 #include "content/common/gpu/client/gl_helper.h"
26 #include "content/common/gpu/client/gl_helper_scaling.h" 26 #include "content/common/gpu/client/gl_helper_scaling.h"
27 #include "content/public/test/unittest_test_suite.h" 27 #include "content/public/test/unittest_test_suite.h"
28 #include "content/test/content_test_suite.h" 28 #include "content/test/content_test_suite.h"
29 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 #include "third_party/skia/include/core/SkBitmap.h" 31 #include "third_party/skia/include/core/SkBitmap.h"
31 #include "third_party/skia/include/core/SkTypes.h" 32 #include "third_party/skia/include/core/SkTypes.h"
32 #include "ui/gfx/codec/png_codec.h" 33 #include "ui/gfx/codec/png_codec.h"
33 #include "ui/gl/gl_surface.h" 34 #include "ui/gl/gl_surface.h"
34 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
35 35
36 #if defined(OS_MACOSX) 36 #if defined(OS_MACOSX)
37 #include "base/mac/scoped_nsautorelease_pool.h" 37 #include "base/mac/scoped_nsautorelease_pool.h"
38 #endif 38 #endif
39 39
40 namespace content { 40 namespace content {
41 41
42 using blink::WebGLId; 42 using blink::WebGLId;
43 using blink::WebGraphicsContext3D; 43 using blink::WebGraphicsContext3D;
44 44
45 content::GLHelper::ScalerQuality kQualities[] = { 45 content::GLHelper::ScalerQuality kQualities[] = {
46 content::GLHelper::SCALER_QUALITY_BEST, 46 content::GLHelper::SCALER_QUALITY_BEST,
47 content::GLHelper::SCALER_QUALITY_GOOD, 47 content::GLHelper::SCALER_QUALITY_GOOD,
48 content::GLHelper::SCALER_QUALITY_FAST, 48 content::GLHelper::SCALER_QUALITY_FAST,
49 }; 49 };
50 50
51 const char *kQualityNames[] = { 51 const char *kQualityNames[] = {
52 "best", 52 "best",
53 "good", 53 "good",
54 "fast", 54 "fast",
55 }; 55 };
56 56
57 class GLHelperTest : public testing::Test { 57 class GLHelperTest : public testing::Test {
58 protected: 58 protected:
59 void SetUp() override { 59 void SetUp() override {
60 WebGraphicsContext3D::Attributes attributes; 60 WebGraphicsContext3D::Attributes attributes;
61 bool lose_context_when_out_of_memory = false; 61 bool lose_context_when_out_of_memory = false;
62 context_ = webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl:: 62 context_ = gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl::
63 CreateOffscreenContext(attributes, lose_context_when_out_of_memory); 63 CreateOffscreenContext(attributes, lose_context_when_out_of_memory);
64 context_->InitializeOnCurrentThread(); 64 context_->InitializeOnCurrentThread();
65 65
66 helper_.reset( 66 helper_.reset(
67 new content::GLHelper(context_->GetGLInterface(), 67 new content::GLHelper(context_->GetGLInterface(),
68 context_->GetContextSupport())); 68 context_->GetContextSupport()));
69 helper_scaling_.reset(new content::GLHelperScaling( 69 helper_scaling_.reset(new content::GLHelperScaling(
70 context_->GetGLInterface(), 70 context_->GetGLInterface(),
71 helper_.get())); 71 helper_.get()));
72 } 72 }
(...skipping 27 matching lines...) Expand all
100 std::vector<gfx::PNGCodec::Comment>(), 100 std::vector<gfx::PNGCodec::Comment>(),
101 &compressed)); 101 &compressed));
102 ASSERT_TRUE(compressed.size()); 102 ASSERT_TRUE(compressed.size());
103 FILE* f = base::OpenFile(filename, "wb"); 103 FILE* f = base::OpenFile(filename, "wb");
104 ASSERT_TRUE(f); 104 ASSERT_TRUE(f);
105 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), 105 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f),
106 compressed.size()); 106 compressed.size());
107 base::CloseFile(f); 107 base::CloseFile(f);
108 } 108 }
109 109
110 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> 110 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl>
111 context_; 111 context_;
112 scoped_ptr<content::GLHelper> helper_; 112 scoped_ptr<content::GLHelper> helper_;
113 scoped_ptr<content::GLHelperScaling> helper_scaling_; 113 scoped_ptr<content::GLHelperScaling> helper_scaling_;
114 std::deque<GLHelperScaling::ScaleOp> x_ops_, y_ops_; 114 std::deque<GLHelperScaling::ScaleOp> x_ops_, y_ops_;
115 }; 115 };
116 116
117 117
118 TEST_F(GLHelperTest, ScaleBenchmark) { 118 TEST_F(GLHelperTest, ScaleBenchmark) {
119 int output_sizes[] = { 1920, 1080, 119 int output_sizes[] = { 1920, 1080,
120 1249, 720, // Output size on pixel 120 1249, 720, // Output size on pixel
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 int main(int argc, char** argv) { 298 int main(int argc, char** argv) {
299 base::CommandLine::Init(argc, argv); 299 base::CommandLine::Init(argc, argv);
300 base::TestSuite* suite = new content::ContentTestSuite(argc, argv); 300 base::TestSuite* suite = new content::ContentTestSuite(argc, argv);
301 #if defined(OS_MACOSX) 301 #if defined(OS_MACOSX)
302 base::mac::ScopedNSAutoreleasePool pool; 302 base::mac::ScopedNSAutoreleasePool pool;
303 #endif 303 #endif
304 gfx::GLSurface::InitializeOneOff(); 304 gfx::GLSurface::InitializeOneOff();
305 305
306 return content::UnitTestTestSuite(suite).Run(); 306 return content::UnitTestTestSuite(suite).Run();
307 } 307 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.cc ('k') | content/common/gpu/client/gl_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698