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 cc::SoftwareOutputDevice::Resize(viewport_size); |
| 25 gfx::CreateBitmapHeader(viewport_size_.width(), |
| 26 viewport_size_.height(), &bitmap_header_); |
| 27 } |
| 28 |
| 29 void SoftwareOutputDevice::EndPaint(cc::SoftwareFrameData* frame_data) { |
| 30 DCHECK(device_); |
| 31 DCHECK(frame_data == NULL); |
| 32 |
| 33 if (!device_) |
| 34 return; |
| 35 |
| 36 gfx::Rect rect = damage_rect_; |
| 37 rect.Intersect(gfx::Rect(viewport_size_)); |
| 38 if (rect.IsEmpty()) |
| 39 return; |
| 40 |
| 41 const SkBitmap& bitmap = device_->accessBitmap(false); |
| 42 gfx::StretchDIBits(hdc_, |
| 43 rect.x(), rect.y(), |
| 44 rect.width(), rect.height(), |
| 45 rect.x(), rect.y(), |
| 46 rect.width(), rect.height(), |
| 47 bitmap.getPixels(), |
| 48 reinterpret_cast<BITMAPINFO*>(&bitmap_header_)); |
| 49 } |
| 50 |
| 51 } // namespace content |
OLD | NEW |