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

Side by Side Diff: ui/base/clipboard/clipboard_win.cc

Issue 10790128: Revert 147915 - Cleanup gfx::Canvas now that 10562027 has landed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | ui/base/dragdrop/drag_utils.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 (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 // Many of these functions are based on those found in 5 // Many of these functions are based on those found in
6 // webkit/port/platform/PasteboardWin.cpp 6 // webkit/port/platform/PasteboardWin.cpp
7 7
8 #include "ui/base/clipboard/clipboard.h" 8 #include "ui/base/clipboard/clipboard.h"
9 9
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 break; 557 break;
558 case 24: 558 case 24:
559 break; 559 break;
560 default: 560 default:
561 NOTREACHED(); 561 NOTREACHED();
562 } 562 }
563 const void* bitmap_bits = reinterpret_cast<const char*>(bitmap) 563 const void* bitmap_bits = reinterpret_cast<const char*>(bitmap)
564 + bitmap->bmiHeader.biSize + color_table_length * sizeof(RGBQUAD); 564 + bitmap->bmiHeader.biSize + color_table_length * sizeof(RGBQUAD);
565 565
566 gfx::Canvas canvas(gfx::Size(bitmap->bmiHeader.biWidth, 566 gfx::Canvas canvas(gfx::Size(bitmap->bmiHeader.biWidth,
567 bitmap->bmiHeader.biHeight), 567 bitmap->bmiHeader.biHeight), false);
568 ui::SCALE_FACTOR_100P,
569 false);
570 { 568 {
571 skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas()); 569 skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas());
572 HDC dc = scoped_platform_paint.GetPlatformSurface(); 570 HDC dc = scoped_platform_paint.GetPlatformSurface();
573 ::SetDIBitsToDevice(dc, 0, 0, bitmap->bmiHeader.biWidth, 571 ::SetDIBitsToDevice(dc, 0, 0, bitmap->bmiHeader.biWidth,
574 bitmap->bmiHeader.biHeight, 0, 0, 0, 572 bitmap->bmiHeader.biHeight, 0, 0, 0,
575 bitmap->bmiHeader.biHeight, bitmap_bits, bitmap, 573 bitmap->bmiHeader.biHeight, bitmap_bits, bitmap,
576 DIB_RGB_COLORS); 574 DIB_RGB_COLORS);
577 } 575 }
578 // Windows doesn't really handle alpha channels well in many situations. When 576 // Windows doesn't really handle alpha channels well in many situations. When
579 // the source image is < 32 bpp, we force the bitmap to be opaque. When the 577 // the source image is < 32 bpp, we force the bitmap to be opaque. When the
580 // source image is 32 bpp, the alpha channel might still contain garbage data. 578 // source image is 32 bpp, the alpha channel might still contain garbage data.
581 // Since Windows uses premultiplied alpha, we scan for instances where 579 // Since Windows uses premultiplied alpha, we scan for instances where
582 // (R, G, B) > A. If there are any invalid premultiplied colors in the image, 580 // (R, G, B) > A. If there are any invalid premultiplied colors in the image,
583 // we assume the alpha channel contains garbage and force the bitmap to be 581 // we assume the alpha channel contains garbage and force the bitmap to be
584 // opaque as well. Note that this heuristic will fail on a transparent bitmap 582 // opaque as well. Note that this heuristic will fail on a transparent bitmap
585 // containing only black pixels... 583 // containing only black pixels...
586 const SkBitmap& device_bitmap = 584 const SkBitmap& device_bitmap =
587 canvas.sk_canvas()->getDevice()->accessBitmap(true); 585 canvas.sk_canvas()->getDevice()->accessBitmap(true);
588 { 586 {
589 SkAutoLockPixels lock(device_bitmap); 587 SkAutoLockPixels lock(device_bitmap);
590 bool has_invalid_alpha_channel = bitmap->bmiHeader.biBitCount < 32 || 588 bool has_invalid_alpha_channel = bitmap->bmiHeader.biBitCount < 32 ||
591 BitmapHasInvalidPremultipliedColors(device_bitmap); 589 BitmapHasInvalidPremultipliedColors(device_bitmap);
592 if (has_invalid_alpha_channel) { 590 if (has_invalid_alpha_channel) {
593 MakeBitmapOpaque(device_bitmap); 591 MakeBitmapOpaque(device_bitmap);
594 } 592 }
595 } 593 }
596 594
597 return canvas.ExtractImageRep().sk_bitmap(); 595 return canvas.ExtractBitmap();
598 } 596 }
599 597
600 void Clipboard::ReadCustomData(Buffer buffer, 598 void Clipboard::ReadCustomData(Buffer buffer,
601 const string16& type, 599 const string16& type,
602 string16* result) const { 600 string16* result) const {
603 DCHECK_EQ(buffer, BUFFER_STANDARD); 601 DCHECK_EQ(buffer, BUFFER_STANDARD);
604 602
605 // Acquire the clipboard. 603 // Acquire the clipboard.
606 ScopedClipboard clipboard; 604 ScopedClipboard clipboard;
607 if (!clipboard.Acquire(GetClipboardWindow())) 605 if (!clipboard.Acquire(GetClipboardWindow()))
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass", 837 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass",
840 L"ClipboardOwnerWindow", 838 L"ClipboardOwnerWindow",
841 0, 0, 0, 0, 0, 839 0, 0, 0, 0, 0,
842 HWND_MESSAGE, 840 HWND_MESSAGE,
843 0, 0, 0); 841 0, 0, 0);
844 } 842 }
845 return clipboard_owner_; 843 return clipboard_owner_;
846 } 844 }
847 845
848 } // namespace ui 846 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | ui/base/dragdrop/drag_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698