| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 explicit ColoredLayer(SkColor color) | 53 explicit ColoredLayer(SkColor color) |
| 54 : Layer(ui::LAYER_TEXTURED), | 54 : Layer(ui::LAYER_TEXTURED), |
| 55 color_(color), | 55 color_(color), |
| 56 draw_(true) { | 56 draw_(true) { |
| 57 set_delegate(this); | 57 set_delegate(this); |
| 58 } | 58 } |
| 59 | 59 |
| 60 virtual ~ColoredLayer() {} | 60 virtual ~ColoredLayer() {} |
| 61 | 61 |
| 62 // Overridden from LayerDelegate: | 62 // Overridden from LayerDelegate: |
| 63 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { | 63 virtual void OnPaintLayer(gfx::Canvas* canvas) override { |
| 64 if (draw_) { | 64 if (draw_) { |
| 65 canvas->DrawColor(color_); | 65 canvas->DrawColor(color_); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 virtual void OnDelegatedFrameDamage( | 69 virtual void OnDelegatedFrameDamage( |
| 70 const gfx::Rect& damage_rect_in_dip) OVERRIDE {} | 70 const gfx::Rect& damage_rect_in_dip) override {} |
| 71 | 71 |
| 72 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE { | 72 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) override { |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE { | 75 virtual base::Closure PrepareForLayerBoundsChange() override { |
| 76 return base::Closure(); | 76 return base::Closure(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void set_color(SkColor color) { color_ = color; } | 79 void set_color(SkColor color) { color_ = color; } |
| 80 void set_draw(bool draw) { draw_ = draw; } | 80 void set_draw(bool draw) { draw_ = draw; } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 SkColor color_; | 83 SkColor color_; |
| 84 bool draw_; | 84 bool draw_; |
| 85 | 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(ColoredLayer); | 86 DISALLOW_COPY_AND_ASSIGN(ColoredLayer); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 const int kFrames = 100; | 89 const int kFrames = 100; |
| 90 | 90 |
| 91 // Benchmark base class, hooks up drawing callback and displaying FPS. | 91 // Benchmark base class, hooks up drawing callback and displaying FPS. |
| 92 class BenchCompositorObserver : public ui::CompositorObserver { | 92 class BenchCompositorObserver : public ui::CompositorObserver { |
| 93 public: | 93 public: |
| 94 explicit BenchCompositorObserver(int max_frames) | 94 explicit BenchCompositorObserver(int max_frames) |
| 95 : start_time_(), | 95 : start_time_(), |
| 96 frames_(0), | 96 frames_(0), |
| 97 max_frames_(max_frames) { | 97 max_frames_(max_frames) { |
| 98 } | 98 } |
| 99 | 99 |
| 100 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE {} | 100 virtual void OnCompositingDidCommit(ui::Compositor* compositor) override {} |
| 101 | 101 |
| 102 virtual void OnCompositingStarted(Compositor* compositor, | 102 virtual void OnCompositingStarted(Compositor* compositor, |
| 103 base::TimeTicks start_time) OVERRIDE {} | 103 base::TimeTicks start_time) override {} |
| 104 | 104 |
| 105 virtual void OnCompositingEnded(Compositor* compositor) OVERRIDE { | 105 virtual void OnCompositingEnded(Compositor* compositor) override { |
| 106 if (start_time_.is_null()) { | 106 if (start_time_.is_null()) { |
| 107 start_time_ = TimeTicks::Now(); | 107 start_time_ = TimeTicks::Now(); |
| 108 } else { | 108 } else { |
| 109 ++frames_; | 109 ++frames_; |
| 110 if (frames_ % kFrames == 0) { | 110 if (frames_ % kFrames == 0) { |
| 111 TimeTicks now = TimeTicks::Now(); | 111 TimeTicks now = TimeTicks::Now(); |
| 112 double ms = (now - start_time_).InMillisecondsF() / kFrames; | 112 double ms = (now - start_time_).InMillisecondsF() / kFrames; |
| 113 LOG(INFO) << "FPS: " << 1000.f / ms << " (" << ms << " ms)"; | 113 LOG(INFO) << "FPS: " << 1000.f / ms << " (" << ms << " ms)"; |
| 114 start_time_ = now; | 114 start_time_ = now; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 if (max_frames_ && frames_ == max_frames_) { | 117 if (max_frames_ && frames_ == max_frames_) { |
| 118 base::MessageLoop::current()->Quit(); | 118 base::MessageLoop::current()->Quit(); |
| 119 } else { | 119 } else { |
| 120 Draw(); | 120 Draw(); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 virtual void OnCompositingAborted(Compositor* compositor) OVERRIDE {} | 124 virtual void OnCompositingAborted(Compositor* compositor) override {} |
| 125 | 125 |
| 126 virtual void OnCompositingLockStateChanged( | 126 virtual void OnCompositingLockStateChanged( |
| 127 Compositor* compositor) OVERRIDE {} | 127 Compositor* compositor) override {} |
| 128 | 128 |
| 129 virtual void Draw() {} | 129 virtual void Draw() {} |
| 130 | 130 |
| 131 int frames() const { return frames_; } | 131 int frames() const { return frames_; } |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 TimeTicks start_time_; | 134 TimeTicks start_time_; |
| 135 int frames_; | 135 int frames_; |
| 136 int max_frames_; | 136 int max_frames_; |
| 137 | 137 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 compositor->AddObserver(this); | 222 compositor->AddObserver(this); |
| 223 } | 223 } |
| 224 | 224 |
| 225 virtual ~WebGLBench() { | 225 virtual ~WebGLBench() { |
| 226 webgl_.SetShowPaintedContent(); | 226 webgl_.SetShowPaintedContent(); |
| 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); |
| 237 gl->Flush(); | 237 gl->Flush(); |
| 238 } | 238 } |
| 239 webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size())); | 239 webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size())); |
| 240 compositor_->ScheduleDraw(); | 240 compositor_->ScheduleDraw(); |
| 241 } | 241 } |
| 242 | 242 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 266 compositor_(compositor) { | 266 compositor_(compositor) { |
| 267 compositor->AddObserver(this); | 267 compositor->AddObserver(this); |
| 268 layer_->set_draw( | 268 layer_->set_draw( |
| 269 !CommandLine::ForCurrentProcess()->HasSwitch("disable-draw")); | 269 !CommandLine::ForCurrentProcess()->HasSwitch("disable-draw")); |
| 270 } | 270 } |
| 271 | 271 |
| 272 virtual ~SoftwareScrollBench() { | 272 virtual ~SoftwareScrollBench() { |
| 273 compositor_->RemoveObserver(this); | 273 compositor_->RemoveObserver(this); |
| 274 } | 274 } |
| 275 | 275 |
| 276 virtual void Draw() OVERRIDE { | 276 virtual void Draw() override { |
| 277 layer_->set_color( | 277 layer_->set_color( |
| 278 SkColorSetARGBInline(255*(frames() % kFrames)/kFrames, 255, 0, 255)); | 278 SkColorSetARGBInline(255*(frames() % kFrames)/kFrames, 255, 0, 255)); |
| 279 layer_->SchedulePaint(gfx::Rect(layer_->bounds().size())); | 279 layer_->SchedulePaint(gfx::Rect(layer_->bounds().size())); |
| 280 } | 280 } |
| 281 | 281 |
| 282 private: | 282 private: |
| 283 ColoredLayer* layer_; | 283 ColoredLayer* layer_; |
| 284 Compositor* compositor_; | 284 Compositor* compositor_; |
| 285 | 285 |
| 286 DISALLOW_COPY_AND_ASSIGN(SoftwareScrollBench); | 286 DISALLOW_COPY_AND_ASSIGN(SoftwareScrollBench); |
| (...skipping 77 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 |