| OLD | NEW |
| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 gfx::Size NativeThemePainter::GetPreferredSize() { | 21 gfx::Size NativeThemePainter::GetPreferredSize() { |
| 22 const gfx::NativeTheme* theme = gfx::NativeTheme::instance(); | 22 const gfx::NativeTheme* theme = gfx::NativeTheme::instance(); |
| 23 gfx::NativeTheme::ExtraParams extra; | 23 gfx::NativeTheme::ExtraParams extra; |
| 24 gfx::NativeTheme::State state = delegate_->GetThemeState(&extra); | 24 gfx::NativeTheme::State state = delegate_->GetThemeState(&extra); |
| 25 return theme->GetPartSize(delegate_->GetThemePart(), state, extra); | 25 return theme->GetPartSize(delegate_->GetThemePart(), state, extra); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void NativeThemePainter::Paint(int w, int h, gfx::Canvas* canvas) { | 28 void NativeThemePainter::Paint(int w, int h, gfx::Canvas* canvas) { |
| 29 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance(); | 29 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance(); |
| 30 gfx::NativeTheme::Part part = delegate_->GetThemePart(); | 30 gfx::NativeTheme::Part part = delegate_->GetThemePart(); |
| 31 gfx::CanvasSkia* skia_canvas = canvas->AsCanvasSkia(); | |
| 32 gfx::Rect rect(0, 0, w, h); | 31 gfx::Rect rect(0, 0, w, h); |
| 33 | 32 |
| 34 if (delegate_->GetThemeAnimation() != NULL && | 33 if (delegate_->GetThemeAnimation() != NULL && |
| 35 delegate_->GetThemeAnimation()->is_animating()) { | 34 delegate_->GetThemeAnimation()->is_animating()) { |
| 36 // Paint background state. | 35 // Paint background state. |
| 37 gfx::NativeTheme::ExtraParams prev_extra; | 36 gfx::NativeTheme::ExtraParams prev_extra; |
| 38 gfx::NativeTheme::State prev_state = | 37 gfx::NativeTheme::State prev_state = |
| 39 delegate_->GetBackgroundThemeState(&prev_extra); | 38 delegate_->GetBackgroundThemeState(&prev_extra); |
| 40 native_theme->Paint(skia_canvas, part, prev_state, rect, prev_extra); | 39 native_theme->Paint( |
| 40 canvas->GetSkCanvas(), part, prev_state, rect, prev_extra); |
| 41 | 41 |
| 42 // Composite foreground state above it. | 42 // Composite foreground state above it. |
| 43 gfx::NativeTheme::ExtraParams extra; | 43 gfx::NativeTheme::ExtraParams extra; |
| 44 gfx::NativeTheme::State state = delegate_->GetForegroundThemeState(&extra); | 44 gfx::NativeTheme::State state = delegate_->GetForegroundThemeState(&extra); |
| 45 int alpha = delegate_->GetThemeAnimation()->CurrentValueBetween(0, 255); | 45 int alpha = delegate_->GetThemeAnimation()->CurrentValueBetween(0, 255); |
| 46 skia_canvas->SaveLayerAlpha(static_cast<uint8>(alpha)); | 46 canvas->SaveLayerAlpha(static_cast<uint8>(alpha)); |
| 47 native_theme->Paint(skia_canvas, part, state, rect, extra); | 47 native_theme->Paint(canvas->GetSkCanvas(), part, state, rect, extra); |
| 48 skia_canvas->Restore(); | 48 canvas->Restore(); |
| 49 } else { | 49 } else { |
| 50 gfx::NativeTheme::ExtraParams extra; | 50 gfx::NativeTheme::ExtraParams extra; |
| 51 gfx::NativeTheme::State state = delegate_->GetThemeState(&extra); | 51 gfx::NativeTheme::State state = delegate_->GetThemeState(&extra); |
| 52 native_theme->Paint(skia_canvas, part, state, rect, extra); | 52 native_theme->Paint(canvas->GetSkCanvas(), part, state, rect, extra); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace views | 56 } // namespace views |
| OLD | NEW |