| 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 <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 PP_NOTREACHED(); | 123 PP_NOTREACHED(); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 void ScheduleNextTimer() { | 129 void ScheduleNextTimer() { |
| 130 PP_DCHECK(timer_interval_ > 0); | 130 PP_DCHECK(timer_interval_ > 0); |
| 131 pp::Module::Get()->core()->CallOnMainThread( | 131 pp::Module::Get()->core()->CallOnMainThread( |
| 132 timer_interval_, | 132 timer_interval_, |
| 133 callback_factory_.NewRequiredCallback(&MyInstance::OnTimer), | 133 callback_factory_.NewCallback(&MyInstance::OnTimer), |
| 134 0); | 134 0); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void OnTimer(int32_t) { | 137 void OnTimer(int32_t) { |
| 138 ScheduleNextTimer(); | 138 ScheduleNextTimer(); |
| 139 Paint(); | 139 Paint(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void DidFlush(int32_t result) { | 142 void DidFlush(int32_t result) { |
| 143 waiting_for_flush_completion_ = false; | 143 waiting_for_flush_completion_ = false; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 154 pending_paint_ = false; | 154 pending_paint_ = false; |
| 155 | 155 |
| 156 if (size_.IsEmpty()) | 156 if (size_.IsEmpty()) |
| 157 return; // Nothing to do. | 157 return; // Nothing to do. |
| 158 | 158 |
| 159 pp::ImageData image = PaintImage(size_); | 159 pp::ImageData image = PaintImage(size_); |
| 160 if (!image.is_null()) { | 160 if (!image.is_null()) { |
| 161 device_context_.ReplaceContents(&image); | 161 device_context_.ReplaceContents(&image); |
| 162 waiting_for_flush_completion_ = true; | 162 waiting_for_flush_completion_ = true; |
| 163 device_context_.Flush( | 163 device_context_.Flush( |
| 164 callback_factory_.NewRequiredCallback(&MyInstance::DidFlush)); | 164 callback_factory_.NewCallback(&MyInstance::DidFlush)); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 pp::ImageData PaintImage(const pp::Size& size) { | 168 pp::ImageData PaintImage(const pp::Size& size) { |
| 169 pp::ImageData image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL, size, false); | 169 pp::ImageData image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL, size, false); |
| 170 if (image.is_null()) | 170 if (image.is_null()) |
| 171 return image; | 171 return image; |
| 172 | 172 |
| 173 // Clear to dark grey. | 173 // Clear to dark grey. |
| 174 for (int y = 0; y < size.height(); y++) { | 174 for (int y = 0; y < size.height(); y++) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 }; | 287 }; |
| 288 | 288 |
| 289 namespace pp { | 289 namespace pp { |
| 290 | 290 |
| 291 // Factory function for your specialization of the Module object. | 291 // Factory function for your specialization of the Module object. |
| 292 Module* CreateModule() { | 292 Module* CreateModule() { |
| 293 return new MyModule(); | 293 return new MyModule(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace pp | 296 } // namespace pp |
| OLD | NEW |