diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-22 18:22:13 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-22 18:22:13 +0000 |
commit | c42835776b8cfe6a6388f2424244f3f7d53955c0 (patch) | |
tree | 5007d1cfd5c035fa2540eb90aae1340a9d9947c6 /ppapi/examples | |
parent | b2e7f957f7fed546c540a0ee7123dcb976712022 (diff) | |
download | chromium_src-c42835776b8cfe6a6388f2424244f3f7d53955c0.zip chromium_src-c42835776b8cfe6a6388f2424244f3f7d53955c0.tar.gz chromium_src-c42835776b8cfe6a6388f2424244f3f7d53955c0.tar.bz2 |
Cache image data objects.
This will re-use ImageData and mapped memory when you do ReplaceContents within a few seconds of doing a previous one. Hopefully this will speed up 2D painting.
BUG=142507
Review URL: https://chromiumcodereview.appspot.com/10823378
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152792 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/examples')
-rw-r--r-- | ppapi/examples/2d/paint_manager_example.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ppapi/examples/2d/paint_manager_example.cc b/ppapi/examples/2d/paint_manager_example.cc index 86bdbe7..430f422 100644 --- a/ppapi/examples/2d/paint_manager_example.cc +++ b/ppapi/examples/2d/paint_manager_example.cc @@ -78,7 +78,9 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client { // PaintManager::Client implementation. virtual bool OnPaint(pp::Graphics2D& graphics_2d, const std::vector<pp::Rect>& paint_rects, - const pp::Rect& paint_bounds) { + const pp::Rect& paint_bounds_unused) { + pp::Rect paint_bounds(paint_manager_.GetEffectiveSize()); + // Make an image just large enough to hold all dirty rects. We won't // actually paint all of these pixels below, but rather just the dirty // ones. Since image allocation can be somewhat heavyweight, we wouldn't @@ -96,6 +98,7 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client { // Note that the aggregator used by the paint manager won't give us // multiple regions that overlap, so we don't have to worry about double // painting in this code. +/* for (size_t i = 0; i < paint_rects.size(); i++) { // Since our image is just the invalid region, we need to offset the // areas we paint by that much. This is just a light blue background. @@ -106,6 +109,7 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client { paint_rects[i].height(), 0xFFAAAAFF); } + */ // Paint the square black. Because we're lazy, we do this outside of the // loop above. @@ -117,7 +121,7 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client { square.height(), 0xFF000000); - graphics_2d.PaintImageData(updated_image, paint_bounds.point()); + graphics_2d.ReplaceContents(&updated_image); return true; } |