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

Unified Diff: webkit/plugins/ppapi/ppb_graphics_2d_impl.cc

Issue 10823378: Cache image data objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 40a88dff63e451195f43dc38ad7223a57b76985b..9ad9258a2e90bcab8ecf3806ddda4f105baef22d 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -322,7 +322,8 @@ void PPB_Graphics2D_Impl::ReplaceContents(PP_Resource image_data) {
queued_operations_.push_back(operation);
}
-int32_t PPB_Graphics2D_Impl::Flush(scoped_refptr<TrackedCallback> callback) {
+int32_t PPB_Graphics2D_Impl::Flush(scoped_refptr<TrackedCallback> callback,
+ PP_Resource* old_image_data) {
TRACE_EVENT0("pepper", "PPB_Graphics2D_Impl::Flush");
// Don't allow more than one pending flush at a time.
if (HasPendingFlush())
@@ -345,7 +346,8 @@ int32_t PPB_Graphics2D_Impl::Flush(scoped_refptr<TrackedCallback> callback) {
&op_rect);
break;
case QueuedOperation::REPLACE:
- ExecuteReplaceContents(operation.replace_image, &op_rect);
+ ExecuteReplaceContents(operation.replace_image, &op_rect,
+ old_image_data);
yzshen1 2012/08/21 22:07:24 There might be more than one ReplaceContents(). If
brettw 2012/08/21 23:24:58 Good catch!
break;
}
@@ -695,7 +697,8 @@ void PPB_Graphics2D_Impl::ExecuteScroll(const gfx::Rect& clip,
}
void PPB_Graphics2D_Impl::ExecuteReplaceContents(PPB_ImageData_Impl* image,
- gfx::Rect* invalidated_rect) {
+ gfx::Rect* invalidated_rect,
+ PP_Resource* old_image_data) {
if (image->format() != image_data_->format()) {
DCHECK(image->width() == image_data_->width() &&
image->height() == image_data_->height());
@@ -711,8 +714,10 @@ void PPB_Graphics2D_Impl::ExecuteReplaceContents(PPB_ImageData_Impl* image,
// guarantee that the current backing store is always mapped.
if (!image->Map())
return;
- image_data_->Unmap();
- image_data_->Swap(image);
+
+ if (old_image_data)
+ *old_image_data = image_data_->GetReference();
+ image_data_ = image;
}
*invalidated_rect = gfx::Rect(0, 0,
image_data_->width(), image_data_->height());

Powered by Google App Engine
This is Rietveld 408576698