| 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 "ppapi/c/pp_input_event.h" | 5 #include "ppapi/c/pp_input_event.h" |
| 6 #include "ppapi/cpp/graphics_2d.h" | 6 #include "ppapi/cpp/graphics_2d.h" |
| 7 #include "ppapi/cpp/image_data.h" | 7 #include "ppapi/cpp/image_data.h" |
| 8 #include "ppapi/cpp/input_event.h" | 8 #include "ppapi/cpp/input_event.h" |
| 9 #include "ppapi/cpp/instance.h" | 9 #include "ppapi/cpp/instance.h" |
| 10 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
| 11 #include "ppapi/cpp/size.h" | 11 #include "ppapi/cpp/size.h" |
| 12 #include "ppapi/cpp/view.h" |
| 12 #include "ppapi/utility/graphics/paint_manager.h" | 13 #include "ppapi/utility/graphics/paint_manager.h" |
| 13 | 14 |
| 14 // Number of pixels to each side of the center of the square that we draw. | 15 // Number of pixels to each side of the center of the square that we draw. |
| 15 static const int kSquareRadius = 2; | 16 static const int kSquareRadius = 2; |
| 16 | 17 |
| 17 // We identify our square by the center point. This computes the rect for the | 18 // We identify our square by the center point. This computes the rect for the |
| 18 // square given that point. | 19 // square given that point. |
| 19 pp::Rect SquareForPoint(int x, int y) { | 20 pp::Rect SquareForPoint(int x, int y) { |
| 20 return PP_MakeRectFromXYWH(x - kSquareRadius, y - kSquareRadius, | 21 return PP_MakeRectFromXYWH(x - kSquareRadius, y - kSquareRadius, |
| 21 kSquareRadius * 2 + 1, kSquareRadius * 2 + 1); | 22 kSquareRadius * 2 + 1, kSquareRadius * 2 + 1); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 UpdateSquare(static_cast<int>(mouse_event.GetPosition().x()), | 64 UpdateSquare(static_cast<int>(mouse_event.GetPosition().x()), |
| 64 static_cast<int>(mouse_event.GetPosition().y())); | 65 static_cast<int>(mouse_event.GetPosition().y())); |
| 65 } | 66 } |
| 66 return true; | 67 return true; |
| 67 } | 68 } |
| 68 default: | 69 default: |
| 69 return false; | 70 return false; |
| 70 } | 71 } |
| 71 } | 72 } |
| 72 | 73 |
| 73 virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip) { | 74 virtual void DidChangeView(const pp::View& view) { |
| 74 paint_manager_.SetSize(position.size()); | 75 paint_manager_.SetSize(view.GetRect().size()); |
| 75 } | 76 } |
| 76 | 77 |
| 77 // PaintManager::Client implementation. | 78 // PaintManager::Client implementation. |
| 78 virtual bool OnPaint(pp::Graphics2D& graphics_2d, | 79 virtual bool OnPaint(pp::Graphics2D& graphics_2d, |
| 79 const std::vector<pp::Rect>& paint_rects, | 80 const std::vector<pp::Rect>& paint_rects, |
| 80 const pp::Rect& paint_bounds) { | 81 const pp::Rect& paint_bounds) { |
| 81 // Make an image just large enough to hold all dirty rects. We won't | 82 // Make an image just large enough to hold all dirty rects. We won't |
| 82 // actually paint all of these pixels below, but rather just the dirty | 83 // actually paint all of these pixels below, but rather just the dirty |
| 83 // ones. Since image allocation can be somewhat heavyweight, we wouldn't | 84 // ones. Since image allocation can be somewhat heavyweight, we wouldn't |
| 84 // want to allocate separate images in the case of multiple dirty rects. | 85 // want to allocate separate images in the case of multiple dirty rects. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 namespace pp { | 154 namespace pp { |
| 154 | 155 |
| 155 // Factory function for your specialization of the Module object. | 156 // Factory function for your specialization of the Module object. |
| 156 Module* CreateModule() { | 157 Module* CreateModule() { |
| 157 return new MyModule(); | 158 return new MyModule(); |
| 158 } | 159 } |
| 159 | 160 |
| 160 } // namespace pp | 161 } // namespace pp |
| OLD | NEW |