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

Side by Side Diff: content/browser/compositor/software_output_device_ozone.cc

Issue 205433002: ozone: Add OzoneSurface object that is owned by compositor, GLSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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 | Annotate | Revision Log
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 "content/browser/compositor/software_output_device_ozone.h" 5 #include "content/browser/compositor/software_output_device_ozone.h"
6 #include "third_party/skia/include/core/SkDevice.h" 6 #include "third_party/skia/include/core/SkDevice.h"
7 #include "ui/compositor/compositor.h" 7 #include "ui/compositor/compositor.h"
8 #include "ui/gfx/ozone/surface_factory_ozone.h" 8 #include "ui/gfx/ozone/surface_factory_ozone.h"
9 #include "ui/gfx/ozone/surface_ozone.h"
9 #include "ui/gfx/skia_util.h" 10 #include "ui/gfx/skia_util.h"
10 #include "ui/gfx/vsync_provider.h" 11 #include "ui/gfx/vsync_provider.h"
11 12
12 namespace content { 13 namespace content {
13 14
14 SoftwareOutputDeviceOzone::SoftwareOutputDeviceOzone(ui::Compositor* compositor) 15 SoftwareOutputDeviceOzone::SoftwareOutputDeviceOzone(ui::Compositor* compositor)
15 : compositor_(compositor), realized_widget_(gfx::kNullAcceleratedWidget) { 16 : compositor_(compositor) {
16 gfx::SurfaceFactoryOzone* factory = gfx::SurfaceFactoryOzone::GetInstance(); 17 gfx::SurfaceFactoryOzone* factory = gfx::SurfaceFactoryOzone::GetInstance();
17 18
18 if (factory->InitializeHardware() != gfx::SurfaceFactoryOzone::INITIALIZED) 19 if (factory->InitializeHardware() != gfx::SurfaceFactoryOzone::INITIALIZED)
19 LOG(FATAL) << "Failed to initialize hardware in OZONE"; 20 LOG(FATAL) << "Failed to initialize hardware in OZONE";
20 21
21 realized_widget_ = factory->RealizeAcceleratedWidget(compositor_->widget()); 22 surface_ozone_ = factory->CreateSurfaceForWidget(compositor_->widget());
22 23
23 if (realized_widget_ == gfx::kNullAcceleratedWidget) 24 if (!surface_ozone_->InitializeCanvas())
24 LOG(FATAL) << "Failed to get a realized AcceleratedWidget"; 25 LOG(FATAL) << "Failed to initialize canvas";
25 26
26 vsync_provider_ = factory->CreateVSyncProvider(realized_widget_); 27 vsync_provider_ = surface_ozone_->CreateVSyncProvider();
27 } 28 }
28 29
29 SoftwareOutputDeviceOzone::~SoftwareOutputDeviceOzone() { 30 SoftwareOutputDeviceOzone::~SoftwareOutputDeviceOzone() {
30 } 31 }
31 32
32 void SoftwareOutputDeviceOzone::Resize(const gfx::Size& viewport_size) { 33 void SoftwareOutputDeviceOzone::Resize(const gfx::Size& viewport_size) {
33 if (viewport_size_ == viewport_size) 34 if (viewport_size_ == viewport_size)
34 return; 35 return;
35 36
36 viewport_size_ = viewport_size; 37 viewport_size_ = viewport_size;
37 gfx::Rect bounds(viewport_size_);
38 38
39 gfx::SurfaceFactoryOzone* factory = gfx::SurfaceFactoryOzone::GetInstance(); 39 surface_ozone_->ResizeCanvas(viewport_size_);
40 factory->AttemptToResizeAcceleratedWidget(compositor_->widget(),
41 bounds);
42
43 canvas_ = skia::SharePtr(factory->GetCanvasForWidget(realized_widget_));
44 } 40 }
45 41
46 SkCanvas* SoftwareOutputDeviceOzone::BeginPaint(const gfx::Rect& damage_rect) { 42 SkCanvas* SoftwareOutputDeviceOzone::BeginPaint(const gfx::Rect& damage_rect) {
47 DCHECK(gfx::Rect(viewport_size_).Contains(damage_rect)); 43 DCHECK(gfx::Rect(viewport_size_).Contains(damage_rect));
48 44
45 // Get canvas for next frame.
46 canvas_ = surface_ozone_->GetCanvas();
47
49 canvas_->clipRect(gfx::RectToSkRect(damage_rect), SkRegion::kReplace_Op); 48 canvas_->clipRect(gfx::RectToSkRect(damage_rect), SkRegion::kReplace_Op);
50 // Save the current state so we can restore once we're done drawing. This is 49 // Save the current state so we can restore once we're done drawing. This is
51 // saved after the clip since we want to keep the clip information after we're 50 // saved after the clip since we want to keep the clip information after we're
52 // done drawing such that OZONE knows what was updated. 51 // done drawing such that OZONE knows what was updated.
53 canvas_->save(); 52 canvas_->save();
54 53
55 return SoftwareOutputDevice::BeginPaint(damage_rect); 54 return SoftwareOutputDevice::BeginPaint(damage_rect);
56 } 55 }
57 56
58 void SoftwareOutputDeviceOzone::EndPaint(cc::SoftwareFrameData* frame_data) { 57 void SoftwareOutputDeviceOzone::EndPaint(cc::SoftwareFrameData* frame_data) {
59 SoftwareOutputDevice::EndPaint(frame_data); 58 SoftwareOutputDevice::EndPaint(frame_data);
60 59
61 canvas_->restore(); 60 canvas_->restore();
62 61
63 if (damage_rect_.IsEmpty()) 62 if (damage_rect_.IsEmpty())
64 return; 63 return;
65 64
66 bool scheduled = gfx::SurfaceFactoryOzone::GetInstance()->SchedulePageFlip( 65 bool scheduled = surface_ozone_->PresentCanvas();
67 compositor_->widget()); 66 DCHECK(scheduled) << "Failed to present canvas";
68 DCHECK(scheduled) << "Failed to schedule pageflip";
69 } 67 }
70 68
71 } // namespace content 69 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/software_output_device_ozone.h ('k') | ui/aura/window_tree_host_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698