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

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

Issue 297573003: Make delegated software renderer work on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebas Created 6 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/compositor/software_output_device_win.h" 5 #include "content/browser/compositor/software_output_device_win.h"
6 6
7 #include "content/public/browser/browser_thread.h" 7 #include "content/public/browser/browser_thread.h"
8 #include "third_party/skia/include/core/SkBitmap.h" 8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "third_party/skia/include/core/SkDevice.h" 9 #include "third_party/skia/include/core/SkDevice.h"
10 #include "ui/compositor/compositor.h" 10 #include "ui/compositor/compositor.h"
(...skipping 11 matching lines...) Expand all
22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
23 23
24 LONG style = GetWindowLong(hwnd_, GWL_EXSTYLE); 24 LONG style = GetWindowLong(hwnd_, GWL_EXSTYLE);
25 is_hwnd_composited_ = !!(style & WS_EX_COMPOSITED); 25 is_hwnd_composited_ = !!(style & WS_EX_COMPOSITED);
26 } 26 }
27 27
28 SoftwareOutputDeviceWin::~SoftwareOutputDeviceWin() { 28 SoftwareOutputDeviceWin::~SoftwareOutputDeviceWin() {
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
30 } 30 }
31 31
32 void SoftwareOutputDeviceWin::Resize(const gfx::Size& viewport_size) { 32 void SoftwareOutputDeviceWin::Resize(const gfx::Size& viewport_pixel_size,
33 float scale_factor) {
33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
34 35
35 if (viewport_size_ == viewport_size) 36 scale_factor_ = scale_factor;
37
38 if (viewport_pixel_size_ == viewport_pixel_size)
36 return; 39 return;
37 40
38 viewport_size_ = viewport_size; 41 viewport_pixel_size_ = viewport_pixel_size;
39 contents_.reset(new gfx::Canvas(viewport_size, 1.0f, true)); 42 contents_.reset(new gfx::Canvas(viewport_pixel_size, 1.0f, true));
40 memset(&bitmap_info_, 0, sizeof(bitmap_info_)); 43 memset(&bitmap_info_, 0, sizeof(bitmap_info_));
41 gfx::CreateBitmapHeader(viewport_size_.width(), viewport_size_.height(), 44 gfx::CreateBitmapHeader(viewport_pixel_size_.width(),
45 viewport_pixel_size_.height(),
42 &bitmap_info_.bmiHeader); 46 &bitmap_info_.bmiHeader);
43 } 47 }
44 48
45 SkCanvas* SoftwareOutputDeviceWin::BeginPaint(const gfx::Rect& damage_rect) { 49 SkCanvas* SoftwareOutputDeviceWin::BeginPaint(const gfx::Rect& damage_rect) {
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
47 DCHECK(contents_); 51 DCHECK(contents_);
48 52
49 damage_rect_ = damage_rect; 53 damage_rect_ = damage_rect;
50 return contents_ ? contents_->sk_canvas() : NULL; 54 return contents_ ? contents_->sk_canvas() : NULL;
51 } 55 }
52 56
53 void SoftwareOutputDeviceWin::EndPaint(cc::SoftwareFrameData* frame_data) { 57 void SoftwareOutputDeviceWin::EndPaint(cc::SoftwareFrameData* frame_data) {
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
55 DCHECK(contents_); 59 DCHECK(contents_);
56 DCHECK(frame_data); 60 DCHECK(frame_data);
57 61
58 if (!contents_) 62 if (!contents_)
59 return; 63 return;
60 64
61 SoftwareOutputDevice::EndPaint(frame_data); 65 SoftwareOutputDevice::EndPaint(frame_data);
62 66
63 gfx::Rect rect = damage_rect_; 67 gfx::Rect rect = damage_rect_;
64 rect.Intersect(gfx::Rect(viewport_size_)); 68 rect.Intersect(gfx::Rect(viewport_pixel_size_));
65 if (rect.IsEmpty()) 69 if (rect.IsEmpty())
66 return; 70 return;
67 71
68 SkCanvas* canvas = contents_->sk_canvas(); 72 SkCanvas* canvas = contents_->sk_canvas();
69 DCHECK(canvas); 73 DCHECK(canvas);
70 if (is_hwnd_composited_) { 74 if (is_hwnd_composited_) {
71 RECT wr; 75 RECT wr;
72 GetWindowRect(hwnd_, &wr); 76 GetWindowRect(hwnd_, &wr);
73 SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; 77 SIZE size = {wr.right - wr.left, wr.bottom - wr.top};
74 POINT position = {wr.left, wr.top}; 78 POINT position = {wr.left, wr.top};
(...skipping 19 matching lines...) Expand all
94 98
95 void SoftwareOutputDeviceWin::CopyToPixels(const gfx::Rect& rect, 99 void SoftwareOutputDeviceWin::CopyToPixels(const gfx::Rect& rect,
96 void* pixels) { 100 void* pixels) {
97 DCHECK(contents_); 101 DCHECK(contents_);
98 SkImageInfo info = SkImageInfo::MakeN32Premul(rect.width(), rect.height()); 102 SkImageInfo info = SkImageInfo::MakeN32Premul(rect.width(), rect.height());
99 contents_->sk_canvas()->readPixels( 103 contents_->sk_canvas()->readPixels(
100 info, pixels, info.minRowBytes(), rect.x(), rect.y()); 104 info, pixels, info.minRowBytes(), rect.x(), rect.y());
101 } 105 }
102 106
103 } // namespace content 107 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/software_output_device_win.h ('k') | content/browser/compositor/software_output_device_x11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698