Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: ui/ozone/demo/software_renderer.cc

Issue 1171513002: Reland of Revert of ozone: Remove singleton pattern for SurfaceFactoryOzone. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_surface_ozone.cc ('k') | ui/ozone/gpu/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
dshwang 2015/06/05 08:12:02 this line is added.
10 #include "ui/ozone/public/surface_factory_ozone.h" 11 #include "ui/ozone/public/surface_factory_ozone.h"
11 #include "ui/ozone/public/surface_ozone_canvas.h" 12 #include "ui/ozone/public/surface_ozone_canvas.h"
12 13
13 namespace ui { 14 namespace ui {
14 namespace { 15 namespace {
15 16
16 const int kFrameDelayMilliseconds = 16; 17 const int kFrameDelayMilliseconds = 16;
17 18
18 } // namespace 19 } // namespace
19 20
20 SoftwareRenderer::SoftwareRenderer(gfx::AcceleratedWidget widget, 21 SoftwareRenderer::SoftwareRenderer(gfx::AcceleratedWidget widget,
21 const gfx::Size& size) 22 const gfx::Size& size)
22 : RendererBase(widget, size), 23 : RendererBase(widget, size),
23 vsync_period_(base::TimeDelta::FromMilliseconds(kFrameDelayMilliseconds)), 24 vsync_period_(base::TimeDelta::FromMilliseconds(kFrameDelayMilliseconds)),
24 weak_ptr_factory_(this) { 25 weak_ptr_factory_(this) {
25 } 26 }
26 27
27 SoftwareRenderer::~SoftwareRenderer() { 28 SoftwareRenderer::~SoftwareRenderer() {
28 } 29 }
29 30
30 bool SoftwareRenderer::Initialize() { 31 bool SoftwareRenderer::Initialize() {
31 software_surface_ = 32 software_surface_ = ui::OzonePlatform::GetInstance()
32 ui::SurfaceFactoryOzone::GetInstance()->CreateCanvasForWidget(widget_); 33 ->GetSurfaceFactoryOzone()
34 ->CreateCanvasForWidget(widget_);
33 if (!software_surface_) { 35 if (!software_surface_) {
34 LOG(ERROR) << "Failed to create software surface"; 36 LOG(ERROR) << "Failed to create software surface";
35 return false; 37 return false;
36 } 38 }
37 39
38 software_surface_->ResizeCanvas(size_); 40 software_surface_->ResizeCanvas(size_);
39 vsync_provider_ = software_surface_->CreateVSyncProvider(); 41 vsync_provider_ = software_surface_->CreateVSyncProvider();
40 RenderFrame(); 42 RenderFrame();
41 return true; 43 return true;
42 } 44 }
(...skipping 18 matching lines...) Expand all
61 63
62 timer_.Start(FROM_HERE, vsync_period_, this, &SoftwareRenderer::RenderFrame); 64 timer_.Start(FROM_HERE, vsync_period_, this, &SoftwareRenderer::RenderFrame);
63 } 65 }
64 66
65 void SoftwareRenderer::UpdateVSyncParameters(const base::TimeTicks timebase, 67 void SoftwareRenderer::UpdateVSyncParameters(const base::TimeTicks timebase,
66 const base::TimeDelta interval) { 68 const base::TimeDelta interval) {
67 vsync_period_ = interval; 69 vsync_period_ = interval;
68 } 70 }
69 71
70 } // namespace ui 72 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_ozone.cc ('k') | ui/ozone/gpu/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698