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

Unified Diff: content/browser/renderer_host/software_output_device_win.cc

Issue 15821012: [Aura] Fix software compositing blits to WS_EX_LAYERED windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/software_output_device_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/software_output_device_win.cc
diff --git a/content/browser/renderer_host/software_output_device_win.cc b/content/browser/renderer_host/software_output_device_win.cc
index 29c4542bbc6feabc9a86bc4274c8f8463e1f1f17..c3af6a24cce3451a224a130f87ca7019e0743272 100644
--- a/content/browser/renderer_host/software_output_device_win.cc
+++ b/content/browser/renderer_host/software_output_device_win.cc
@@ -8,16 +8,20 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkDevice.h"
#include "ui/compositor/compositor.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/gdi_util.h"
namespace content {
SoftwareOutputDeviceWin::SoftwareOutputDeviceWin(ui::Compositor* compositor)
- : compositor_(compositor) {
+ : hwnd_(compositor->widget()),
+ is_hwnd_composited_(false) {
// TODO(skaslev) Remove this when crbug.com/180702 is fixed.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- hwnd_ = compositor->widget();
+ LONG style = GetWindowLong(hwnd_, GWL_EXSTYLE);
+ is_hwnd_composited_ = !!(style & WS_EX_COMPOSITED);
}
SoftwareOutputDeviceWin::~SoftwareOutputDeviceWin() {
@@ -27,18 +31,30 @@ SoftwareOutputDeviceWin::~SoftwareOutputDeviceWin() {
void SoftwareOutputDeviceWin::Resize(gfx::Size viewport_size) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- cc::SoftwareOutputDevice::Resize(viewport_size);
+ if (viewport_size_ == viewport_size)
+ return;
+
+ viewport_size_ = viewport_size;
+ contents_.reset(new gfx::Canvas(viewport_size, ui::SCALE_FACTOR_100P, false));
memset(&bitmap_info_, 0, sizeof(bitmap_info_));
gfx::CreateBitmapHeader(viewport_size_.width(), viewport_size_.height(),
&bitmap_info_.bmiHeader);
}
+SkCanvas* SoftwareOutputDeviceWin::BeginPaint(gfx::Rect damage_rect) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(contents_);
+
+ damage_rect_ = damage_rect;
+ return contents_ ? contents_->sk_canvas() : NULL;
+}
+
void SoftwareOutputDeviceWin::EndPaint(cc::SoftwareFrameData* frame_data) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(device_);
+ DCHECK(contents_);
DCHECK(frame_data == NULL);
- if (!device_)
+ if (!contents_)
return;
gfx::Rect rect = damage_rect_;
@@ -46,16 +62,38 @@ void SoftwareOutputDeviceWin::EndPaint(cc::SoftwareFrameData* frame_data) {
if (rect.IsEmpty())
return;
- const SkBitmap& bitmap = device_->accessBitmap(false);
- HDC hdc = ::GetDC(hwnd_);
- gfx::StretchDIBits(hdc,
- rect.x(), rect.y(),
- rect.width(), rect.height(),
- rect.x(), rect.y(),
- rect.width(), rect.height(),
- bitmap.getPixels(),
- &bitmap_info_);
- ::ReleaseDC(hwnd_, hdc);
+ SkCanvas* canvas = contents_->sk_canvas();
+ DCHECK(canvas);
+ if (is_hwnd_composited_) {
+ RECT wr;
+ GetWindowRect(hwnd_, &wr);
+ SIZE size = {wr.right - wr.left, wr.bottom - wr.top};
+ POINT position = {wr.left, wr.top};
+ POINT zero = {0, 0};
+ BLENDFUNCTION blend = {AC_SRC_OVER, 0x00, 0xFF, AC_SRC_ALPHA};
+
+ DWORD style = GetWindowLong(hwnd_, GWL_EXSTYLE);
+ style &= ~WS_EX_COMPOSITED;
+ style |= WS_EX_LAYERED;
+ SetWindowLong(hwnd_, GWL_EXSTYLE, style);
+
+ HDC dib_dc = skia::BeginPlatformPaint(canvas);
+ ::UpdateLayeredWindow(hwnd_, NULL, &position, &size, dib_dc, &zero,
+ RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA);
+ skia::EndPlatformPaint(canvas);
+ } else {
+ SkDevice* device = canvas->getDevice();
+ const SkBitmap& bitmap = device->accessBitmap(false);
+ HDC hdc = ::GetDC(hwnd_);
+ gfx::StretchDIBits(hdc,
+ rect.x(), rect.y(),
+ rect.width(), rect.height(),
+ rect.x(), rect.y(),
+ rect.width(), rect.height(),
+ bitmap.getPixels(),
+ &bitmap_info_);
+ ::ReleaseDC(hwnd_, hdc);
+ }
}
} // namespace content
« no previous file with comments | « content/browser/renderer_host/software_output_device_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698