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

Side by Side Diff: ui/compositor/paint_recorder.cc

Issue 1423653005: Further plumb visual rect into cc:DisplayItemList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cc unit tests. Created 5 years, 1 month 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
OLDNEW
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 "ui/compositor/paint_recorder.h" 5 #include "ui/compositor/paint_recorder.h"
6 6
7 #include "cc/playback/display_item_list.h" 7 #include "cc/playback/display_item_list.h"
8 #include "cc/playback/drawing_display_item.h" 8 #include "cc/playback/drawing_display_item.h"
9 #include "third_party/skia/include/core/SkPictureRecorder.h" 9 #include "third_party/skia/include/core/SkPictureRecorder.h"
10 #include "ui/compositor/paint_cache.h" 10 #include "ui/compositor/paint_cache.h"
11 #include "ui/compositor/paint_context.h" 11 #include "ui/compositor/paint_context.h"
12 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/skia_util.h" 13 #include "ui/gfx/skia_util.h"
13 14
14 namespace ui { 15 namespace ui {
15 16
16 PaintRecorder::PaintRecorder(const PaintContext& context, 17 PaintRecorder::PaintRecorder(const PaintContext& context,
17 const gfx::Size& recording_size, 18 const gfx::Size& recording_size,
18 PaintCache* cache) 19 PaintCache* cache)
19 : context_(context), 20 : context_(context),
20 // The SkCanvas reference returned by beginRecording is shared with 21 // The SkCanvas reference returned by beginRecording is shared with
21 // the recorder_ so no need to store a RefPtr to it on this class, we just 22 // the recorder_ so no need to store a RefPtr to it on this class, we just
22 // store the gfx::Canvas. 23 // store the gfx::Canvas.
23 canvas_(skia::SharePtr(context.recorder_->beginRecording( 24 canvas_(skia::SharePtr(context.recorder_->beginRecording(
24 gfx::RectToSkRect(gfx::Rect(recording_size)))) 25 gfx::RectToSkRect(gfx::Rect(recording_size))))
25 .get(), 26 .get(),
26 context.device_scale_factor_), 27 context.device_scale_factor_),
27 cache_(cache) { 28 cache_(cache),
29 visual_rect_(context.ToVisualRect(recording_size)) {
danakj 2015/11/06 00:32:45 ditto, store the recording_size instead?
wkorman 2015/11/16 19:01:03 Same as above, can explore subsequently.
28 #if DCHECK_IS_ON() 30 #if DCHECK_IS_ON()
29 DCHECK(!context.inside_paint_recorder_); 31 DCHECK(!context.inside_paint_recorder_);
30 context.inside_paint_recorder_ = true; 32 context.inside_paint_recorder_ = true;
31 #endif 33 #endif
32 } 34 }
33 35
34 PaintRecorder::PaintRecorder(const PaintContext& context, 36 PaintRecorder::PaintRecorder(const PaintContext& context,
35 const gfx::Size& recording_size) 37 const gfx::Size& recording_size)
36 : PaintRecorder(context, recording_size, nullptr) { 38 : PaintRecorder(context, recording_size, nullptr) {
37 } 39 }
38 40
39 PaintRecorder::~PaintRecorder() { 41 PaintRecorder::~PaintRecorder() {
40 #if DCHECK_IS_ON() 42 #if DCHECK_IS_ON()
41 context_.inside_paint_recorder_ = false; 43 context_.inside_paint_recorder_ = false;
42 #endif 44 #endif
43 45
44 auto* item = context_.list_->CreateAndAppendItem<cc::DrawingDisplayItem>(); 46 auto* item =
47 context_.list_->CreateAndAppendItem<cc::DrawingDisplayItem>(visual_rect_);
45 item->SetNew(skia::AdoptRef(context_.recorder_->endRecordingAsPicture())); 48 item->SetNew(skia::AdoptRef(context_.recorder_->endRecordingAsPicture()));
46 if (cache_) 49 if (cache_)
47 cache_->SetCache(item); 50 cache_->SetCache(visual_rect_, item);
48 } 51 }
49 52
50 } // namespace ui 53 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698