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

Side by Side Diff: views/native_theme_painter.cc

Issue 6879013: skia::PlatformCanvas is being deprecated. Going forward we will use gfx::Canvas wherever we need ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 | « views/drag_utils.cc ('k') | views/painter.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/native_theme_painter.h" 5 #include "views/native_theme_painter.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/animation/animation.h" 8 #include "ui/base/animation/animation.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/canvas_skia.h" 10 #include "ui/gfx/canvas_skia.h"
11 #include "ui/gfx/rect.h" 11 #include "ui/gfx/rect.h"
12 12
13 namespace views { 13 namespace views {
14 14
15 NativeThemePainter::NativeThemePainter(Delegate* delegate) 15 NativeThemePainter::NativeThemePainter(Delegate* delegate)
16 : delegate_(delegate) { 16 : delegate_(delegate) {
17 DCHECK(delegate_); 17 DCHECK(delegate_);
18 } 18 }
19 19
20 gfx::Size NativeThemePainter::GetPreferredSize() { 20 gfx::Size NativeThemePainter::GetPreferredSize() {
21 const gfx::NativeTheme* theme = gfx::NativeTheme::instance(); 21 const gfx::NativeTheme* theme = gfx::NativeTheme::instance();
22 return theme->GetPartSize(delegate_->GetThemePart()); 22 return theme->GetPartSize(delegate_->GetThemePart());
23 } 23 }
24 24
25 void NativeThemePainter::Paint(int w, int h, gfx::Canvas* canvas) { 25 void NativeThemePainter::Paint(int w, int h, gfx::Canvas* canvas) {
26 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance(); 26 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance();
27 gfx::NativeTheme::Part part = delegate_->GetThemePart(); 27 gfx::NativeTheme::Part part = delegate_->GetThemePart();
28 gfx::CanvasSkia* skia_canvas = canvas->AsCanvasSkia(); 28 gfx::CanvasSkia* canvas_skia = canvas->AsCanvasSkia();
29 gfx::Rect rect(0, 0, w, h); 29 gfx::Rect rect(0, 0, w, h);
30 30
31 if (delegate_->GetThemeAnimation() != NULL && 31 if (delegate_->GetThemeAnimation() != NULL &&
32 delegate_->GetThemeAnimation()->is_animating()) { 32 delegate_->GetThemeAnimation()->is_animating()) {
33 // Paint background state. 33 // Paint background state.
34 gfx::NativeTheme::ExtraParams prev_extra; 34 gfx::NativeTheme::ExtraParams prev_extra;
35 gfx::NativeTheme::State prev_state = 35 gfx::NativeTheme::State prev_state =
36 delegate_->GetBackgroundThemeState(&prev_extra); 36 delegate_->GetBackgroundThemeState(&prev_extra);
37 native_theme->Paint(skia_canvas, part, prev_state, rect, prev_extra); 37 native_theme->Paint(canvas_skia->skia_canvas(),
38 part, prev_state, rect, prev_extra);
38 39
39 // Composite foreground state above it. 40 // Composite foreground state above it.
40 gfx::NativeTheme::ExtraParams extra; 41 gfx::NativeTheme::ExtraParams extra;
41 gfx::NativeTheme::State state = delegate_->GetForegroundThemeState(&extra); 42 gfx::NativeTheme::State state = delegate_->GetForegroundThemeState(&extra);
42 int alpha = delegate_->GetThemeAnimation()->CurrentValueBetween(0, 255); 43 int alpha = delegate_->GetThemeAnimation()->CurrentValueBetween(0, 255);
43 skia_canvas->SaveLayerAlpha(static_cast<uint8>(alpha)); 44 canvas_skia->SaveLayerAlpha(static_cast<uint8>(alpha));
44 native_theme->Paint(skia_canvas, part, state, rect, extra); 45 native_theme->Paint(canvas_skia->skia_canvas(), part, state, rect, extra);
45 skia_canvas->Restore(); 46 canvas_skia->Restore();
46 } else { 47 } else {
47 gfx::NativeTheme::ExtraParams extra; 48 gfx::NativeTheme::ExtraParams extra;
48 gfx::NativeTheme::State state = delegate_->GetThemeState(&extra); 49 gfx::NativeTheme::State state = delegate_->GetThemeState(&extra);
49 native_theme->Paint(skia_canvas, part, state, rect, extra); 50 native_theme->Paint(canvas_skia->skia_canvas(), part, state, rect, extra);
50 } 51 }
51 } 52 }
52 53
53 } // namespace views 54 } // namespace views
OLDNEW
« no previous file with comments | « views/drag_utils.cc ('k') | views/painter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698