OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/widget/root_view.h" | 5 #include "views/widget/root_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #if defined(TOUCH_UI) && defined(HAVE_XINPUT2) | 9 #if defined(TOUCH_UI) && defined(HAVE_XINPUT2) |
10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // The target root view. | 56 // The target root view. |
57 RootView* root_view_; | 57 RootView* root_view_; |
58 | 58 |
59 DISALLOW_COPY_AND_ASSIGN(PaintTask); | 59 DISALLOW_COPY_AND_ASSIGN(PaintTask); |
60 }; | 60 }; |
61 | 61 |
62 namespace { | 62 namespace { |
63 | 63 |
64 #ifndef NDEBUG | 64 #ifndef NDEBUG |
65 // Sets the value of RootView's |is_processing_paint_| member to true as long | 65 // Sets the value of RootView's |is_processing_paint_| member to true as long |
66 // as ProcessPaint is being called. Sets it to |false| when it returns. | 66 // as Paint() is being called. Sets it to |false| when it returns. |
67 class ScopedProcessingPaint { | 67 class ScopedProcessingPaint { |
68 public: | 68 public: |
69 explicit ScopedProcessingPaint(bool* is_processing_paint) | 69 explicit ScopedProcessingPaint(bool* is_processing_paint) |
70 : is_processing_paint_(is_processing_paint) { | 70 : is_processing_paint_(is_processing_paint) { |
71 *is_processing_paint_ = true; | 71 *is_processing_paint_ = true; |
72 } | 72 } |
73 | 73 |
74 ~ScopedProcessingPaint() { | 74 ~ScopedProcessingPaint() { |
75 *is_processing_paint_ = false; | 75 *is_processing_paint_ = false; |
76 } | 76 } |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 invalid_rect_urgent_ = true; | 351 invalid_rect_urgent_ = true; |
352 } else { | 352 } else { |
353 if (!pending_paint_task_) { | 353 if (!pending_paint_task_) { |
354 pending_paint_task_ = new PaintTask(this); | 354 pending_paint_task_ = new PaintTask(this); |
355 MessageLoop::current()->PostTask(FROM_HERE, pending_paint_task_); | 355 MessageLoop::current()->PostTask(FROM_HERE, pending_paint_task_); |
356 } | 356 } |
357 paint_task_needed_ = true; | 357 paint_task_needed_ = true; |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 void RootView::ProcessPaint(gfx::Canvas* canvas) { | 361 void RootView::Paint(gfx::Canvas* canvas) { |
362 #ifndef NDEBUG | 362 #ifndef NDEBUG |
363 ScopedProcessingPaint processing_paint(&is_processing_paint_); | 363 ScopedProcessingPaint processing_paint(&is_processing_paint_); |
364 #endif | 364 #endif |
365 | 365 |
366 // Clip the invalid rect to our bounds. If a view is in a scrollview | 366 // Clip the invalid rect to our bounds. If a view is in a scrollview |
367 // it could be a lot larger | 367 // it could be a lot larger |
368 invalid_rect_ = GetScheduledPaintRectConstrainedToSize(); | 368 invalid_rect_ = GetScheduledPaintRectConstrainedToSize(); |
369 | 369 |
370 if (invalid_rect_.IsEmpty()) | 370 if (invalid_rect_.IsEmpty()) |
371 return; | 371 return; |
372 | 372 |
373 // Clear the background. | 373 // Clear the background. |
374 canvas->AsCanvasSkia()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); | 374 canvas->AsCanvasSkia()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); |
375 | 375 |
376 // Save the current transforms. | 376 // Save the current transforms. |
377 canvas->Save(); | 377 canvas->Save(); |
378 | 378 |
379 // Set the clip rect according to the invalid rect. | 379 // Set the clip rect according to the invalid rect. |
380 int clip_x = invalid_rect_.x() + x(); | 380 int clip_x = invalid_rect_.x() + x(); |
381 int clip_y = invalid_rect_.y() + y(); | 381 int clip_y = invalid_rect_.y() + y(); |
382 canvas->ClipRectInt(clip_x, clip_y, invalid_rect_.width(), | 382 canvas->ClipRectInt(clip_x, clip_y, invalid_rect_.width(), |
383 invalid_rect_.height()); | 383 invalid_rect_.height()); |
384 | 384 |
385 // Paint the tree | 385 // Paint the tree |
386 View::ProcessPaint(canvas); | 386 View::Paint(canvas); |
387 | 387 |
388 // Restore the previous transform | 388 // Restore the previous transform |
389 canvas->Restore(); | 389 canvas->Restore(); |
390 | 390 |
391 ClearPaintRect(); | 391 ClearPaintRect(); |
392 } | 392 } |
393 | 393 |
394 void RootView::PaintNow() { | 394 void RootView::PaintNow() { |
395 if (pending_paint_task_) { | 395 if (pending_paint_task_) { |
396 pending_paint_task_->Cancel(); | 396 pending_paint_task_->Cancel(); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 last_mouse_event_y_ = e.y(); | 811 last_mouse_event_y_ = e.y(); |
812 } | 812 } |
813 | 813 |
814 // Drag and drop --------------------------------------------------------------- | 814 // Drag and drop --------------------------------------------------------------- |
815 | 815 |
816 View* RootView::GetDragView() { | 816 View* RootView::GetDragView() { |
817 return drag_view_; | 817 return drag_view_; |
818 } | 818 } |
819 | 819 |
820 } // namespace views | 820 } // namespace views |
OLD | NEW |