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

Side by Side Diff: ui/base/native_theme/native_theme_win.cc

Issue 10915065: Add PlatformPictureSkia and RecordingPlatformDeviceSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: And one more.. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « skia/skia.gyp ('k') | ui/gfx/blit.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 #include "ui/base/native_theme/native_theme_win.h" 5 #include "ui/base/native_theme/native_theme_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <uxtheme.h> 8 #include <uxtheme.h>
9 #include <vsstyle.h> 9 #include <vsstyle.h>
10 #include <vssym32.h> 10 #include <vssym32.h>
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 return gfx::Size(size.cx, size.cy); 282 return gfx::Size(size.cx, size.cy);
283 } 283 }
284 284
285 void NativeThemeWin::Paint(SkCanvas* canvas, 285 void NativeThemeWin::Paint(SkCanvas* canvas,
286 Part part, 286 Part part,
287 State state, 287 State state,
288 const gfx::Rect& rect, 288 const gfx::Rect& rect,
289 const ExtraParams& extra) const { 289 const ExtraParams& extra) const {
290 bool needs_paint_indirect = false; 290 bool needs_paint_indirect = false;
291 if (!skia::SupportsPlatformPaint(canvas)) { 291 if (skia::PlatformPaintSupport(canvas) !=
292 skia::PlatformDevice::PLATFORM_PAINT_DIRECT) {
292 // This block will only get hit with --enable-accelerated-drawing flag. 293 // This block will only get hit with --enable-accelerated-drawing flag.
293 needs_paint_indirect = true; 294 needs_paint_indirect = true;
294 } else { 295 } else {
295 // Scrollbars on Windows XP and the Windows Classic theme have particularly 296 // Scrollbars on Windows XP and the Windows Classic theme have particularly
296 // problematic alpha values, so always draw them indirectly. 297 // problematic alpha values, so always draw them indirectly.
297 switch (part) { 298 switch (part) {
298 case kScrollbarDownArrow: 299 case kScrollbarDownArrow:
299 case kScrollbarUpArrow: 300 case kScrollbarUpArrow:
300 case kScrollbarLeftArrow: 301 case kScrollbarLeftArrow:
301 case kScrollbarRightArrow: 302 case kScrollbarRightArrow:
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 const gfx::Rect& rect, 476 const gfx::Rect& rect,
476 const ExtraParams& extra) const { 477 const ExtraParams& extra) const {
477 // TODO(asvitkine): This path is pretty inefficient - for each paint operation 478 // TODO(asvitkine): This path is pretty inefficient - for each paint operation
478 // it creates a new offscreen bitmap Skia canvas. This can 479 // it creates a new offscreen bitmap Skia canvas. This can
479 // be sped up by doing it only once per part/state and 480 // be sped up by doing it only once per part/state and
480 // keeping a cache of the resulting bitmaps. 481 // keeping a cache of the resulting bitmaps.
481 482
482 // Create an offscreen canvas that is backed by an HDC. 483 // Create an offscreen canvas that is backed by an HDC.
483 scoped_ptr<SkCanvas> offscreen_canvas( 484 scoped_ptr<SkCanvas> offscreen_canvas(
484 skia::CreateBitmapCanvas(rect.width(), rect.height(), false)); 485 skia::CreateBitmapCanvas(rect.width(), rect.height(), false));
485 DCHECK(offscreen_canvas.get()); 486 DCHECK(offscreen_canvas.get());
reed1 2012/09/25 11:53:59 shouldn't we DCHECK against one or more enum value
reveman 2012/09/25 12:04:13 I explicitly made PLATFORM_PAINT_UNSUPPORTED = 0 s
486 DCHECK(skia::SupportsPlatformPaint(offscreen_canvas.get())); 487 DCHECK(skia::PlatformPaintSupport(offscreen_canvas.get()));
487 488
488 // Some of the Windows theme drawing operations do not write correct alpha 489 // Some of the Windows theme drawing operations do not write correct alpha
489 // values for fully-opaque pixels; instead the pixels get alpha 0. This is 490 // values for fully-opaque pixels; instead the pixels get alpha 0. This is
490 // especially a problem on Windows XP or when using the Classic theme. 491 // especially a problem on Windows XP or when using the Classic theme.
491 // 492 //
492 // To work-around this, mark all pixels with a placeholder value, to detect 493 // To work-around this, mark all pixels with a placeholder value, to detect
493 // which pixels get touched by the paint operation. After paint, set any 494 // which pixels get touched by the paint operation. After paint, set any
494 // pixels that have alpha 0 to opaque and placeholders to fully-transparent. 495 // pixels that have alpha 0 to opaque and placeholders to fully-transparent.
495 const SkColor placeholder = SkColorSetARGB(1, 0, 0, 0); 496 const SkColor placeholder = SkColorSetARGB(1, 0, 0, 0);
496 offscreen_canvas->clear(placeholder); 497 offscreen_canvas->clear(placeholder);
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 handle = open_theme_(NULL, L"Spin"); 1810 handle = open_theme_(NULL, L"Spin");
1810 break; 1811 break;
1811 default: 1812 default:
1812 NOTREACHED(); 1813 NOTREACHED();
1813 } 1814 }
1814 theme_handles_[theme_name] = handle; 1815 theme_handles_[theme_name] = handle;
1815 return handle; 1816 return handle;
1816 } 1817 }
1817 1818
1818 } // namespace ui 1819 } // namespace ui
OLDNEW
« no previous file with comments | « skia/skia.gyp ('k') | ui/gfx/blit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698