| 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 "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
| 6 #include "cc/debug/rendering_stats.h" | 6 #include "cc/debug/rendering_stats.h" |
| 7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
| 8 #include "cc/resources/picture.h" | 8 #include "cc/resources/picture.h" |
| 9 #include "skia/ext/analysis_canvas.h" | 9 #include "skia/ext/analysis_canvas.h" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| 11 #include "third_party/skia/include/core/SkData.h" | 11 #include "third_party/skia/include/core/SkData.h" |
| 12 #include "third_party/skia/include/utils/SkPictureUtils.h" | 12 #include "third_party/skia/include/utils/SkPictureUtils.h" |
| 13 #include "ui/gfx/rect_conversions.h" | 13 #include "ui/gfx/rect_conversions.h" |
| 14 #include "ui/gfx/skia_util.h" | 14 #include "ui/gfx/skia_util.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 // URI label for a lazily decoded SkPixelRef. | 17 // URI label for a lazily decoded SkPixelRef. |
| 18 const char labelLazyDecoded[] = "lazy"; | 18 const char kLabelLazyDecoded[] = "lazy"; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace cc { | 21 namespace cc { |
| 22 | 22 |
| 23 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { | 23 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { |
| 24 return make_scoped_refptr(new Picture(layer_rect)); | 24 return make_scoped_refptr(new Picture(layer_rect)); |
| 25 } | 25 } |
| 26 | 26 |
| 27 Picture::Picture(gfx::Rect layer_rect) | 27 Picture::Picture(gfx::Rect layer_rect) |
| 28 : layer_rect_(layer_rect) { | 28 : layer_rect_(layer_rect) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 59 scoped_refptr<Picture> clone = make_scoped_refptr( | 59 scoped_refptr<Picture> clone = make_scoped_refptr( |
| 60 new Picture(skia::AdoptRef(new SkPicture(clones[i])), | 60 new Picture(skia::AdoptRef(new SkPicture(clones[i])), |
| 61 layer_rect_, | 61 layer_rect_, |
| 62 opaque_rect_)); | 62 opaque_rect_)); |
| 63 clones_.push_back(clone); | 63 clones_.push_back(clone); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void Picture::Record(ContentLayerClient* painter, | 67 void Picture::Record(ContentLayerClient* painter, |
| 68 RenderingStats* stats, | 68 RenderingStats* stats, |
| 69 const SkTileGridPicture::TileGridInfo& tileGridInfo) { | 69 const SkTileGridPicture::TileGridInfo& tile_grid_info) { |
| 70 TRACE_EVENT2("cc", "Picture::Record", | 70 TRACE_EVENT2("cc", "Picture::Record", |
| 71 "width", layer_rect_.width(), "height", layer_rect_.height()); | 71 "width", layer_rect_.width(), "height", layer_rect_.height()); |
| 72 | 72 |
| 73 // Record() should only be called once. | 73 // Record() should only be called once. |
| 74 DCHECK(!picture_); | 74 DCHECK(!picture_); |
| 75 DCHECK(!tileGridInfo.fTileInterval.isEmpty()); | 75 DCHECK(!tile_grid_info.fTileInterval.isEmpty()); |
| 76 picture_ = skia::AdoptRef(new SkTileGridPicture( | 76 picture_ = skia::AdoptRef(new SkTileGridPicture( |
| 77 layer_rect_.width(), layer_rect_.height(), tileGridInfo)); | 77 layer_rect_.width(), layer_rect_.height(), tile_grid_info)); |
| 78 | 78 |
| 79 SkCanvas* canvas = picture_->beginRecording( | 79 SkCanvas* canvas = picture_->beginRecording( |
| 80 layer_rect_.width(), | 80 layer_rect_.width(), |
| 81 layer_rect_.height(), | 81 layer_rect_.height(), |
| 82 SkPicture::kUsePathBoundsForClip_RecordingFlag | | 82 SkPicture::kUsePathBoundsForClip_RecordingFlag | |
| 83 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); | 83 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); |
| 84 | 84 |
| 85 canvas->save(); | 85 canvas->save(); |
| 86 canvas->translate(SkFloatToScalar(-layer_rect_.x()), | 86 canvas->translate(SkFloatToScalar(-layer_rect_.x()), |
| 87 SkFloatToScalar(-layer_rect_.y())); | 87 SkFloatToScalar(-layer_rect_.y())); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 void* data = const_cast<void*>(pixel_refs->data()); | 144 void* data = const_cast<void*>(pixel_refs->data()); |
| 145 if (!data) { | 145 if (!data) { |
| 146 pixel_refs->unref(); | 146 pixel_refs->unref(); |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 | 149 |
| 150 SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data); | 150 SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data); |
| 151 for (unsigned int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) { | 151 for (unsigned int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) { |
| 152 if (*refs && (*refs)->getURI() && !strncmp( | 152 if (*refs && (*refs)->getURI() && !strncmp( |
| 153 (*refs)->getURI(), labelLazyDecoded, 4)) { | 153 (*refs)->getURI(), kLabelLazyDecoded, 4)) { |
| 154 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); | 154 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
| 155 } | 155 } |
| 156 refs++; | 156 refs++; |
| 157 } | 157 } |
| 158 pixel_refs->unref(); | 158 pixel_refs->unref(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace cc | 161 } // namespace cc |
| OLD | NEW |