Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/aura/software_output_device_ozone.h" | 5 #include "content/browser/aura/software_output_device_ozone.h" |
| 6 #include "third_party/skia/include/core/SkBitmapDevice.h" | 6 #include "third_party/skia/include/core/SkBitmapDevice.h" |
| 7 #include "third_party/skia/include/core/SkDevice.h" | 7 #include "third_party/skia/include/core/SkDevice.h" |
| 8 #include "ui/compositor/compositor.h" | 8 #include "ui/compositor/compositor.h" |
| 9 #include "ui/gfx/ozone/surface_factory_ozone.h" | 9 #include "ui/gfx/ozone/surface_factory_ozone.h" |
| 10 #include "ui/gfx/skia_util.h" | 10 #include "ui/gfx/skia_util.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 void SoftwareOutputDeviceOzone::Resize(gfx::Size viewport_size) { | 24 void SoftwareOutputDeviceOzone::Resize(gfx::Size viewport_size) { |
| 25 if (viewport_size_ == viewport_size) | 25 if (viewport_size_ == viewport_size) |
| 26 return; | 26 return; |
| 27 | 27 |
| 28 viewport_size_ = viewport_size; | 28 viewport_size_ = viewport_size; |
| 29 gfx::Rect bounds(viewport_size_); | 29 gfx::Rect bounds(viewport_size_); |
| 30 | 30 |
| 31 gfx::SurfaceFactoryOzone* factory = gfx::SurfaceFactoryOzone::GetInstance(); | 31 gfx::SurfaceFactoryOzone* factory = gfx::SurfaceFactoryOzone::GetInstance(); |
| 32 factory->AttemptToResizeAcceleratedWidget(compositor_->widget(), | 32 factory->AttemptToResizeAcceleratedWidget(compositor_->widget(), |
| 33 bounds); | 33 bounds); |
| 34 gfx::AcceleratedWidget realized_widget = factory->RealizeAcceleratedWidget( | 34 realized_widget_ = factory->RealizeAcceleratedWidget(compositor_->widget()); |
|
piman
2013/11/05 23:32:27
Could this be done at construction time?
| |
| 35 compositor_->widget()); | |
| 36 | 35 |
| 37 if (realized_widget == gfx::kNullAcceleratedWidget) | 36 if (realized_widget_ == gfx::kNullAcceleratedWidget) |
| 38 LOG(FATAL) << "Failed to get a realized AcceleratedWidget"; | 37 LOG(FATAL) << "Failed to get a realized AcceleratedWidget"; |
| 39 | 38 |
| 40 canvas_ = skia::SharePtr(factory->GetCanvasForWidget(realized_widget)); | 39 canvas_ = skia::SharePtr(factory->GetCanvasForWidget(realized_widget_)); |
| 41 device_ = skia::SharePtr(canvas_->getDevice()); | 40 device_ = skia::SharePtr(canvas_->getDevice()); |
| 42 } | 41 } |
| 43 | 42 |
| 44 SkCanvas* SoftwareOutputDeviceOzone::BeginPaint(gfx::Rect damage_rect) { | 43 SkCanvas* SoftwareOutputDeviceOzone::BeginPaint(gfx::Rect damage_rect) { |
| 45 DCHECK(gfx::Rect(viewport_size_).Contains(damage_rect)); | 44 DCHECK(gfx::Rect(viewport_size_).Contains(damage_rect)); |
| 46 | 45 |
| 47 canvas_->clipRect(gfx::RectToSkRect(damage_rect), SkRegion::kReplace_Op); | 46 canvas_->clipRect(gfx::RectToSkRect(damage_rect), SkRegion::kReplace_Op); |
| 48 // Save the current state so we can restore once we're done drawing. This is | 47 // Save the current state so we can restore once we're done drawing. This is |
| 49 // saved after the clip since we want to keep the clip information after we're | 48 // saved after the clip since we want to keep the clip information after we're |
| 50 // done drawing such that OZONE knows what was updated. | 49 // done drawing such that OZONE knows what was updated. |
| 51 canvas_->save(); | 50 canvas_->save(); |
| 52 | 51 |
| 53 return SoftwareOutputDevice::BeginPaint(damage_rect); | 52 return SoftwareOutputDevice::BeginPaint(damage_rect); |
| 54 } | 53 } |
| 55 | 54 |
| 56 void SoftwareOutputDeviceOzone::EndPaint(cc::SoftwareFrameData* frame_data) { | 55 void SoftwareOutputDeviceOzone::EndPaint(cc::SoftwareFrameData* frame_data) { |
| 57 SoftwareOutputDevice::EndPaint(frame_data); | 56 SoftwareOutputDevice::EndPaint(frame_data); |
| 58 | 57 |
| 59 canvas_->restore(); | 58 canvas_->restore(); |
| 60 | 59 |
| 61 if (damage_rect_.IsEmpty()) | 60 if (damage_rect_.IsEmpty()) |
| 62 return; | 61 return; |
| 63 | 62 |
| 64 bool scheduled = gfx::SurfaceFactoryOzone::GetInstance()->SchedulePageFlip( | 63 bool scheduled = gfx::SurfaceFactoryOzone::GetInstance()->SchedulePageFlip( |
| 65 compositor_->widget()); | 64 compositor_->widget()); |
| 66 DCHECK(scheduled) << "Failed to schedule pageflip"; | 65 DCHECK(scheduled) << "Failed to schedule pageflip"; |
| 67 } | 66 } |
| 68 | 67 |
| 68 gfx::VSyncProvider* SoftwareOutputDeviceOzone::GetVSyncProvider() { | |
| 69 return gfx::SurfaceFactoryOzone::GetInstance()->GetVSyncProvider( | |
| 70 realized_widget_); | |
|
piman
2013/11/05 23:32:27
Do we expect different VSyncProvider across calls?
| |
| 71 } | |
| 72 | |
| 69 } // namespace content | 73 } // namespace content |
| OLD | NEW |