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

Unified Diff: ui/native_theme/native_theme_win.cc

Issue 2090003003: Remove NativeThemeWin::PaintIndirect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/native_theme/native_theme_win.cc
diff --git a/ui/native_theme/native_theme_win.cc b/ui/native_theme/native_theme_win.cc
index 69954dd8d2bedcede4e6fb5a7c83566b33f0be09..91c1061a7ede156199cbf114d44c77a3d5653a61 100644
--- a/ui/native_theme/native_theme_win.cc
+++ b/ui/native_theme/native_theme_win.cc
@@ -255,39 +255,7 @@ void NativeThemeWin::Paint(SkCanvas* canvas,
break;
}
- bool needs_paint_indirect = false;
- if (!skia::SupportsPlatformPaint(canvas)) {
- // This block will only get hit with --enable-accelerated-drawing flag.
- needs_paint_indirect = true;
- } else {
- // Scrollbar components on Windows Classic theme (on all Windows versions)
- // have particularly problematic alpha values, so always draw them
- // indirectly. In addition, scrollbar thumbs and grippers for the Windows XP
- // theme (available only on Windows XP) also need their alpha values
- // fixed.
- switch (part) {
- case kScrollbarDownArrow:
- case kScrollbarUpArrow:
- case kScrollbarLeftArrow:
- case kScrollbarRightArrow:
- needs_paint_indirect = !GetThemeHandle(SCROLLBAR);
- break;
- case kScrollbarHorizontalThumb:
- case kScrollbarVerticalThumb:
- case kScrollbarHorizontalGripper:
- case kScrollbarVerticalGripper:
- needs_paint_indirect = !GetThemeHandle(SCROLLBAR) ||
- base::win::GetVersion() == base::win::VERSION_XP;
- break;
- default:
- break;
- }
- }
-
- if (needs_paint_indirect)
- PaintIndirect(canvas, part, state, rect, extra);
- else
- PaintDirect(canvas, part, state, rect, extra);
+ PaintDirect(canvas, part, state, rect, extra);
Peter Kasting 2016/06/29 23:20:01 This is now the only caller of this function. I w
}
NativeThemeWin::NativeThemeWin()
@@ -672,76 +640,6 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const {
return GetAuraColor(color_id, this);
}
-void NativeThemeWin::PaintIndirect(SkCanvas* canvas,
- Part part,
- State state,
- const gfx::Rect& rect,
- const ExtraParams& extra) const {
- // TODO(asvitkine): This path is pretty inefficient - for each paint operation
- // it creates a new offscreen bitmap Skia canvas. This can
- // be sped up by doing it only once per part/state and
- // keeping a cache of the resulting bitmaps.
-
- // Create an offscreen canvas that is backed by an HDC.
- sk_sp<skia::BitmapPlatformDevice> device(
- skia::BitmapPlatformDevice::Create(
- rect.width(), rect.height(), false, NULL));
- DCHECK(device);
- SkCanvas offscreen_canvas(device.get());
- DCHECK(skia::SupportsPlatformPaint(&offscreen_canvas));
-
- // Some of the Windows theme drawing operations do not write correct alpha
- // values for fully-opaque pixels; instead the pixels get alpha 0. This is
- // especially a problem on Windows XP or when using the Classic theme.
- //
- // To work-around this, mark all pixels with a placeholder value, to detect
- // which pixels get touched by the paint operation. After paint, set any
- // pixels that have alpha 0 to opaque and placeholders to fully-transparent.
- const SkColor placeholder = SkColorSetARGB(1, 0, 0, 0);
- offscreen_canvas.clear(placeholder);
-
- // Offset destination rects to have origin (0,0).
- gfx::Rect adjusted_rect(rect.size());
- ExtraParams adjusted_extra(extra);
- switch (part) {
- case kProgressBar:
- adjusted_extra.progress_bar.value_rect_x = 0;
- adjusted_extra.progress_bar.value_rect_y = 0;
- break;
- case kScrollbarHorizontalTrack:
- case kScrollbarVerticalTrack:
- adjusted_extra.scrollbar_track.track_x = 0;
- adjusted_extra.scrollbar_track.track_y = 0;
- break;
- default:
- break;
- }
- // Draw the theme controls using existing HDC-drawing code.
- PaintDirect(&offscreen_canvas, part, state, adjusted_rect, adjusted_extra);
-
- SkBitmap bitmap = skia::ReadPixels(&offscreen_canvas);
-
- // Post-process the pixels to fix up the alpha values (see big comment above).
- const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder);
- const int pixel_count = rect.width() * rect.height();
- SkPMColor* pixels = bitmap.getAddr32(0, 0);
- for (int i = 0; i < pixel_count; i++) {
- if (pixels[i] == placeholder_value) {
- // Pixel wasn't touched - make it fully transparent.
- pixels[i] = SkPackARGB32(0, 0, 0, 0);
- } else if (SkGetPackedA32(pixels[i]) == 0) {
- // Pixel was touched but has incorrect alpha of 0, make it fully opaque.
- pixels[i] = SkPackARGB32(0xFF,
- SkGetPackedR32(pixels[i]),
- SkGetPackedG32(pixels[i]),
- SkGetPackedB32(pixels[i]));
- }
- }
-
- // Draw the offscreen bitmap to the destination canvas.
- canvas->drawBitmap(bitmap, rect.x(), rect.y());
-}
-
HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name,
HDC hdc,
int part_id,
« 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