OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/software_output_device.h" |
| 6 |
| 7 #include "third_party/skia/include/core/SkBitmap.h" |
| 8 #include "third_party/skia/include/core/SkDevice.h" |
| 9 #include "ui/compositor/compositor.h" |
| 10 #include "ui/gfx/gdi_util.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 SoftwareOutputDevice::SoftwareOutputDevice(ui::Compositor* compositor) |
| 15 : compositor_(compositor) { |
| 16 hdc_ = ::GetWindowDC(compositor->widget()); |
| 17 } |
| 18 |
| 19 SoftwareOutputDevice::~SoftwareOutputDevice() { |
| 20 ::ReleaseDC(compositor_->widget(), hdc_); |
| 21 } |
| 22 |
| 23 void SoftwareOutputDevice::Resize(const gfx::Size& viewport_size) { |
| 24 SoftwareOutputDeviceImpl::Resize(viewport_size); |
| 25 gfx::CreateBitmapHeader(viewport_size_.width(), |
| 26 viewport_size_.height(), &bitmap_header_); |
| 27 } |
| 28 |
| 29 void SoftwareOutputDevice::EndPaint(const gfx::Rect& damage_rect) { |
| 30 if (!device_) |
| 31 return; |
| 32 |
| 33 const SkBitmap& bitmap = device_->accessBitmap(false); |
| 34 gfx::StretchDIBits(hdc_, |
| 35 damage_rect.x(), damage_rect.y(), |
| 36 damage_rect.width(), damage_rect.height(), |
| 37 damage_rect.x(), damage_rect.y(), |
| 38 damage_rect.width(), damage_rect.height(), |
| 39 bitmap.getPixels(), |
| 40 reinterpret_cast<BITMAPINFO*>(&bitmap_header_)); |
| 41 } |
| 42 |
| 43 } // namespace content |
OLD | NEW |