| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 void Control::PaintMultipleRects(pp::ImageData* image_data, | 38 void Control::PaintMultipleRects(pp::ImageData* image_data, |
| 39 const std::list<pp::Rect>& rects) { | 39 const std::list<pp::Rect>& rects) { |
| 40 DCHECK(rects.size() > 0); | 40 DCHECK(rects.size() > 0); |
| 41 if (rects.size() == 1) { | 41 if (rects.size() == 1) { |
| 42 Paint(image_data, rects.front()); | 42 Paint(image_data, rects.front()); |
| 43 return; | 43 return; |
| 44 } | 44 } |
| 45 | 45 |
| 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 // paining (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()) |
| 53 return; |
| 54 |
| 52 pp::Rect draw_rc = pp::Rect(image_data->size()).Intersect(rect()); | 55 pp::Rect draw_rc = pp::Rect(image_data->size()).Intersect(rect()); |
| 53 pp::Rect ctrl_rc = pp::Rect(rect().point() - draw_rc.point(), draw_rc.size()); | 56 pp::Rect ctrl_rc = pp::Rect(rect().point() - draw_rc.point(), draw_rc.size()); |
| 54 CopyImage(*image_data, draw_rc, &buffer, ctrl_rc, false); | 57 CopyImage(*image_data, draw_rc, &buffer, ctrl_rc, false); |
| 55 | 58 |
| 56 // 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. |
| 57 // 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 |
| 58 // buffer, we don't need to invalidate here. | 61 // buffer, we don't need to invalidate here. |
| 59 pp::Rect temp = rect(); | 62 pp::Rect temp = rect(); |
| 60 MoveTo(pp::Point(0, 0), false); | 63 MoveTo(pp::Point(0, 0), false); |
| 61 Paint(&buffer, ctrl_rc); | 64 Paint(&buffer, ctrl_rc); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 owner()->Invalidate(id(), old_rc); | 108 owner()->Invalidate(id(), old_rc); |
| 106 owner()->Invalidate(id(), rect()); | 109 owner()->Invalidate(id(), rect()); |
| 107 } | 110 } |
| 108 } | 111 } |
| 109 | 112 |
| 110 void Control::MoveTo(const pp::Point& origin, bool invalidate) { | 113 void Control::MoveTo(const pp::Point& origin, bool invalidate) { |
| 111 MoveBy(origin - rc_.point(), invalidate); | 114 MoveBy(origin - rc_.point(), invalidate); |
| 112 } | 115 } |
| 113 | 116 |
| 114 } // namespace chrome_pdf | 117 } // namespace chrome_pdf |
| OLD | NEW |