| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "ppapi/cpp/graphics_2d.h" | 7 #include "ppapi/cpp/graphics_2d.h" |
| 8 #include "ppapi/cpp/image_data.h" | 8 #include "ppapi/cpp/image_data.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" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 Paint(); | 50 Paint(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 void Paint() { | 54 void Paint() { |
| 55 pp::ImageData image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL, | 55 pp::ImageData image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL, |
| 56 view_.GetRect().size(), true); | 56 view_.GetRect().size(), true); |
| 57 if (image.is_null()) | 57 if (image.is_null()) |
| 58 return; | 58 return; |
| 59 | 59 |
| 60 // Draw black and white stripes to present an "interesting" keyframe. | 60 // Draw blue and green checkerboard pattern to show "interesting" keyframe. |
| 61 const int kSquareSizePixels = 8; |
| 61 for (int y = 0; y < view_.GetRect().size().height(); ++y) { | 62 for (int y = 0; y < view_.GetRect().size().height(); ++y) { |
| 62 for (int x = 0; x < view_.GetRect().size().width(); ++x) { | 63 for (int x = 0; x < view_.GetRect().size().width(); ++x) { |
| 63 uint32_t color = x % 2 ? 0xFF0000FF : 0xFFFFFFFF; | 64 int x_square = x / kSquareSizePixels; |
| 65 int y_square = y / kSquareSizePixels; |
| 66 uint32_t color = ((x_square + y_square) % 2) ? 0xFF0000FF : 0xFF00FF00; |
| 64 *image.GetAddr32(pp::Point(x, y)) = color; | 67 *image.GetAddr32(pp::Point(x, y)) = color; |
| 65 } | 68 } |
| 66 } | 69 } |
| 67 | 70 |
| 68 device_context_.ReplaceContents(&image); | 71 device_context_.ReplaceContents(&image); |
| 69 device_context_.Flush( | 72 device_context_.Flush( |
| 70 pp::CompletionCallback(&DummyCompletionCallback, nullptr)); | 73 pp::CompletionCallback(&DummyCompletionCallback, nullptr)); |
| 71 } | 74 } |
| 72 | 75 |
| 73 pp::View view_; | 76 pp::View view_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 84 } | 87 } |
| 85 }; | 88 }; |
| 86 | 89 |
| 87 namespace pp { | 90 namespace pp { |
| 88 | 91 |
| 89 Module* CreateModule() { | 92 Module* CreateModule() { |
| 90 return new PowerSaverTestModule(); | 93 return new PowerSaverTestModule(); |
| 91 } | 94 } |
| 92 | 95 |
| 93 } // namespace pp | 96 } // namespace pp |
| OLD | NEW |