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

Side by Side Diff: ui/gfx/icon_util.cc

Issue 2423293003: Bug Fix: Cursor Stretched During Tab Capturing On Windows (Closed)
Patch Set: nit Created 4 years, 2 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gfx/icon_util.h" 5 #include "ui/gfx/icon_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/important_file_writer.h" 10 #include "base/files/important_file_writer.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 ScopedICONINFO icon_info; 305 ScopedICONINFO icon_info;
306 BITMAP bitmap_info = { 0 }; 306 BITMAP bitmap_info = { 0 };
307 307
308 if (!::GetIconInfo(icon, &icon_info)) 308 if (!::GetIconInfo(icon, &icon_info))
309 return NULL; 309 return NULL;
310 310
311 if (!::GetObject(icon_info.hbmMask, sizeof(bitmap_info), &bitmap_info)) 311 if (!::GetObject(icon_info.hbmMask, sizeof(bitmap_info), &bitmap_info))
312 return NULL; 312 return NULL;
313 313
314 gfx::Size icon_size(bitmap_info.bmWidth, bitmap_info.bmHeight); 314 // For non-color cursors, the mask contains both an AND and an XOR mask and
315 // the height includes both. Thus, the mask width is the same as image width,
316 // but we need to divide mask height by 2 to get the image height.
317 const int height = bitmap_info.bmHeight / (icon_info.hbmColor ? 1 : 2);
318 gfx::Size icon_size(bitmap_info.bmWidth, height);
315 return new SkBitmap(CreateSkBitmapFromHICONHelper(icon, icon_size)); 319 return new SkBitmap(CreateSkBitmapFromHICONHelper(icon, icon_size));
316 } 320 }
317 321
318 base::win::ScopedHICON IconUtil::CreateCursorFromDIB(const gfx::Size& icon_size, 322 base::win::ScopedHICON IconUtil::CreateCursorFromDIB(const gfx::Size& icon_size,
319 const gfx::Point& hotspot, 323 const gfx::Point& hotspot,
320 const void* dib_bits, 324 const void* dib_bits,
321 size_t dib_size) { 325 size_t dib_size) {
322 BITMAPINFO icon_bitmap_info = {}; 326 BITMAPINFO icon_bitmap_info = {};
323 skia::CreateBitmapHeader( 327 skia::CreateBitmapHeader(
324 icon_size.width(), 328 icon_size.width(),
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 // Once we compute the size for a singe AND mask scan line, we multiply that 694 // Once we compute the size for a singe AND mask scan line, we multiply that
691 // number by the image height in order to get the total number of bytes for 695 // number by the image height in order to get the total number of bytes for
692 // the AND mask. Thus, for a 15X15 image, we need 15 * 4 which is 60 bytes 696 // the AND mask. Thus, for a 15X15 image, we need 15 * 4 which is 60 bytes
693 // for the monochrome bitmap representing the AND mask. 697 // for the monochrome bitmap representing the AND mask.
694 size_t and_line_length = (bitmap.width() + 7) >> 3; 698 size_t and_line_length = (bitmap.width() + 7) >> 3;
695 and_line_length = (and_line_length + 3) & ~3; 699 and_line_length = (and_line_length + 3) & ~3;
696 size_t and_mask_size = and_line_length * bitmap.height(); 700 size_t and_mask_size = and_line_length * bitmap.height();
697 size_t masks_size = *xor_mask_size + and_mask_size; 701 size_t masks_size = *xor_mask_size + and_mask_size;
698 *bytes_in_resource = masks_size + sizeof(BITMAPINFOHEADER); 702 *bytes_in_resource = masks_size + sizeof(BITMAPINFOHEADER);
699 } 703 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698