| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/aura_extra/image_window_delegate.h" | 5 #include "ui/aura_extra/image_window_delegate.h" |
| 6 | 6 |
| 7 #include "ui/base/cursor/cursor.h" | 7 #include "ui/base/cursor/cursor.h" |
| 8 #include "ui/base/hit_test.h" | 8 #include "ui/base/hit_test.h" |
| 9 #include "ui/compositor/compositor.h" | 9 #include "ui/compositor/compositor.h" |
| 10 #include "ui/compositor/paint_context.h" | 10 #include "ui/compositor/paint_recorder.h" |
| 11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 13 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 15 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
| 16 | 16 |
| 17 namespace aura_extra { | 17 namespace aura_extra { |
| 18 | 18 |
| 19 ImageWindowDelegate::ImageWindowDelegate() | 19 ImageWindowDelegate::ImageWindowDelegate() |
| 20 : background_color_(SK_ColorWHITE), | 20 : background_color_(SK_ColorWHITE), |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool ImageWindowDelegate::CanFocus() { | 66 bool ImageWindowDelegate::CanFocus() { |
| 67 return false; | 67 return false; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void ImageWindowDelegate::OnCaptureLost() { | 70 void ImageWindowDelegate::OnCaptureLost() { |
| 71 } | 71 } |
| 72 | 72 |
| 73 void ImageWindowDelegate::OnPaint(const ui::PaintContext& context) { | 73 void ImageWindowDelegate::OnPaint(const ui::PaintContext& context) { |
| 74 gfx::Canvas* canvas = context.canvas(); | 74 ui::PaintRecorder recorder(context); |
| 75 if (background_color_ != SK_ColorTRANSPARENT && | 75 if (background_color_ != SK_ColorTRANSPARENT && |
| 76 (image_.IsEmpty() || size_mismatch_ || !offset_.IsZero())) { | 76 (image_.IsEmpty() || size_mismatch_ || !offset_.IsZero())) { |
| 77 canvas->DrawColor(background_color_); | 77 recorder.canvas()->DrawColor(background_color_); |
| 78 } | 78 } |
| 79 if (!image_.IsEmpty()) | 79 if (!image_.IsEmpty()) { |
| 80 canvas->DrawImageInt(image_.AsImageSkia(), offset_.x(), offset_.y()); | 80 recorder.canvas()->DrawImageInt(image_.AsImageSkia(), offset_.x(), |
| 81 offset_.y()); |
| 82 } |
| 81 } | 83 } |
| 82 | 84 |
| 83 void ImageWindowDelegate::OnDeviceScaleFactorChanged(float scale_factor) { | 85 void ImageWindowDelegate::OnDeviceScaleFactorChanged(float scale_factor) { |
| 84 } | 86 } |
| 85 | 87 |
| 86 void ImageWindowDelegate::OnWindowDestroying(aura::Window* window) { | 88 void ImageWindowDelegate::OnWindowDestroying(aura::Window* window) { |
| 87 } | 89 } |
| 88 | 90 |
| 89 void ImageWindowDelegate::OnWindowDestroyed(aura::Window* window) { | 91 void ImageWindowDelegate::OnWindowDestroyed(aura::Window* window) { |
| 90 delete this; | 92 delete this; |
| 91 } | 93 } |
| 92 | 94 |
| 93 void ImageWindowDelegate::OnWindowTargetVisibilityChanged(bool visible) { | 95 void ImageWindowDelegate::OnWindowTargetVisibilityChanged(bool visible) { |
| 94 } | 96 } |
| 95 | 97 |
| 96 bool ImageWindowDelegate::HasHitTestMask() const { | 98 bool ImageWindowDelegate::HasHitTestMask() const { |
| 97 return false; | 99 return false; |
| 98 } | 100 } |
| 99 | 101 |
| 100 void ImageWindowDelegate::GetHitTestMask(gfx::Path* mask) const { | 102 void ImageWindowDelegate::GetHitTestMask(gfx::Path* mask) const { |
| 101 } | 103 } |
| 102 | 104 |
| 103 } // namespace aura_extra | 105 } // namespace aura_extra |
| OLD | NEW |