OLD | NEW |
---|---|
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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 SkTileGridFactory factory(tile_grid_info); | 254 SkTileGridFactory factory(tile_grid_info); |
255 SkPictureRecorder recorder; | 255 SkPictureRecorder recorder; |
256 | 256 |
257 skia::RefPtr<SkCanvas> canvas; | 257 skia::RefPtr<SkCanvas> canvas; |
258 canvas = skia::SharePtr( | 258 canvas = skia::SharePtr( |
259 recorder.beginRecording(layer_rect_.width(), | 259 recorder.beginRecording(layer_rect_.width(), |
260 layer_rect_.height(), | 260 layer_rect_.height(), |
261 &factory, | 261 &factory, |
262 SkPicture::kUsePathBoundsForClip_RecordingFlag)); | 262 SkPicture::kUsePathBoundsForClip_RecordingFlag)); |
263 | 263 |
264 bool disableGraphicsContext = false; | |
Sami
2014/04/29 10:57:23
hacker_style here too.
Stephen Chennney
2014/04/29 20:30:45
Done.
| |
265 | |
264 switch (recording_mode) { | 266 switch (recording_mode) { |
265 case RECORD_NORMALLY: | 267 case RECORD_NORMALLY: |
266 // Already setup for normal recording | 268 // Already setup for normal recording |
267 break; | 269 break; |
268 case RECORD_WITH_SK_NULL_CANVAS: | 270 case RECORD_WITH_SK_NULL_CANVAS: |
269 canvas = skia::AdoptRef(SkCreateNullCanvas()); | 271 canvas = skia::AdoptRef(SkCreateNullCanvas()); |
270 break; | 272 break; |
271 case RECORD_WITH_PAINTING_DISABLED: | 273 case RECORD_WITH_PAINTING_DISABLED: |
272 // Blink's GraphicsContext will disable painting when given a NULL | 274 // We pass a disable flag through the paint calls |
Sami
2014/04/29 10:57:23
nit: end comments with punctuation.
Stephen Chennney
2014/04/29 20:30:45
Done.
| |
273 // canvas. | 275 disableGraphicsContext = true; |
274 canvas.clear(); | |
275 break; | 276 break; |
276 default: | 277 default: |
277 NOTREACHED(); | 278 NOTREACHED(); |
278 } | 279 } |
279 | 280 |
280 if (canvas) { | 281 if (canvas) { |
281 canvas->save(); | 282 canvas->save(); |
282 canvas->translate(SkFloatToScalar(-layer_rect_.x()), | 283 canvas->translate(SkFloatToScalar(-layer_rect_.x()), |
283 SkFloatToScalar(-layer_rect_.y())); | 284 SkFloatToScalar(-layer_rect_.y())); |
284 | 285 |
285 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), | 286 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), |
286 layer_rect_.y(), | 287 layer_rect_.y(), |
287 layer_rect_.width(), | 288 layer_rect_.width(), |
288 layer_rect_.height()); | 289 layer_rect_.height()); |
289 canvas->clipRect(layer_skrect); | 290 canvas->clipRect(layer_skrect); |
290 } | 291 } |
291 | 292 |
292 gfx::RectF opaque_layer_rect; | 293 gfx::RectF opaque_layer_rect; |
293 painter->PaintContents(canvas.get(), layer_rect_, &opaque_layer_rect); | 294 painter->PaintContents( |
295 canvas.get(), layer_rect_, &opaque_layer_rect, disableGraphicsContext); | |
294 | 296 |
295 if (canvas) | 297 if (canvas) |
296 canvas->restore(); | 298 canvas->restore(); |
297 picture_ = skia::AdoptRef(recorder.endRecording()); | 299 picture_ = skia::AdoptRef(recorder.endRecording()); |
298 DCHECK(picture_); | 300 DCHECK(picture_); |
299 | 301 |
300 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); | 302 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); |
301 | 303 |
302 EmitTraceSnapshot(); | 304 EmitTraceSnapshot(); |
303 } | 305 } |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 | 547 |
546 scoped_refptr<base::debug::ConvertableToTraceFormat> | 548 scoped_refptr<base::debug::ConvertableToTraceFormat> |
547 Picture::AsTraceableRecordData() const { | 549 Picture::AsTraceableRecordData() const { |
548 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); | 550 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
549 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); | 551 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); |
550 record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release()); | 552 record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release()); |
551 return TracedValue::FromValue(record_data.release()); | 553 return TracedValue::FromValue(record_data.release()); |
552 } | 554 } |
553 | 555 |
554 } // namespace cc | 556 } // namespace cc |
OLD | NEW |