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

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

Issue 2610323004: Remove skia::DrawToNativeContext() (Closed)
Patch Set: missing header Created 3 years, 11 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 | skia/ext/bitmap_platform_device_win.cc » ('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 "ui/compositor/compositor.h" 13 #include "ui/compositor/compositor.h"
13 #include "ui/gfx/gdi_util.h" 14 #include "ui/gfx/gdi_util.h"
14 #include "ui/gfx/skia_util.h" 15 #include "ui/gfx/skia_util.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 // If a window is larger than this in bytes, don't even try to create a 19 // If a window is larger than this in bytes, don't even try to create a
19 // backing bitmap for it. 20 // backing bitmap for it.
20 static const size_t kMaxBitmapSizeBytes = 4 * (16384 * 8192); 21 static const size_t kMaxBitmapSizeBytes = 4 * (16384 * 8192);
21 22
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 SoftwareOutputDevice::EndPaint(); 159 SoftwareOutputDevice::EndPaint();
159 160
160 if (!contents_) 161 if (!contents_)
161 return; 162 return;
162 163
163 gfx::Rect rect = damage_rect_; 164 gfx::Rect rect = damage_rect_;
164 rect.Intersect(gfx::Rect(viewport_pixel_size_)); 165 rect.Intersect(gfx::Rect(viewport_pixel_size_));
165 if (rect.IsEmpty()) 166 if (rect.IsEmpty())
166 return; 167 return;
167 168
169 HDC dib_dc = skia::GetNativeDrawingContext(contents_.get());
170
168 if (is_hwnd_composited_) { 171 if (is_hwnd_composited_) {
169 RECT wr; 172 RECT wr;
170 GetWindowRect(hwnd_, &wr); 173 GetWindowRect(hwnd_, &wr);
171 SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; 174 SIZE size = {wr.right - wr.left, wr.bottom - wr.top};
172 POINT position = {wr.left, wr.top}; 175 POINT position = {wr.left, wr.top};
173 POINT zero = {0, 0}; 176 POINT zero = {0, 0};
174 BLENDFUNCTION blend = {AC_SRC_OVER, 0x00, 0xFF, AC_SRC_ALPHA}; 177 BLENDFUNCTION blend = {AC_SRC_OVER, 0x00, 0xFF, AC_SRC_ALPHA};
175 178
176 DWORD style = GetWindowLong(hwnd_, GWL_EXSTYLE); 179 DWORD style = GetWindowLong(hwnd_, GWL_EXSTYLE);
177 style &= ~WS_EX_COMPOSITED; 180 style &= ~WS_EX_COMPOSITED;
178 style |= WS_EX_LAYERED; 181 style |= WS_EX_LAYERED;
179 SetWindowLong(hwnd_, GWL_EXSTYLE, style); 182 SetWindowLong(hwnd_, GWL_EXSTYLE, style);
180 183
181 HDC dib_dc = skia::GetNativeDrawingContext(contents_.get());
182 ::UpdateLayeredWindow(hwnd_, NULL, &position, &size, dib_dc, &zero, 184 ::UpdateLayeredWindow(hwnd_, NULL, &position, &size, dib_dc, &zero,
183 RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA); 185 RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA);
184 } else { 186 } else {
185 HDC hdc = ::GetDC(hwnd_); 187 HDC hdc = ::GetDC(hwnd_);
186 RECT src_rect = rect.ToRECT(); 188 RECT src_rect = rect.ToRECT();
187 skia::DrawToNativeContext(contents_.get(), hdc, rect.x(), rect.y(), 189 skia::CopyHDC(dib_dc,
188 &src_rect); 190 hdc,
191 rect.x(),
192 rect.y(),
193 contents_.get()->imageInfo().isOpaque(),
194 src_rect,
195 contents_.get()->getTotalMatrix());
196
189 ::ReleaseDC(hwnd_, hdc); 197 ::ReleaseDC(hwnd_, hdc);
190 } 198 }
191 } 199 }
192 200
193 void SoftwareOutputDeviceWin::ReleaseContents() { 201 void SoftwareOutputDeviceWin::ReleaseContents() {
194 DCHECK(!in_paint_); 202 DCHECK(!in_paint_);
195 contents_.reset(); 203 contents_.reset();
196 } 204 }
197 205
198 } // namespace content 206 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698