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

Side by Side Diff: ui/aura_extra/image_window_delegate.cc

Issue 880703002: Move ImageWindowDelegate to ui/aura_extra (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved to ui/aura_extra Created 5 years, 10 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
OLDNEW
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 "content/browser/web_contents/aura/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/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/geometry/rect.h" 11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
13 #include "ui/gfx/image/image.h" 13 #include "ui/gfx/image/image.h"
14 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
15 15
16 namespace content { 16 namespace aura_extra {
17 17
18 ImageWindowDelegate::ImageWindowDelegate() 18 ImageWindowDelegate::ImageWindowDelegate()
19 : size_mismatch_(false) { 19 : background_color_(SK_ColorWHITE),
20 self_destroy_(true),
21 size_mismatch_(false) {
20 } 22 }
21 23
22 ImageWindowDelegate::~ImageWindowDelegate() { 24 ImageWindowDelegate::~ImageWindowDelegate() {
23 } 25 }
24 26
27 void ImageWindowDelegate::SetBackgroundColor(SkColor color) {
28 background_color_ = color;
29 }
30
25 void ImageWindowDelegate::SetImage(const gfx::Image& image) { 31 void ImageWindowDelegate::SetImage(const gfx::Image& image) {
26 image_ = image; 32 image_ = image;
27 if (!window_size_.IsEmpty() && !image_.IsEmpty()) 33 if (!window_size_.IsEmpty() && !image_.IsEmpty())
28 size_mismatch_ = window_size_ != image_.AsImageSkia().size(); 34 size_mismatch_ = window_size_ != image_.AsImageSkia().size();
29 } 35 }
30 36
37 void ImageWindowDelegate::SetImageOffset(gfx::Vector2d offset) {
38 offset_ = offset;
39 }
40
41 void ImageWindowDelegate::SetSelfDestroy(bool self_destroy) {
42 self_destroy_ = self_destroy;
sadrul 2015/01/28 18:26:56 Is this really necessary? It looks like this is us
mohsen 2015/01/28 21:10:29 Actually, that was Mikhail's original approach, bu
sadrul 2015/01/28 21:13:39 Yeah, I think that'd be cleaner. (some other parts
mohsen 2015/01/29 03:23:15 Done.
43 }
44
31 gfx::Size ImageWindowDelegate::GetMinimumSize() const { 45 gfx::Size ImageWindowDelegate::GetMinimumSize() const {
32 return gfx::Size(); 46 return gfx::Size();
33 } 47 }
34 48
35 gfx::Size ImageWindowDelegate::GetMaximumSize() const { 49 gfx::Size ImageWindowDelegate::GetMaximumSize() const {
36 return gfx::Size(); 50 return gfx::Size();
37 } 51 }
38 52
39 void ImageWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds, 53 void ImageWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds,
40 const gfx::Rect& new_bounds) { 54 const gfx::Rect& new_bounds) {
(...skipping 17 matching lines...) Expand all
58 } 72 }
59 73
60 bool ImageWindowDelegate::CanFocus() { 74 bool ImageWindowDelegate::CanFocus() {
61 return false; 75 return false;
62 } 76 }
63 77
64 void ImageWindowDelegate::OnCaptureLost() { 78 void ImageWindowDelegate::OnCaptureLost() {
65 } 79 }
66 80
67 void ImageWindowDelegate::OnPaint(gfx::Canvas* canvas) { 81 void ImageWindowDelegate::OnPaint(gfx::Canvas* canvas) {
68 if (image_.IsEmpty()) { 82 if (background_color_ != SK_ColorTRANSPARENT &&
69 canvas->DrawColor(SK_ColorWHITE); 83 (image_.IsEmpty() || size_mismatch_ || !offset_.IsZero())) {
70 } else { 84 canvas->DrawColor(background_color_);
71 if (size_mismatch_)
72 canvas->DrawColor(SK_ColorWHITE);
73 canvas->DrawImageInt(image_.AsImageSkia(), 0, 0);
74 } 85 }
86 if (!image_.IsEmpty())
87 canvas->DrawImageInt(image_.AsImageSkia(), offset_.x(), offset_.y());
75 } 88 }
sadrul 2015/01/28 18:26:56 Can this be: if (image_.IsEmpty() || size_misma
mfomitchev 2015/01/28 19:15:42 If offset is non-zero we should paint the backgrou
sadrul 2015/01/28 19:28:47 Why?
sadrul 2015/01/28 19:30:04 Oh, I see, because there will be parts of the Wind
76 89
77 void ImageWindowDelegate::OnDeviceScaleFactorChanged(float scale_factor) { 90 void ImageWindowDelegate::OnDeviceScaleFactorChanged(float scale_factor) {
78 } 91 }
79 92
80 void ImageWindowDelegate::OnWindowDestroying(aura::Window* window) { 93 void ImageWindowDelegate::OnWindowDestroying(aura::Window* window) {
81 } 94 }
82 95
83 void ImageWindowDelegate::OnWindowDestroyed(aura::Window* window) { 96 void ImageWindowDelegate::OnWindowDestroyed(aura::Window* window) {
84 delete this; 97 if (self_destroy_)
98 delete this;
85 } 99 }
86 100
87 void ImageWindowDelegate::OnWindowTargetVisibilityChanged(bool visible) { 101 void ImageWindowDelegate::OnWindowTargetVisibilityChanged(bool visible) {
88 } 102 }
89 103
90 bool ImageWindowDelegate::HasHitTestMask() const { 104 bool ImageWindowDelegate::HasHitTestMask() const {
91 return false; 105 return false;
92 } 106 }
93 107
94 void ImageWindowDelegate::GetHitTestMask(gfx::Path* mask) const { 108 void ImageWindowDelegate::GetHitTestMask(gfx::Path* mask) const {
95 } 109 }
96 110
97 } // namespace content 111 } // namespace aura_extra
OLDNEW
« ui/aura_extra/image_window_delegate.h ('K') | « ui/aura_extra/image_window_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698