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

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

Issue 2826343002: Remove use of WS_EX_COMPOSITED for translucent windows. (Closed)
Patch Set: post-review changes Created 3 years, 8 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
« no previous file with comments | « no previous file | ui/base/win/internal_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/debug/alias.h" 7 #include "base/debug/alias.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "cc/resources/shared_bitmap.h" 9 #include "cc/resources/shared_bitmap.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "skia/ext/platform_canvas.h" 11 #include "skia/ext/platform_canvas.h"
12 #include "skia/ext/skia_utils_win.h" 12 #include "skia/ext/skia_utils_win.h"
13 #include "ui/base/win/internal_constants.h"
13 #include "ui/compositor/compositor.h" 14 #include "ui/compositor/compositor.h"
14 #include "ui/gfx/gdi_util.h" 15 #include "ui/gfx/gdi_util.h"
15 #include "ui/gfx/skia_util.h" 16 #include "ui/gfx/skia_util.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 // If a window is larger than this in bytes, don't even try to create a 20 // If a window is larger than this in bytes, don't even try to create a
20 // backing bitmap for it. 21 // backing bitmap for it.
21 static const size_t kMaxBitmapSizeBytes = 4 * (16384 * 8192); 22 static const size_t kMaxBitmapSizeBytes = 4 * (16384 * 8192);
22 23
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 87 }
87 88
88 SoftwareOutputDeviceWin::SoftwareOutputDeviceWin(OutputDeviceBacking* backing, 89 SoftwareOutputDeviceWin::SoftwareOutputDeviceWin(OutputDeviceBacking* backing,
89 ui::Compositor* compositor) 90 ui::Compositor* compositor)
90 : hwnd_(compositor->widget()), 91 : hwnd_(compositor->widget()),
91 is_hwnd_composited_(false), 92 is_hwnd_composited_(false),
92 backing_(backing), 93 backing_(backing),
93 in_paint_(false) { 94 in_paint_(false) {
94 DCHECK_CURRENTLY_ON(BrowserThread::UI); 95 DCHECK_CURRENTLY_ON(BrowserThread::UI);
95 96
96 LONG style = GetWindowLong(hwnd_, GWL_EXSTYLE); 97 is_hwnd_composited_ = !!::GetProp(hwnd_, ui::kWindowTranslucent);
97 is_hwnd_composited_ = !!(style & WS_EX_COMPOSITED);
98 // Layered windows must be completely updated every time, so they can't 98 // Layered windows must be completely updated every time, so they can't
99 // share contents with other windows. 99 // share contents with other windows.
100 if (is_hwnd_composited_) 100 if (is_hwnd_composited_)
101 backing_ = nullptr; 101 backing_ = nullptr;
102 if (backing_) 102 if (backing_)
103 backing_->RegisterOutputDevice(this); 103 backing_->RegisterOutputDevice(this);
104 } 104 }
105 105
106 SoftwareOutputDeviceWin::~SoftwareOutputDeviceWin() { 106 SoftwareOutputDeviceWin::~SoftwareOutputDeviceWin() {
107 DCHECK_CURRENTLY_ON(BrowserThread::UI); 107 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 if (is_hwnd_composited_) { 171 if (is_hwnd_composited_) {
172 RECT wr; 172 RECT wr;
173 GetWindowRect(hwnd_, &wr); 173 GetWindowRect(hwnd_, &wr);
174 SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; 174 SIZE size = {wr.right - wr.left, wr.bottom - wr.top};
175 POINT position = {wr.left, wr.top}; 175 POINT position = {wr.left, wr.top};
176 POINT zero = {0, 0}; 176 POINT zero = {0, 0};
177 BLENDFUNCTION blend = {AC_SRC_OVER, 0x00, 0xFF, AC_SRC_ALPHA}; 177 BLENDFUNCTION blend = {AC_SRC_OVER, 0x00, 0xFF, AC_SRC_ALPHA};
178 178
179 DWORD style = GetWindowLong(hwnd_, GWL_EXSTYLE); 179 DWORD style = GetWindowLong(hwnd_, GWL_EXSTYLE);
180 style &= ~WS_EX_COMPOSITED; 180 DCHECK(!(style & WS_EX_COMPOSITED));
181 style |= WS_EX_LAYERED; 181 style |= WS_EX_LAYERED;
182 SetWindowLong(hwnd_, GWL_EXSTYLE, style); 182 SetWindowLong(hwnd_, GWL_EXSTYLE, style);
183 183
184 ::UpdateLayeredWindow(hwnd_, NULL, &position, &size, dib_dc, &zero, 184 ::UpdateLayeredWindow(hwnd_, NULL, &position, &size, dib_dc, &zero,
185 RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA); 185 RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA);
186 } else { 186 } else {
187 HDC hdc = ::GetDC(hwnd_); 187 HDC hdc = ::GetDC(hwnd_);
188 RECT src_rect = rect.ToRECT(); 188 RECT src_rect = rect.ToRECT();
189 skia::CopyHDC(dib_dc, 189 skia::CopyHDC(dib_dc,
190 hdc, 190 hdc,
191 rect.x(), 191 rect.x(),
192 rect.y(), 192 rect.y(),
193 contents_.get()->imageInfo().isOpaque(), 193 contents_.get()->imageInfo().isOpaque(),
194 src_rect, 194 src_rect,
195 contents_.get()->getTotalMatrix()); 195 contents_.get()->getTotalMatrix());
196 196
197 ::ReleaseDC(hwnd_, hdc); 197 ::ReleaseDC(hwnd_, hdc);
198 } 198 }
199 } 199 }
200 200
201 void SoftwareOutputDeviceWin::ReleaseContents() { 201 void SoftwareOutputDeviceWin::ReleaseContents() {
202 DCHECK(!in_paint_); 202 DCHECK(!in_paint_);
203 contents_.reset(); 203 contents_.reset();
204 } 204 }
205 205
206 } // namespace content 206 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/base/win/internal_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698