| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 WebGLBench(ui::ContextFactory* context_factory, | 151 WebGLBench(ui::ContextFactory* context_factory, |
| 152 Layer* parent, | 152 Layer* parent, |
| 153 Compositor* compositor, | 153 Compositor* compositor, |
| 154 int max_frames) | 154 int max_frames) |
| 155 : BenchCompositorObserver(max_frames), | 155 : BenchCompositorObserver(max_frames), |
| 156 parent_(parent), | 156 parent_(parent), |
| 157 webgl_(ui::LAYER_SOLID_COLOR), | 157 webgl_(ui::LAYER_SOLID_COLOR), |
| 158 compositor_(compositor), | 158 compositor_(compositor), |
| 159 fbo_(0), | 159 fbo_(0), |
| 160 do_draw_(true) { | 160 do_draw_(true) { |
| 161 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 161 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 162 do_draw_ = !command_line->HasSwitch("disable-draw"); | 162 do_draw_ = !command_line->HasSwitch("disable-draw"); |
| 163 | 163 |
| 164 std::string webgl_size = command_line->GetSwitchValueASCII("webgl-size"); | 164 std::string webgl_size = command_line->GetSwitchValueASCII("webgl-size"); |
| 165 int width = 0; | 165 int width = 0; |
| 166 int height = 0; | 166 int height = 0; |
| 167 if (!webgl_size.empty()) { | 167 if (!webgl_size.empty()) { |
| 168 std::vector<std::string> split_size; | 168 std::vector<std::string> split_size; |
| 169 base::SplitString(webgl_size, 'x', &split_size); | 169 base::SplitString(webgl_size, 'x', &split_size); |
| 170 if (split_size.size() == 2) { | 170 if (split_size.size() == 2) { |
| 171 width = atoi(split_size[0].c_str()); | 171 width = atoi(split_size[0].c_str()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 class SoftwareScrollBench : public BenchCompositorObserver { | 256 class SoftwareScrollBench : public BenchCompositorObserver { |
| 257 public: | 257 public: |
| 258 SoftwareScrollBench(ColoredLayer* layer, | 258 SoftwareScrollBench(ColoredLayer* layer, |
| 259 Compositor* compositor, | 259 Compositor* compositor, |
| 260 int max_frames) | 260 int max_frames) |
| 261 : BenchCompositorObserver(max_frames), | 261 : BenchCompositorObserver(max_frames), |
| 262 layer_(layer), | 262 layer_(layer), |
| 263 compositor_(compositor) { | 263 compositor_(compositor) { |
| 264 compositor->AddObserver(this); | 264 compositor->AddObserver(this); |
| 265 layer_->set_draw( | 265 layer_->set_draw( |
| 266 !CommandLine::ForCurrentProcess()->HasSwitch("disable-draw")); | 266 !base::CommandLine::ForCurrentProcess()->HasSwitch("disable-draw")); |
| 267 } | 267 } |
| 268 | 268 |
| 269 ~SoftwareScrollBench() override { compositor_->RemoveObserver(this); } | 269 ~SoftwareScrollBench() override { compositor_->RemoveObserver(this); } |
| 270 | 270 |
| 271 void Draw() override { | 271 void Draw() override { |
| 272 layer_->set_color( | 272 layer_->set_color( |
| 273 SkColorSetARGBInline(255*(frames() % kFrames)/kFrames, 255, 0, 255)); | 273 SkColorSetARGBInline(255*(frames() % kFrames)/kFrames, 255, 0, 255)); |
| 274 layer_->SchedulePaint(gfx::Rect(layer_->bounds().size())); | 274 layer_->SchedulePaint(gfx::Rect(layer_->bounds().size())); |
| 275 } | 275 } |
| 276 | 276 |
| 277 private: | 277 private: |
| 278 ColoredLayer* layer_; | 278 ColoredLayer* layer_; |
| 279 Compositor* compositor_; | 279 Compositor* compositor_; |
| 280 | 280 |
| 281 DISALLOW_COPY_AND_ASSIGN(SoftwareScrollBench); | 281 DISALLOW_COPY_AND_ASSIGN(SoftwareScrollBench); |
| 282 }; | 282 }; |
| 283 | 283 |
| 284 } // namespace | 284 } // namespace |
| 285 | 285 |
| 286 int main(int argc, char** argv) { | 286 int main(int argc, char** argv) { |
| 287 CommandLine::Init(argc, argv); | 287 base::CommandLine::Init(argc, argv); |
| 288 | 288 |
| 289 base::AtExitManager exit_manager; | 289 base::AtExitManager exit_manager; |
| 290 | 290 |
| 291 #if defined(USE_X11) | 291 #if defined(USE_X11) |
| 292 // This demo uses InProcessContextFactory which uses X on a separate Gpu | 292 // This demo uses InProcessContextFactory which uses X on a separate Gpu |
| 293 // thread. | 293 // thread. |
| 294 gfx::InitializeThreadedX11(); | 294 gfx::InitializeThreadedX11(); |
| 295 #endif | 295 #endif |
| 296 | 296 |
| 297 gfx::GLSurface::InitializeOneOff(); | 297 gfx::GLSurface::InitializeOneOff(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 322 ColoredLayer background(SK_ColorRED); | 322 ColoredLayer background(SK_ColorRED); |
| 323 background.SetBounds(host->window()->bounds()); | 323 background.SetBounds(host->window()->bounds()); |
| 324 host->window()->layer()->Add(&background); | 324 host->window()->layer()->Add(&background); |
| 325 | 325 |
| 326 ColoredLayer window(SK_ColorBLUE); | 326 ColoredLayer window(SK_ColorBLUE); |
| 327 window.SetBounds(gfx::Rect(background.bounds().size())); | 327 window.SetBounds(gfx::Rect(background.bounds().size())); |
| 328 background.Add(&window); | 328 background.Add(&window); |
| 329 | 329 |
| 330 Layer content_layer(ui::LAYER_NOT_DRAWN); | 330 Layer content_layer(ui::LAYER_NOT_DRAWN); |
| 331 | 331 |
| 332 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 332 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 333 bool force = command_line->HasSwitch("force-render-surface"); | 333 bool force = command_line->HasSwitch("force-render-surface"); |
| 334 content_layer.SetForceRenderSurface(force); | 334 content_layer.SetForceRenderSurface(force); |
| 335 gfx::Rect bounds(window.bounds().size()); | 335 gfx::Rect bounds(window.bounds().size()); |
| 336 bounds.Inset(0, 30, 0, 0); | 336 bounds.Inset(0, 30, 0, 0); |
| 337 content_layer.SetBounds(bounds); | 337 content_layer.SetBounds(bounds); |
| 338 window.Add(&content_layer); | 338 window.Add(&content_layer); |
| 339 | 339 |
| 340 ColoredLayer page_background(SK_ColorWHITE); | 340 ColoredLayer page_background(SK_ColorWHITE); |
| 341 page_background.SetBounds(gfx::Rect(content_layer.bounds().size())); | 341 page_background.SetBounds(gfx::Rect(content_layer.bounds().size())); |
| 342 content_layer.Add(&page_background); | 342 content_layer.Add(&page_background); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 359 ui::PrintLayerHierarchy(host->window()->layer(), gfx::Point(100, 100)); | 359 ui::PrintLayerHierarchy(host->window()->layer(), gfx::Point(100, 100)); |
| 360 #endif | 360 #endif |
| 361 | 361 |
| 362 host->Show(); | 362 host->Show(); |
| 363 base::MessageLoopForUI::current()->Run(); | 363 base::MessageLoopForUI::current()->Run(); |
| 364 focus_client.reset(); | 364 focus_client.reset(); |
| 365 host.reset(); | 365 host.reset(); |
| 366 | 366 |
| 367 return 0; | 367 return 0; |
| 368 } | 368 } |
| OLD | NEW |