| 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 "ui/ozone/demo/software_renderer.h" | 5 #include "ui/ozone/demo/software_renderer.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
| 9 #include "third_party/skia/include/core/SkSurface.h" | 9 #include "third_party/skia/include/core/SkSurface.h" |
| 10 #include "ui/gfx/vsync_provider.h" | 10 #include "ui/gfx/vsync_provider.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 vsync_provider_ = software_surface_->CreateVSyncProvider(); | 42 vsync_provider_ = software_surface_->CreateVSyncProvider(); |
| 43 RenderFrame(); | 43 RenderFrame(); |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void SoftwareRenderer::RenderFrame() { | 47 void SoftwareRenderer::RenderFrame() { |
| 48 TRACE_EVENT0("ozone", "SoftwareRenderer::RenderFrame"); | 48 TRACE_EVENT0("ozone", "SoftwareRenderer::RenderFrame"); |
| 49 | 49 |
| 50 float fraction = NextFraction(); | 50 float fraction = NextFraction(); |
| 51 | 51 |
| 52 skia::RefPtr<SkSurface> surface = software_surface_->GetSurface(); | 52 sk_sp<SkSurface> surface = software_surface_->GetSurface(); |
| 53 | 53 |
| 54 SkColor color = | 54 SkColor color = |
| 55 SkColorSetARGB(0xff, 0, 0xff * fraction, 0xff * (1 - fraction)); | 55 SkColorSetARGB(0xff, 0, 0xff * fraction, 0xff * (1 - fraction)); |
| 56 | 56 |
| 57 surface->getCanvas()->clear(color); | 57 surface->getCanvas()->clear(color); |
| 58 | 58 |
| 59 software_surface_->PresentCanvas(gfx::Rect(size_)); | 59 software_surface_->PresentCanvas(gfx::Rect(size_)); |
| 60 | 60 |
| 61 if (vsync_provider_) { | 61 if (vsync_provider_) { |
| 62 vsync_provider_->GetVSyncParameters( | 62 vsync_provider_->GetVSyncParameters( |
| 63 base::Bind(&SoftwareRenderer::UpdateVSyncParameters, | 63 base::Bind(&SoftwareRenderer::UpdateVSyncParameters, |
| 64 weak_ptr_factory_.GetWeakPtr())); | 64 weak_ptr_factory_.GetWeakPtr())); |
| 65 } | 65 } |
| 66 | 66 |
| 67 timer_.Start(FROM_HERE, vsync_period_, this, &SoftwareRenderer::RenderFrame); | 67 timer_.Start(FROM_HERE, vsync_period_, this, &SoftwareRenderer::RenderFrame); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void SoftwareRenderer::UpdateVSyncParameters(const base::TimeTicks timebase, | 70 void SoftwareRenderer::UpdateVSyncParameters(const base::TimeTicks timebase, |
| 71 const base::TimeDelta interval) { | 71 const base::TimeDelta interval) { |
| 72 vsync_period_ = interval; | 72 vsync_period_ = interval; |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace ui | 75 } // namespace ui |
| OLD | NEW |