Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: ppapi/examples/gamepad/gamepad.cc

Issue 1182283002: Plugin Power Saver: Fix Dr. Memory leaks in browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ppapi/tests/power_saver_test_plugin.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <cmath> 6 #include <cmath>
7 #include <stdarg.h> 7 #include <stdarg.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 9
10 #include "ppapi/c/ppb_gamepad.h" 10 #include "ppapi/c/ppb_gamepad.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 height_ = rect.size().height(); 62 height_ = rect.size().height();
63 63
64 device_context_ = pp::Graphics2D(this, pp::Size(width_, height_), false); 64 device_context_ = pp::Graphics2D(this, pp::Size(width_, height_), false);
65 if (!BindGraphics(device_context_)) 65 if (!BindGraphics(device_context_))
66 return; 66 return;
67 67
68 Paint(); 68 Paint();
69 } 69 }
70 70
71 void OnFlush(int32_t) { 71 void OnFlush(int32_t) {
72 // This plugin continuously paints because it continously samples the
73 // gamepad and paints its updated state.
72 Paint(); 74 Paint();
73 } 75 }
74 76
75 private: 77 private:
76 void Paint() { 78 void Paint() {
77 pp::ImageData image = PaintImage(device_context_.size()); 79 pp::ImageData image = PaintImage(device_context_.size());
78 if (!image.is_null()) { 80 if (!image.is_null()) {
79 device_context_.ReplaceContents(&image); 81 device_context_.ReplaceContents(&image);
80 device_context_.Flush( 82 device_context_.Flush(
81 callback_factory_.NewCallback(&MyInstance::OnFlush)); 83 callback_factory_.NewCallback(&MyInstance::OnFlush));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 }; 140 };
139 141
140 namespace pp { 142 namespace pp {
141 143
142 // Factory function for your specialization of the Module object. 144 // Factory function for your specialization of the Module object.
143 Module* CreateModule() { 145 Module* CreateModule() {
144 return new MyModule(); 146 return new MyModule();
145 } 147 }
146 148
147 } // namespace pp 149 } // namespace pp
148
OLDNEW
« no previous file with comments | « no previous file | ppapi/tests/power_saver_test_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698