OLD | NEW |
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 #if defined(USE_X11) | 5 #if defined(USE_X11) |
6 #include <X11/Xlib.h> | 6 #include <X11/Xlib.h> |
7 #endif | 7 #endif |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 // A benchmark that adds a texture layer that is updated every frame. | 151 // A benchmark that adds a texture layer that is updated every frame. |
152 class WebGLBench : public BenchCompositorObserver { | 152 class WebGLBench : public BenchCompositorObserver { |
153 public: | 153 public: |
154 WebGLBench(ui::ContextFactory* context_factory, | 154 WebGLBench(ui::ContextFactory* context_factory, |
155 Layer* parent, | 155 Layer* parent, |
156 Compositor* compositor, | 156 Compositor* compositor, |
157 int max_frames) | 157 int max_frames) |
158 : BenchCompositorObserver(max_frames), | 158 : BenchCompositorObserver(max_frames), |
159 parent_(parent), | 159 parent_(parent), |
160 webgl_(ui::LAYER_TEXTURED), | 160 webgl_(ui::LAYER_SOLID_COLOR), |
161 compositor_(compositor), | 161 compositor_(compositor), |
162 fbo_(0), | 162 fbo_(0), |
163 do_draw_(true) { | 163 do_draw_(true) { |
164 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 164 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
165 do_draw_ = !command_line->HasSwitch("disable-draw"); | 165 do_draw_ = !command_line->HasSwitch("disable-draw"); |
166 | 166 |
167 std::string webgl_size = command_line->GetSwitchValueASCII("webgl-size"); | 167 std::string webgl_size = command_line->GetSwitchValueASCII("webgl-size"); |
168 int width = 0; | 168 int width = 0; |
169 int height = 0; | 169 int height = 0; |
170 if (!webgl_size.empty()) { | 170 if (!webgl_size.empty()) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 GLuint sync_point = gl->InsertSyncPointCHROMIUM(); | 216 GLuint sync_point = gl->InsertSyncPointCHROMIUM(); |
217 webgl_.SetTextureMailbox( | 217 webgl_.SetTextureMailbox( |
218 cc::TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), | 218 cc::TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), |
219 cc::SingleReleaseCallback::Create( | 219 cc::SingleReleaseCallback::Create( |
220 base::Bind(ReturnMailbox, context_provider_, texture)), | 220 base::Bind(ReturnMailbox, context_provider_, texture)), |
221 bounds.size()); | 221 bounds.size()); |
222 compositor->AddObserver(this); | 222 compositor->AddObserver(this); |
223 } | 223 } |
224 | 224 |
225 virtual ~WebGLBench() { | 225 virtual ~WebGLBench() { |
226 webgl_.SetShowPaintedContent(); | 226 webgl_.SetShowSolidColorContent(); |
227 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 227 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
228 gl->DeleteFramebuffers(1, &fbo_); | 228 gl->DeleteFramebuffers(1, &fbo_); |
229 compositor_->RemoveObserver(this); | 229 compositor_->RemoveObserver(this); |
230 } | 230 } |
231 | 231 |
232 virtual void Draw() OVERRIDE { | 232 virtual void Draw() OVERRIDE { |
233 if (do_draw_) { | 233 if (do_draw_) { |
234 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 234 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
235 gl->ClearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f); | 235 gl->ClearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f); |
236 gl->Clear(GL_COLOR_BUFFER_BIT); | 236 gl->Clear(GL_COLOR_BUFFER_BIT); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 ui::PrintLayerHierarchy(host->window()->layer(), gfx::Point(100, 100)); | 364 ui::PrintLayerHierarchy(host->window()->layer(), gfx::Point(100, 100)); |
365 #endif | 365 #endif |
366 | 366 |
367 host->Show(); | 367 host->Show(); |
368 base::MessageLoopForUI::current()->Run(); | 368 base::MessageLoopForUI::current()->Run(); |
369 focus_client.reset(); | 369 focus_client.reset(); |
370 host.reset(); | 370 host.reset(); |
371 | 371 |
372 return 0; | 372 return 0; |
373 } | 373 } |
OLD | NEW |