Update UnusedResources lint suppressions.
[chromium-blink-merge.git] / ui / aura_extra / image_window_delegate.cc
blob9e4b35e679e040b22d88760541559f0478f3f606
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
3 // found in the LICENSE file.
5 #include "ui/aura_extra/image_window_delegate.h"
7 #include "ui/base/cursor/cursor.h"
8 #include "ui/base/hit_test.h"
9 #include "ui/compositor/compositor.h"
10 #include "ui/compositor/paint_recorder.h"
11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "ui/gfx/image/image.h"
15 #include "ui/gfx/image/image_skia.h"
17 namespace aura_extra {
19 ImageWindowDelegate::ImageWindowDelegate()
20 : background_color_(SK_ColorWHITE),
21 size_mismatch_(false) {
24 ImageWindowDelegate::~ImageWindowDelegate() {
27 void ImageWindowDelegate::SetImage(const gfx::Image& image) {
28 image_ = image;
29 if (!window_size_.IsEmpty() && !image_.IsEmpty())
30 size_mismatch_ = window_size_ != image_.AsImageSkia().size();
33 gfx::Size ImageWindowDelegate::GetMinimumSize() const {
34 return gfx::Size();
37 gfx::Size ImageWindowDelegate::GetMaximumSize() const {
38 return gfx::Size();
41 void ImageWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds,
42 const gfx::Rect& new_bounds) {
43 window_size_ = new_bounds.size();
44 if (!image_.IsEmpty())
45 size_mismatch_ = window_size_ != image_.AsImageSkia().size();
48 ui::TextInputClient* ImageWindowDelegate::GetFocusedTextInputClient() {
49 return nullptr;
52 gfx::NativeCursor ImageWindowDelegate::GetCursor(const gfx::Point& point) {
53 return gfx::kNullCursor;
56 int ImageWindowDelegate::GetNonClientComponent(const gfx::Point& point) const {
57 return HTNOWHERE;
60 bool ImageWindowDelegate::ShouldDescendIntoChildForEventHandling(
61 aura::Window* child,
62 const gfx::Point& location) {
63 return false;
66 bool ImageWindowDelegate::CanFocus() {
67 return false;
70 void ImageWindowDelegate::OnCaptureLost() {
73 void ImageWindowDelegate::OnPaint(const ui::PaintContext& context) {
74 ui::PaintRecorder recorder(context);
75 if (background_color_ != SK_ColorTRANSPARENT &&
76 (image_.IsEmpty() || size_mismatch_ || !offset_.IsZero())) {
77 recorder.canvas()->DrawColor(background_color_);
79 if (!image_.IsEmpty()) {
80 recorder.canvas()->DrawImageInt(image_.AsImageSkia(), offset_.x(),
81 offset_.y());
85 void ImageWindowDelegate::OnDeviceScaleFactorChanged(float scale_factor) {
88 void ImageWindowDelegate::OnWindowDestroying(aura::Window* window) {
91 void ImageWindowDelegate::OnWindowDestroyed(aura::Window* window) {
92 delete this;
95 void ImageWindowDelegate::OnWindowTargetVisibilityChanged(bool visible) {
98 bool ImageWindowDelegate::HasHitTestMask() const {
99 return false;
102 void ImageWindowDelegate::GetHitTestMask(gfx::Path* mask) const {
105 } // namespace aura_extra