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

Side by Side Diff: content/browser/renderer_host/software_output_device_win.cc

Issue 12542006: Implemented browser side software compositing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing review comments. Created 7 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
(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 "base/command_line.h"
8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "third_party/skia/include/core/SkDevice.h"
10 #include "ui/compositor/compositor.h"
11 #include "ui/compositor/compositor_switches.h"
12 #include "ui/gfx/gdi_util.h"
13
14 namespace content {
15
16 SoftwareOutputDevice::SoftwareOutputDevice(ui::Compositor* compositor)
17 : compositor_(compositor) {
18 // TODO Remove this when crbug.com/180702 is fixed
19 CHECK(!CommandLine::ForCurrentProcess()->HasSwitch(
20 switches::kUIEnableThreadedCompositing));
21 hdc_ = ::GetWindowDC(compositor->widget());
22 }
23
24 SoftwareOutputDevice::~SoftwareOutputDevice() {
25 ::ReleaseDC(compositor_->widget(), hdc_);
26 }
27
28 void SoftwareOutputDevice::Resize(const gfx::Size& viewport_size) {
29 cc::SoftwareOutputDevice::Resize(viewport_size);
30 gfx::CreateBitmapHeader(viewport_size_.width(),
31 viewport_size_.height(), &bitmap_header_);
32 }
33
34 void SoftwareOutputDevice::EndPaint(cc::SoftwareFrameData* frame_data) {
35 DCHECK(device_);
36 DCHECK(frame_data == NULL);
37
38 if (!device_)
39 return;
40
41 gfx::Rect rect = damage_rect_;
42 rect.Intersect(gfx::Rect(viewport_size_));
43 if (rect.IsEmpty())
44 return;
45
46 const SkBitmap& bitmap = device_->accessBitmap(false);
47 gfx::StretchDIBits(hdc_,
48 rect.x(), rect.y(),
49 rect.width(), rect.height(),
50 rect.x(), rect.y(),
51 rect.width(), rect.height(),
52 bitmap.getPixels(),
53 reinterpret_cast<BITMAPINFO*>(&bitmap_header_));
54 }
55
56 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698