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