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

Side by Side Diff: ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc

Issue 262893002: Removes grab input window and extra grab and ungrab in X11WholeScreenMoveLoop Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removes grab input window and extra grab and ungrab in X11WholeScreenMoveLoop (refactored) Created 6 years, 7 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 | Annotate | Revision Log
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 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h" 5 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
6 6
7 #include <X11/extensions/XInput2.h>
7 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
8 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. 9 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
9 #undef RootWindow 10 #undef RootWindow
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 14 #include "base/run_loop.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "ui/aura/env.h" 16 #include "ui/aura/env.h"
16 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
(...skipping 12 matching lines...) Expand all
29 30
30 namespace views { 31 namespace views {
31 32
32 namespace { 33 namespace {
33 34
34 // The minimum alpha before we declare a pixel transparent when searching in 35 // The minimum alpha before we declare a pixel transparent when searching in
35 // our source image. 36 // our source image.
36 const uint32 kMinAlpha = 32; 37 const uint32 kMinAlpha = 32;
37 const unsigned char kDragWidgetOpacity = 0xc0; 38 const unsigned char kDragWidgetOpacity = 0xc0;
38 39
39 class ScopedCapturer {
40 public:
41 explicit ScopedCapturer(aura::WindowTreeHost* host)
42 : host_(host) {
43 host_->SetCapture();
44 }
45
46 ~ScopedCapturer() {
47 host_->ReleaseCapture();
48 }
49
50 private:
51 aura::WindowTreeHost* host_;
52
53 DISALLOW_COPY_AND_ASSIGN(ScopedCapturer);
54 };
55
56 } // namespace 40 } // namespace
57 41
58 X11WholeScreenMoveLoop::X11WholeScreenMoveLoop( 42 X11WholeScreenMoveLoop::X11WholeScreenMoveLoop(
59 X11WholeScreenMoveLoopDelegate* delegate) 43 X11WholeScreenMoveLoopDelegate* delegate)
60 : delegate_(delegate), 44 : delegate_(delegate),
61 in_move_loop_(false), 45 in_move_loop_(false),
62 should_reset_mouse_flags_(false), 46 should_reset_mouse_flags_(false),
63 grab_input_window_(None),
64 canceled_(false), 47 canceled_(false),
65 weak_factory_(this) { 48 weak_factory_(this) {
66 last_xmotion_.type = LASTEvent; 49 last_xmotion_.type = LASTEvent;
67 } 50 }
68 51
69 X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {} 52 X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {}
70 53
71 void X11WholeScreenMoveLoop::DispatchMouseMovement() { 54 void X11WholeScreenMoveLoop::DispatchMouseMovement() {
72 if (!weak_factory_.HasWeakPtrs()) 55 if (!weak_factory_.HasWeakPtrs())
73 return; 56 return;
74 weak_factory_.InvalidateWeakPtrs(); 57 weak_factory_.InvalidateWeakPtrs();
75 DCHECK_EQ(MotionNotify, last_xmotion_.type); 58 DCHECK_EQ(MotionNotify, last_xmotion_.type);
76 delegate_->OnMouseMovement(&last_xmotion_); 59 delegate_->OnMouseMovement(&last_xmotion_);
77 last_xmotion_.type = LASTEvent; 60 last_xmotion_.type = LASTEvent;
78 } 61 }
79 62
80 //////////////////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////////////////
81 // DesktopWindowTreeHostLinux, ui::PlatformEventDispatcher implementation: 64 // DesktopWindowTreeHostLinux, ui::PlatformEventDispatcher implementation:
82 65
83 bool X11WholeScreenMoveLoop::CanDispatchEvent(const ui::PlatformEvent& event) { 66 bool X11WholeScreenMoveLoop::CanDispatchEvent(const ui::PlatformEvent& event) {
67 NOTREACHED();
84 return in_move_loop_; 68 return in_move_loop_;
pkotwicz 2014/05/05 18:14:37 returning true would probably be more appropriate
varkha 2014/05/05 19:06:04 Done.
85 } 69 }
86 70
87 uint32_t X11WholeScreenMoveLoop::DispatchEvent(const ui::PlatformEvent& event) { 71 uint32_t X11WholeScreenMoveLoop::DispatchEvent(const ui::PlatformEvent& event) {
88 // This method processes all events for the grab_input_window_ as well as 72 // This method processes all mouse events for all windows while the move loop
89 // mouse events for all windows while the move loop is active - even before 73 // is active.
90 // the grab is granted by X. This allows mouse notification events that were
91 // sent after the capture was requested but before the capture was granted
92 // to be dispatched. It is especially important to process the mouse release
93 // event that should have stopped the drag even if that mouse release happened
94 // before the grab was granted.
95 if (!in_move_loop_) 74 if (!in_move_loop_)
96 return ui::POST_DISPATCH_PERFORM_DEFAULT; 75 return ui::POST_DISPATCH_PERFORM_DEFAULT;
97 XEvent* xev = event; 76 XEvent* xev = event;
98 77
99 // Note: the escape key is handled in the tab drag controller, which has 78 // Note: the escape key is handled in the tab drag controller, which has
100 // keyboard focus even though we took pointer grab. 79 // keyboard focus even though we took pointer grab.
101 switch (xev->type) { 80 switch (xev->type) {
102 case MotionNotify: { 81 case MotionNotify: {
103 if (drag_widget_.get()) { 82 if (drag_widget_.get()) {
104 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 83 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
(...skipping 14 matching lines...) Expand all
119 } 98 }
120 return ui::POST_DISPATCH_NONE; 99 return ui::POST_DISPATCH_NONE;
121 } 100 }
122 case ButtonRelease: { 101 case ButtonRelease: {
123 if (xev->xbutton.button == Button1) { 102 if (xev->xbutton.button == Button1) {
124 // Assume that drags are being done with the left mouse button. Only 103 // Assume that drags are being done with the left mouse button. Only
125 // break the drag if the left mouse button was released. 104 // break the drag if the left mouse button was released.
126 DispatchMouseMovement(); 105 DispatchMouseMovement();
127 delegate_->OnMouseReleased(); 106 delegate_->OnMouseReleased();
128 } 107 }
129 return ui::POST_DISPATCH_NONE; 108 // default dispatch will release capture in Widget::OnMouseEvent.
pkotwicz 2014/05/05 18:14:37 Nit: Widget::OnMouseEvent()
varkha 2014/05/05 19:06:04 Done.
109 break;
130 } 110 }
131 case KeyPress: { 111 case KeyPress: {
132 if (ui::KeyboardCodeFromXKeyEvent(xev) == ui::VKEY_ESCAPE) { 112 if (ui::KeyboardCodeFromXKeyEvent(xev) == ui::VKEY_ESCAPE) {
133 canceled_ = true; 113 canceled_ = true;
134 EndMoveLoop(); 114 EndMoveLoop();
135 return ui::POST_DISPATCH_NONE; 115 return ui::POST_DISPATCH_NONE;
136 } 116 }
137 break; 117 break;
138 } 118 }
139 case GenericEvent: { 119 case GenericEvent: {
140 ui::EventType type = ui::EventTypeFromNative(xev); 120 ui::EventType type = ui::EventTypeFromNative(xev);
141 switch (type) { 121 switch (type) {
142 case ui::ET_MOUSE_MOVED: 122 case ui::ET_MOUSE_MOVED:
143 case ui::ET_MOUSE_DRAGGED: 123 case ui::ET_MOUSE_DRAGGED:
144 case ui::ET_MOUSE_RELEASED: { 124 case ui::ET_MOUSE_RELEASED: {
145 XEvent xevent = {0}; 125 XEvent xevent = {0};
146 if (type == ui::ET_MOUSE_RELEASED) { 126 if (type == ui::ET_MOUSE_RELEASED) {
147 xevent.type = ButtonRelease; 127 xevent.type = ButtonRelease;
148 xevent.xbutton.button = ui::EventButtonFromNative(xev); 128 xevent.xbutton.button = ui::EventButtonFromNative(xev);
149 } else { 129 } else {
150 xevent.type = MotionNotify; 130 xevent.type = MotionNotify;
151 } 131 }
152 xevent.xany.display = xev->xgeneric.display; 132 xevent.xany.display = xev->xgeneric.display;
153 xevent.xany.window = grab_input_window_; 133 XIDeviceEvent* xievent =
134 static_cast<XIDeviceEvent*>(xev->xcookie.data);
135 xevent.xany.window = xievent->event;
154 // The fields used below are in the same place for all of events 136 // The fields used below are in the same place for all of events
155 // above. Using xmotion from XEvent's unions to avoid repeating 137 // above. Using xmotion from XEvent's unions to avoid repeating
156 // the code. 138 // the code.
157 xevent.xmotion.root = DefaultRootWindow(xev->xgeneric.display); 139 xevent.xmotion.root = DefaultRootWindow(xev->xgeneric.display);
158 xevent.xmotion.time = ui::EventTimeFromNative(xev).InMilliseconds(); 140 xevent.xmotion.time = ui::EventTimeFromNative(xev).InMilliseconds();
159 gfx::Point point(ui::EventSystemLocationFromNative(xev)); 141 gfx::Point point(ui::EventSystemLocationFromNative(xev));
160 xevent.xmotion.x_root = point.x(); 142 xevent.xmotion.x_root = point.x();
161 xevent.xmotion.y_root = point.y(); 143 xevent.xmotion.y_root = point.y();
162 DispatchEvent(&xevent); 144 return DispatchEvent(&xevent);
163 return ui::POST_DISPATCH_NONE;
164 } 145 }
165 default: 146 default:
166 break; 147 break;
167 } 148 }
168 } 149 }
169 } 150 }
170 151
171 return (event->xany.window == grab_input_window_) ? 152 return ui::POST_DISPATCH_PERFORM_DEFAULT;
172 ui::POST_DISPATCH_NONE : ui::POST_DISPATCH_PERFORM_DEFAULT;
173 } 153 }
174 154
175 bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source, 155 bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source,
176 gfx::NativeCursor cursor) { 156 gfx::NativeCursor cursor) {
177 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. 157 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
178 158
179 // Start a capture on the host, so that it continues to receive events during
180 // the drag. This may be second time we are capturing the mouse events - the
181 // first being when a mouse is first pressed. That first capture needs to be
182 // released before the call to GrabPointerAndKeyboard below, otherwise it may
183 // get released while we still need the pointer grab, which is why we restrict
184 // the scope here.
185 {
186 ScopedCapturer capturer(source->GetHost());
187
188 grab_input_window_ = CreateDragInputWindow(gfx::GetXDisplay());
189 // Releasing ScopedCapturer ensures that any other instance of
190 // X11ScopedCapture will not prematurely release grab that will be acquired
191 // below.
192 }
193 // TODO(varkha): Consider integrating GrabPointerAndKeyboard with
194 // ScopedCapturer to avoid possibility of logically keeping multiple grabs.
195 if (!GrabPointerAndKeyboard(cursor)) {
196 XDestroyWindow(gfx::GetXDisplay(), grab_input_window_);
197 return false;
198 }
199
200 scoped_ptr<ui::ScopedEventDispatcher> old_dispatcher = 159 scoped_ptr<ui::ScopedEventDispatcher> old_dispatcher =
201 nested_dispatcher_.Pass(); 160 nested_dispatcher_.Pass();
202 nested_dispatcher_ = 161 nested_dispatcher_ =
203 ui::PlatformEventSource::GetInstance()->OverrideDispatcher(this); 162 ui::PlatformEventSource::GetInstance()->OverrideDispatcher(this);
204 if (!drag_image_.isNull() && CheckIfIconValid()) 163 if (!drag_image_.isNull() && CheckIfIconValid()) {
205 CreateDragImageWindow(); 164 CreateDragImageWindow();
165 source = drag_widget_->GetNativeWindow();
pkotwicz 2014/05/05 18:14:37 I wonder whether we can move this logic to Desktop
varkha 2014/05/05 19:06:04 I'll try that. I have uploaded a patch with the re
varkha 2014/05/06 22:02:41 Done.
166 }
167 // Start a capture on the source window (drag widget for drag and drop),
168 // so that it continues to receive events during the drag.
169 source->SetCapture();
206 170
207 // We are handling a mouse drag outside of the aura::RootWindow system. We 171 // We are handling a mouse drag outside of the aura::RootWindow system. We
208 // must manually make aura think that the mouse button is pressed so that we 172 // must manually make aura think that the mouse button is pressed so that we
209 // don't draw extraneous tooltips. 173 // don't draw extraneous tooltips.
210 aura::Env* env = aura::Env::GetInstance(); 174 aura::Env* env = aura::Env::GetInstance();
211 if (!env->IsMouseButtonDown()) { 175 if (!env->IsMouseButtonDown()) {
212 env->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON); 176 env->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON);
213 should_reset_mouse_flags_ = true; 177 should_reset_mouse_flags_ = true;
214 } 178 }
215 179
216 in_move_loop_ = true; 180 in_move_loop_ = true;
217 canceled_ = false; 181 canceled_ = false;
218 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); 182 base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
219 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); 183 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
220 base::RunLoop run_loop; 184 base::RunLoop run_loop;
221 quit_closure_ = run_loop.QuitClosure(); 185 quit_closure_ = run_loop.QuitClosure();
222 run_loop.Run(); 186 run_loop.Run();
223 nested_dispatcher_ = old_dispatcher.Pass(); 187 nested_dispatcher_ = old_dispatcher.Pass();
224 return !canceled_; 188 return !canceled_;
225 } 189 }
226 190
227 void X11WholeScreenMoveLoop::UpdateCursor(gfx::NativeCursor cursor) {
228 if (in_move_loop_) {
229 // If we're still in the move loop, regrab the pointer with the updated
230 // cursor. Note: we can be called from handling an XdndStatus message after
231 // EndMoveLoop() was called, but before we return from the nested RunLoop.
232 GrabPointerAndKeyboard(cursor);
233 }
234 }
235
236 void X11WholeScreenMoveLoop::EndMoveLoop() { 191 void X11WholeScreenMoveLoop::EndMoveLoop() {
237 if (!in_move_loop_) 192 if (!in_move_loop_)
238 return; 193 return;
239 194
240 // Prevent DispatchMouseMovement from dispatching any posted motion event. 195 // Prevent DispatchMouseMovement from dispatching any posted motion event.
241 weak_factory_.InvalidateWeakPtrs(); 196 weak_factory_.InvalidateWeakPtrs();
242 last_xmotion_.type = LASTEvent; 197 last_xmotion_.type = LASTEvent;
243 198
244 // We undo our emulated mouse click from RunMoveLoop(); 199 // We undo our emulated mouse click from RunMoveLoop();
245 if (should_reset_mouse_flags_) { 200 if (should_reset_mouse_flags_) {
246 aura::Env::GetInstance()->set_mouse_button_flags(0); 201 aura::Env::GetInstance()->set_mouse_button_flags(0);
247 should_reset_mouse_flags_ = false; 202 should_reset_mouse_flags_ = false;
248 } 203 }
249 204
250 // TODO(erg): Is this ungrab the cause of having to click to give input focus
251 // on drawn out windows? Not ungrabbing here screws the X server until I kill
252 // the chrome process.
253
254 // Ungrab before we let go of the window.
255 XDisplay* display = gfx::GetXDisplay();
256 XUngrabPointer(display, CurrentTime);
257 XUngrabKeyboard(display, CurrentTime);
258
259 // Restore the previous dispatcher. 205 // Restore the previous dispatcher.
260 nested_dispatcher_.reset(); 206 nested_dispatcher_.reset();
261 drag_widget_.reset(); 207 drag_widget_.reset();
262 delegate_->OnMoveLoopEnded(); 208 delegate_->OnMoveLoopEnded();
263 XDestroyWindow(display, grab_input_window_);
264 grab_input_window_ = None;
265 209
266 in_move_loop_ = false; 210 in_move_loop_ = false;
267 quit_closure_.Run(); 211 quit_closure_.Run();
268 } 212 }
269 213
270 void X11WholeScreenMoveLoop::SetDragImage(const gfx::ImageSkia& image, 214 void X11WholeScreenMoveLoop::SetDragImage(const gfx::ImageSkia& image,
271 gfx::Vector2dF offset) { 215 gfx::Vector2dF offset) {
272 drag_image_ = image; 216 drag_image_ = image;
273 drag_offset_ = offset; 217 drag_offset_ = offset;
274 // Reset the Y offset, so that the drag-image is always just below the cursor, 218 // Reset the Y offset, so that the drag-image is always just below the cursor,
275 // so that it is possible to see where the cursor is going. 219 // so that it is possible to see where the cursor is going.
276 drag_offset_.set_y(0.f); 220 drag_offset_.set_y(0.f);
277 } 221 }
278 222
279 bool X11WholeScreenMoveLoop::GrabPointerAndKeyboard(gfx::NativeCursor cursor) {
280 XDisplay* display = gfx::GetXDisplay();
281 XGrabServer(display);
282
283 XUngrabPointer(display, CurrentTime);
284 int ret = XGrabPointer(
285 display,
286 grab_input_window_,
287 False,
288 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
289 GrabModeAsync,
290 GrabModeAsync,
291 None,
292 cursor.platform(),
293 CurrentTime);
294 if (ret != GrabSuccess) {
295 DLOG(ERROR) << "Grabbing pointer for dragging failed: "
296 << ui::GetX11ErrorString(display, ret);
297 } else {
298 XUngrabKeyboard(display, CurrentTime);
299 ret = XGrabKeyboard(
300 display,
301 grab_input_window_,
302 False,
303 GrabModeAsync,
304 GrabModeAsync,
305 CurrentTime);
306 if (ret != GrabSuccess) {
307 DLOG(ERROR) << "Grabbing keyboard for dragging failed: "
308 << ui::GetX11ErrorString(display, ret);
309 }
310 }
311
312 XUngrabServer(display);
313 XFlush(display);
314 return ret == GrabSuccess;
315 }
316
317 Window X11WholeScreenMoveLoop::CreateDragInputWindow(XDisplay* display) {
318 // Creates an invisible, InputOnly toplevel window. This window will receive
319 // all mouse movement for drags. It turns out that normal windows doing a
320 // grab doesn't redirect pointer motion events if the pointer isn't over the
321 // grabbing window. But InputOnly windows are able to grab everything. This
322 // is what GTK+ does, and I found a patch to KDE that did something similar.
323 unsigned long attribute_mask = CWEventMask | CWOverrideRedirect;
324 XSetWindowAttributes swa;
325 memset(&swa, 0, sizeof(swa));
326 swa.event_mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
327 KeyPressMask | KeyReleaseMask | StructureNotifyMask;
328 swa.override_redirect = True;
329 Window window = XCreateWindow(display,
330 DefaultRootWindow(display),
331 -100, -100, 10, 10,
332 0, CopyFromParent, InputOnly, CopyFromParent,
333 attribute_mask, &swa);
334 XMapRaised(display, window);
335 ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(window);
336 return window;
337 }
338
339 void X11WholeScreenMoveLoop::CreateDragImageWindow() { 223 void X11WholeScreenMoveLoop::CreateDragImageWindow() {
340 Widget* widget = new Widget; 224 Widget* widget = new Widget;
341 Widget::InitParams params(Widget::InitParams::TYPE_DRAG); 225 Widget::InitParams params(Widget::InitParams::TYPE_DRAG);
342 params.opacity = Widget::InitParams::OPAQUE_WINDOW; 226 params.opacity = Widget::InitParams::OPAQUE_WINDOW;
343 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 227 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
344 params.accept_events = false; 228 params.accept_events = false;
345 229
346 gfx::Point location = gfx::ToFlooredPoint( 230 gfx::Point location = gfx::ToFlooredPoint(
347 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint() - drag_offset_); 231 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint() - drag_offset_);
348 params.bounds = gfx::Rect(location, drag_image_.size()); 232 params.bounds = gfx::Rect(location, drag_image_.size());
349 widget->set_focus_on_creation(false); 233 widget->set_focus_on_creation(false);
350 widget->set_frame_type(Widget::FRAME_TYPE_FORCE_NATIVE); 234 widget->set_frame_type(Widget::FRAME_TYPE_FORCE_NATIVE);
351 widget->Init(params); 235 widget->Init(params);
352 widget->SetOpacity(kDragWidgetOpacity); 236 widget->SetOpacity(kDragWidgetOpacity);
353 widget->GetNativeWindow()->SetName("DragWindow"); 237 widget->GetNativeWindow()->SetName("DragWindow");
354 238
355 ImageView* image = new ImageView(); 239 ImageView* image = new ImageView();
356 image->SetImage(drag_image_); 240 image->SetImage(drag_image_);
357 image->SetBounds(0, 0, drag_image_.width(), drag_image_.height()); 241 image->SetBounds(0, 0, drag_image_.width(), drag_image_.height());
358 widget->SetContentsView(image); 242 widget->SetContentsView(image);
359 widget->Show(); 243 widget->Show();
360 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false); 244 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false);
361
362 drag_widget_.reset(widget); 245 drag_widget_.reset(widget);
363 } 246 }
364 247
365 bool X11WholeScreenMoveLoop::CheckIfIconValid() { 248 bool X11WholeScreenMoveLoop::CheckIfIconValid() {
366 // Because we need a GL context per window, we do a quick check so that we 249 // Because we need a GL context per window, we do a quick check so that we
367 // don't make another context if the window would just be displaying a mostly 250 // don't make another context if the window would just be displaying a mostly
368 // transparent image. 251 // transparent image.
369 const SkBitmap* in_bitmap = drag_image_.bitmap(); 252 const SkBitmap* in_bitmap = drag_image_.bitmap();
370 SkAutoLockPixels in_lock(*in_bitmap); 253 SkAutoLockPixels in_lock(*in_bitmap);
371 for (int y = 0; y < in_bitmap->height(); ++y) { 254 for (int y = 0; y < in_bitmap->height(); ++y) {
372 uint32* in_row = in_bitmap->getAddr32(0, y); 255 uint32* in_row = in_bitmap->getAddr32(0, y);
373 256
374 for (int x = 0; x < in_bitmap->width(); ++x) { 257 for (int x = 0; x < in_bitmap->width(); ++x) {
375 if (SkColorGetA(in_row[x]) > kMinAlpha) 258 if (SkColorGetA(in_row[x]) > kMinAlpha)
376 return true; 259 return true;
377 } 260 }
378 } 261 }
379 262
380 return false; 263 return false;
381 } 264 }
382 265
383 } // namespace views 266 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698