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

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: Removed reninterpret_casts 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_win.h"
6
7 #include "content/public/browser/browser_thread.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/gfx/gdi_util.h"
12
13 namespace content {
14
15 SoftwareOutputDeviceWin::SoftwareOutputDeviceWin(ui::Compositor* compositor)
16 : compositor_(compositor) {
17 // TODO(skaslev) Remove this when crbug.com/180702 is fixed.
18 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
19
20 hdc_ = ::GetWindowDC(compositor->widget());
21 }
22
23 SoftwareOutputDeviceWin::~SoftwareOutputDeviceWin() {
24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
25
26 ::ReleaseDC(compositor_->widget(), hdc_);
27 }
28
29 void SoftwareOutputDeviceWin::Resize(const gfx::Size& viewport_size) {
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
31
32 cc::SoftwareOutputDevice::Resize(viewport_size);
33 memset(&bitmap_info_, 0, sizeof(bitmap_info_));
34 gfx::CreateBitmapHeader(viewport_size_.width(), viewport_size_.height(),
35 &bitmap_info_.bmiHeader);
36 }
37
38 void SoftwareOutputDeviceWin::EndPaint(cc::SoftwareFrameData* frame_data) {
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
40 DCHECK(device_);
41 DCHECK(frame_data == NULL);
42
43 if (!device_)
44 return;
45
46 gfx::Rect rect = damage_rect_;
47 rect.Intersect(gfx::Rect(viewport_size_));
48 if (rect.IsEmpty())
49 return;
50
51 const SkBitmap& bitmap = device_->accessBitmap(false);
52 gfx::StretchDIBits(hdc_,
53 rect.x(), rect.y(),
54 rect.width(), rect.height(),
55 rect.x(), rect.y(),
56 rect.width(), rect.height(),
57 bitmap.getPixels(),
58 &bitmap_info_);
59 }
60
61 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/software_output_device_win.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698