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

Side by Side Diff: ui/views/controls/image_view.h

Issue 73893007: Makes ImageView do a bit more checking before assuming images equal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 7 years, 1 month 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 | « no previous file | ui/views/controls/image_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ 5 #ifndef UI_VIEWS_CONTROLS_IMAGE_VIEW_H_
6 #define UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ 6 #define UI_VIEWS_CONTROLS_IMAGE_VIEW_H_
7 7
8 #include "ui/gfx/image/image_skia.h" 8 #include "ui/gfx/image/image_skia.h"
9 #include "ui/views/view.h" 9 #include "ui/views/view.h"
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 // Overriden from View: 78 // Overriden from View:
79 virtual gfx::Size GetPreferredSize() OVERRIDE; 79 virtual gfx::Size GetPreferredSize() OVERRIDE;
80 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 80 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
81 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 81 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
82 virtual bool GetTooltipText(const gfx::Point& p, 82 virtual bool GetTooltipText(const gfx::Point& p,
83 string16* tooltip) const OVERRIDE; 83 string16* tooltip) const OVERRIDE;
84 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; 84 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
85 85
86 private: 86 private:
87 // Returns true if |img| is the same as the last image we painted. This is
88 // intended to be a quick check, not exhaustive. In other words it's possible
89 // for this to return false even though the images are in fact equal.
90 bool IsImageEqual(const gfx::ImageSkia& img) const;
91
87 // Compute the image origin given the desired size and the receiver alignment 92 // Compute the image origin given the desired size and the receiver alignment
88 // properties. 93 // properties.
89 gfx::Point ComputeImageOrigin(const gfx::Size& image_size) const; 94 gfx::Point ComputeImageOrigin(const gfx::Size& image_size) const;
90 95
91 // Whether the image size is set. 96 // Whether the image size is set.
92 bool image_size_set_; 97 bool image_size_set_;
93 98
94 // The actual image size. 99 // The actual image size.
95 gfx::Size image_size_; 100 gfx::Size image_size_;
96 101
97 // The underlying image. 102 // The underlying image.
98 gfx::ImageSkia image_; 103 gfx::ImageSkia image_;
99 104
100 // Horizontal alignment. 105 // Horizontal alignment.
101 Alignment horiz_alignment_; 106 Alignment horiz_alignment_;
102 107
103 // Vertical alignment. 108 // Vertical alignment.
104 Alignment vert_alignment_; 109 Alignment vert_alignment_;
105 110
106 // The current tooltip text. 111 // The current tooltip text.
107 string16 tooltip_text_; 112 string16 tooltip_text_;
108 113
109 // A flag controlling hit test handling for interactivity. 114 // A flag controlling hit test handling for interactivity.
110 bool interactive_; 115 bool interactive_;
111 116
117 // Scale last painted at.
118 float last_paint_scale_;
119
120 // Address of bytes we last painted. This is used only for comparison, so its
121 // safe to cache.
122 void* last_painted_bitmap_pixels_;
123
112 DISALLOW_COPY_AND_ASSIGN(ImageView); 124 DISALLOW_COPY_AND_ASSIGN(ImageView);
113 }; 125 };
114 126
115 } // namespace views 127 } // namespace views
116 128
117 #endif // UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ 129 #endif // UI_VIEWS_CONTROLS_IMAGE_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/image_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698