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

Unified Diff: ui/compositor/paint_recorder.cc

Issue 1101783002: ui: Cache the output of View::OnPaint when the View isn't invalid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cache: . Created 5 years, 8 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
« no previous file with comments | « ui/compositor/paint_recorder.h ('k') | ui/views/view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/paint_recorder.cc
diff --git a/ui/compositor/paint_recorder.cc b/ui/compositor/paint_recorder.cc
index 15aa0fb8edff443e07c3d98a19276fed1b66ca86..80fb616a35fa169554fbedeb61e73692368db7f6 100644
--- a/ui/compositor/paint_recorder.cc
+++ b/ui/compositor/paint_recorder.cc
@@ -7,14 +7,15 @@
#include "cc/resources/display_item_list.h"
#include "cc/resources/drawing_display_item.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
+#include "ui/compositor/paint_cache.h"
#include "ui/compositor/paint_context.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/skia_util.h"
namespace ui {
-PaintRecorder::PaintRecorder(const PaintContext& context)
- : context_(context), canvas_(context.canvas_) {
+PaintRecorder::PaintRecorder(const PaintContext& context, PaintCache* cache)
+ : context_(context), canvas_(context.canvas_), cache_(cache) {
#if DCHECK_IS_ON()
DCHECK(!context.inside_paint_recorder_);
context.inside_paint_recorder_ = true;
@@ -34,15 +35,23 @@ PaintRecorder::PaintRecorder(const PaintContext& context)
}
}
+PaintRecorder::PaintRecorder(const PaintContext& context)
+ : PaintRecorder(context, nullptr) {
+}
+
PaintRecorder::~PaintRecorder() {
#if DCHECK_IS_ON()
context_.inside_paint_recorder_ = false;
#endif
- if (context_.list_) {
- context_.list_->AppendItem(cc::DrawingDisplayItem::Create(
- skia::AdoptRef(context_.recorder_->endRecordingAsPicture())));
- }
+ if (!context_.list_)
+ return;
+
+ scoped_ptr<cc::DrawingDisplayItem> item = cc::DrawingDisplayItem::Create(
+ skia::AdoptRef(context_.recorder_->endRecordingAsPicture()));
+ if (cache_)
+ cache_->SetCache(item->Clone());
+ context_.list_->AppendItem(item.Pass());
}
} // namespace ui
« no previous file with comments | « ui/compositor/paint_recorder.h ('k') | ui/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698