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

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: add missing InitializeCanvas to FileSurface 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 gfx::Rect bounds(viewport_size_);
38 39
39 gfx::SurfaceFactoryOzone* factory = gfx::SurfaceFactoryOzone::GetInstance(); 40 surface_ozone_->ResizeCanvas(bounds);
40 factory->AttemptToResizeAcceleratedWidget(compositor_->widget(),
41 bounds);
42 41
43 canvas_ = skia::SharePtr(factory->GetCanvasForWidget(realized_widget_)); 42 canvas_ = skia::SharePtr(surface_ozone_->GetCanvas());
44 device_ = skia::SharePtr(canvas_->getDevice()); 43 device_ = skia::SharePtr(canvas_->getDevice());
45 } 44 }
46 45
47 SkCanvas* SoftwareOutputDeviceOzone::BeginPaint(const gfx::Rect& damage_rect) { 46 SkCanvas* SoftwareOutputDeviceOzone::BeginPaint(const gfx::Rect& damage_rect) {
48 DCHECK(gfx::Rect(viewport_size_).Contains(damage_rect)); 47 DCHECK(gfx::Rect(viewport_size_).Contains(damage_rect));
49 48
50 canvas_->clipRect(gfx::RectToSkRect(damage_rect), SkRegion::kReplace_Op); 49 canvas_->clipRect(gfx::RectToSkRect(damage_rect), SkRegion::kReplace_Op);
51 // Save the current state so we can restore once we're done drawing. This is 50 // Save the current state so we can restore once we're done drawing. This is
52 // saved after the clip since we want to keep the clip information after we're 51 // saved after the clip since we want to keep the clip information after we're
53 // done drawing such that OZONE knows what was updated. 52 // done drawing such that OZONE knows what was updated.
54 canvas_->save(); 53 canvas_->save();
55 54
56 return SoftwareOutputDevice::BeginPaint(damage_rect); 55 return SoftwareOutputDevice::BeginPaint(damage_rect);
57 } 56 }
58 57
59 void SoftwareOutputDeviceOzone::EndPaint(cc::SoftwareFrameData* frame_data) { 58 void SoftwareOutputDeviceOzone::EndPaint(cc::SoftwareFrameData* frame_data) {
60 SoftwareOutputDevice::EndPaint(frame_data); 59 SoftwareOutputDevice::EndPaint(frame_data);
61 60
62 canvas_->restore(); 61 canvas_->restore();
63 62
64 if (damage_rect_.IsEmpty()) 63 if (damage_rect_.IsEmpty())
65 return; 64 return;
66 65
67 bool scheduled = gfx::SurfaceFactoryOzone::GetInstance()->SchedulePageFlip( 66 bool scheduled = surface_ozone_->SwapCanvas();
68 compositor_->widget());
69 DCHECK(scheduled) << "Failed to schedule pageflip"; 67 DCHECK(scheduled) << "Failed to schedule pageflip";
70 } 68 }
71 69
72 } // namespace content 70 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698