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

Side by Side Diff: cc/resources/picture.cc

Issue 236633008: Switching Chromium to use new Skia SkPictureRecorder API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update to ToT Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/picture_layer.cc ('k') | cc/resources/picture_pile_impl.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/resources/picture.h" 5 #include "cc/resources/picture.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 RecordingMode recording_mode) { 242 RecordingMode recording_mode) {
243 TRACE_EVENT2("cc", 243 TRACE_EVENT2("cc",
244 "Picture::Record", 244 "Picture::Record",
245 "data", 245 "data",
246 AsTraceableRecordData(), 246 AsTraceableRecordData(),
247 "recording_mode", 247 "recording_mode",
248 recording_mode); 248 recording_mode);
249 249
250 DCHECK(!picture_); 250 DCHECK(!picture_);
251 DCHECK(!tile_grid_info.fTileInterval.isEmpty()); 251 DCHECK(!tile_grid_info.fTileInterval.isEmpty());
252 picture_ = skia::AdoptRef(new SkTileGridPicture( 252
253 layer_rect_.width(), layer_rect_.height(), tile_grid_info)); 253 skia::RefPtr<SkPictureFactory> factory =
254 skia::AdoptRef(new SkTileGridPictureFactory(tile_grid_info));
255 SkPictureRecorder recorder(factory.get());
254 256
255 skia::RefPtr<SkCanvas> canvas; 257 skia::RefPtr<SkCanvas> canvas;
258 canvas = skia::SharePtr(recorder.beginRecording(
259 layer_rect_.width(),
260 layer_rect_.height(),
261 SkPicture::kUsePathBoundsForClip_RecordingFlag |
262 SkPicture::kOptimizeForClippedPlayback_RecordingFlag));
263
256 switch (recording_mode) { 264 switch (recording_mode) {
257 case RECORD_NORMALLY: 265 case RECORD_NORMALLY:
258 canvas = skia::SharePtr(picture_->beginRecording( 266 // Already setup for normal recording
259 layer_rect_.width(),
260 layer_rect_.height(),
261 SkPicture::kUsePathBoundsForClip_RecordingFlag |
262 SkPicture::kOptimizeForClippedPlayback_RecordingFlag));
263 break; 267 break;
264 case RECORD_WITH_SK_NULL_CANVAS: 268 case RECORD_WITH_SK_NULL_CANVAS:
265 canvas = skia::AdoptRef(SkCreateNullCanvas()); 269 canvas = skia::AdoptRef(SkCreateNullCanvas());
266 break; 270 break;
267 case RECORD_WITH_PAINTING_DISABLED: 271 case RECORD_WITH_PAINTING_DISABLED:
268 // Blink's GraphicsContext will disable painting when given a NULL 272 // Blink's GraphicsContext will disable painting when given a NULL
269 // canvas. 273 // canvas.
274 canvas.clear();
270 break; 275 break;
271 default: 276 default:
272 NOTREACHED(); 277 NOTREACHED();
273 } 278 }
274 279
275 if (canvas) { 280 if (canvas) {
276 canvas->save(); 281 canvas->save();
277 canvas->translate(SkFloatToScalar(-layer_rect_.x()), 282 canvas->translate(SkFloatToScalar(-layer_rect_.x()),
278 SkFloatToScalar(-layer_rect_.y())); 283 SkFloatToScalar(-layer_rect_.y()));
279 284
280 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), 285 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(),
281 layer_rect_.y(), 286 layer_rect_.y(),
282 layer_rect_.width(), 287 layer_rect_.width(),
283 layer_rect_.height()); 288 layer_rect_.height());
284 canvas->clipRect(layer_skrect); 289 canvas->clipRect(layer_skrect);
285 } 290 }
286 291
287 gfx::RectF opaque_layer_rect; 292 gfx::RectF opaque_layer_rect;
288 painter->PaintContents(canvas.get(), layer_rect_, &opaque_layer_rect); 293 painter->PaintContents(canvas.get(), layer_rect_, &opaque_layer_rect);
289 294
290 if (canvas) 295 if (canvas)
291 canvas->restore(); 296 canvas->restore();
292 if (picture_->getRecordingCanvas()) 297 picture_ = skia::AdoptRef(recorder.endRecording());
293 picture_->endRecording(); 298 DCHECK(picture_);
294 299
295 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); 300 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect);
296 301
297 EmitTraceSnapshot(); 302 EmitTraceSnapshot();
298 } 303 }
299 304
300 void Picture::GatherPixelRefs( 305 void Picture::GatherPixelRefs(
301 const SkTileGridPicture::TileGridInfo& tile_grid_info) { 306 const SkTileGridPicture::TileGridInfo& tile_grid_info) {
302 TRACE_EVENT2("cc", "Picture::GatherPixelRefs", 307 TRACE_EVENT2("cc", "Picture::GatherPixelRefs",
303 "width", layer_rect_.width(), 308 "width", layer_rect_.width(),
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 545
541 scoped_refptr<base::debug::ConvertableToTraceFormat> 546 scoped_refptr<base::debug::ConvertableToTraceFormat>
542 Picture::AsTraceableRecordData() const { 547 Picture::AsTraceableRecordData() const {
543 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); 548 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue());
544 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); 549 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release());
545 record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release()); 550 record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release());
546 return TracedValue::FromValue(record_data.release()); 551 return TracedValue::FromValue(record_data.release());
547 } 552 }
548 553
549 } // namespace cc 554 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer.cc ('k') | cc/resources/picture_pile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698