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

Side by Side Diff: views/native_theme_painter.cc

Issue 8771006: views: Move the remaining file from views/ to ui/views/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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/native_theme_painter.h ('k') | views/paint_lock.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "views/native_theme_painter.h"
6
7 #include "base/logging.h"
8 #include "ui/base/animation/animation.h"
9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/canvas_skia.h"
11 #include "ui/gfx/rect.h"
12 #include "views/native_theme_delegate.h"
13
14 namespace views {
15
16 NativeThemePainter::NativeThemePainter(NativeThemeDelegate* delegate)
17 : delegate_(delegate) {
18 DCHECK(delegate_);
19 }
20
21 gfx::Size NativeThemePainter::GetPreferredSize() {
22 const gfx::NativeTheme* theme = gfx::NativeTheme::instance();
23 gfx::NativeTheme::ExtraParams extra;
24 gfx::NativeTheme::State state = delegate_->GetThemeState(&extra);
25 return theme->GetPartSize(delegate_->GetThemePart(), state, extra);
26 }
27
28 void NativeThemePainter::Paint(int w, int h, gfx::Canvas* canvas) {
29 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance();
30 gfx::NativeTheme::Part part = delegate_->GetThemePart();
31 gfx::Rect rect(0, 0, w, h);
32
33 if (delegate_->GetThemeAnimation() != NULL &&
34 delegate_->GetThemeAnimation()->is_animating()) {
35 // Paint background state.
36 gfx::NativeTheme::ExtraParams prev_extra;
37 gfx::NativeTheme::State prev_state =
38 delegate_->GetBackgroundThemeState(&prev_extra);
39 native_theme->Paint(
40 canvas->GetSkCanvas(), part, prev_state, rect, prev_extra);
41
42 // Composite foreground state above it.
43 gfx::NativeTheme::ExtraParams extra;
44 gfx::NativeTheme::State state = delegate_->GetForegroundThemeState(&extra);
45 int alpha = delegate_->GetThemeAnimation()->CurrentValueBetween(0, 255);
46 canvas->SaveLayerAlpha(static_cast<uint8>(alpha));
47 native_theme->Paint(canvas->GetSkCanvas(), part, state, rect, extra);
48 canvas->Restore();
49 } else {
50 gfx::NativeTheme::ExtraParams extra;
51 gfx::NativeTheme::State state = delegate_->GetThemeState(&extra);
52 native_theme->Paint(canvas->GetSkCanvas(), part, state, rect, extra);
53 }
54 }
55
56 } // namespace views
OLDNEW
« no previous file with comments | « views/native_theme_painter.h ('k') | views/paint_lock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698