| OLD | NEW |
| 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 "pdf/control.h" | 5 #include "pdf/control.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "pdf/draw_utils.h" | 8 #include "pdf/draw_utils.h" |
| 9 | 9 |
| 10 namespace chrome_pdf { | 10 namespace chrome_pdf { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // Some rects in the input list may overlap. To prevent double | 46 // Some rects in the input list may overlap. To prevent double |
| 47 // painting (causes problems with semi-transparent controls) we'll | 47 // painting (causes problems with semi-transparent controls) we'll |
| 48 // paint control into buffer image data only once and copy requested | 48 // paint control into buffer image data only once and copy requested |
| 49 // rectangles. | 49 // rectangles. |
| 50 pp::ImageData buffer(owner()->GetInstance(), image_data->format(), | 50 pp::ImageData buffer(owner()->GetInstance(), image_data->format(), |
| 51 rect().size(), false); | 51 rect().size(), false); |
| 52 if (buffer.is_null()) | 52 if (buffer.is_null()) |
| 53 return; | 53 return; |
| 54 | 54 |
| 55 pp::Rect draw_rc = pp::Rect(image_data->size()).Intersect(rect()); | 55 pp::Rect draw_rc = pp::Rect(image_data->size()).Intersect(rect()); |
| 56 pp::Rect ctrl_rc = pp::Rect(rect().point() - draw_rc.point(), draw_rc.size()); | 56 pp::Rect ctrl_rc = pp::Rect(draw_rc.point() - rect().point(), draw_rc.size()); |
| 57 CopyImage(*image_data, draw_rc, &buffer, ctrl_rc, false); | 57 CopyImage(*image_data, draw_rc, &buffer, ctrl_rc, false); |
| 58 | 58 |
| 59 // Temporary move control to origin (0,0) and draw it into temp buffer. | 59 // Temporary move control to origin (0,0) and draw it into temp buffer. |
| 60 // Move to the original position afterward. Since this is going on temp | 60 // Move to the original position afterward. Since this is going on temp |
| 61 // buffer, we don't need to invalidate here. | 61 // buffer, we don't need to invalidate here. |
| 62 pp::Rect temp = rect(); | 62 pp::Rect temp = rect(); |
| 63 MoveTo(pp::Point(0, 0), false); | 63 MoveTo(pp::Point(0, 0), false); |
| 64 Paint(&buffer, ctrl_rc); | 64 Paint(&buffer, ctrl_rc); |
| 65 MoveTo(temp.point(), false); | 65 MoveTo(temp.point(), false); |
| 66 | 66 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 owner()->Invalidate(id(), old_rc); | 108 owner()->Invalidate(id(), old_rc); |
| 109 owner()->Invalidate(id(), rect()); | 109 owner()->Invalidate(id(), rect()); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 void Control::MoveTo(const pp::Point& origin, bool invalidate) { | 113 void Control::MoveTo(const pp::Point& origin, bool invalidate) { |
| 114 MoveBy(origin - rc_.point(), invalidate); | 114 MoveBy(origin - rc_.point(), invalidate); |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace chrome_pdf | 117 } // namespace chrome_pdf |
| OLD | NEW |