| 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/content_layer_client.h" | 6 #include "cc/content_layer_client.h" |
| 7 #include "cc/picture.h" | 7 #include "cc/picture.h" |
| 8 #include "cc/rendering_stats.h" | 8 #include "cc/rendering_stats.h" |
| 9 #include "skia/ext/analysis_canvas.h" |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| 10 #include "third_party/skia/include/core/SkData.h" | 11 #include "third_party/skia/include/core/SkData.h" |
| 11 #include "third_party/skia/include/core/SkTileGridPicture.h" | 12 #include "third_party/skia/include/core/SkTileGridPicture.h" |
| 12 #include "third_party/skia/include/utils/SkPictureUtils.h" | 13 #include "third_party/skia/include/utils/SkPictureUtils.h" |
| 13 #include "ui/gfx/rect_conversions.h" | 14 #include "ui/gfx/rect_conversions.h" |
| 14 #include "ui/gfx/skia_util.h" | 15 #include "ui/gfx/skia_util.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 // URI label for a lazily decoded SkPixelRef. | 18 // URI label for a lazily decoded SkPixelRef. |
| 18 const char labelLazyDecoded[] = "lazy"; | 19 const char labelLazyDecoded[] = "lazy"; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 picture_->endRecording(); | 95 picture_->endRecording(); |
| 95 | 96 |
| 96 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); | 97 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void Picture::Raster( | 100 void Picture::Raster( |
| 100 SkCanvas* canvas, | 101 SkCanvas* canvas, |
| 101 gfx::Rect content_rect, | 102 gfx::Rect content_rect, |
| 102 float contents_scale) { | 103 float contents_scale) { |
| 103 TRACE_EVENT2("cc", "Picture::Raster", | 104 TRACE_EVENT2("cc", "Picture::Raster", |
| 104 "width", layer_rect_.width(), "height", layer_rect_.height()); | 105 "layer width", layer_rect_.width(), |
| 106 "layer height", layer_rect_.height()); |
| 105 DCHECK(picture_); | 107 DCHECK(picture_); |
| 106 | 108 |
| 107 canvas->save(); | 109 canvas->save(); |
| 108 canvas->clipRect(gfx::RectToSkRect(content_rect)); | 110 canvas->clipRect(gfx::RectToSkRect(content_rect)); |
| 109 canvas->scale(contents_scale, contents_scale); | 111 canvas->scale(contents_scale, contents_scale); |
| 110 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 112 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
| 111 canvas->drawPicture(*picture_); | 113 canvas->drawPicture(*picture_); |
| 112 canvas->restore(); | 114 canvas->restore(); |
| 113 } | 115 } |
| 114 | 116 |
| 115 bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) { | 117 bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) { |
| 116 return false; | 118 TRACE_EVENT0("cc", "Picture::IsCheapInRect"); |
| 119 |
| 120 SkBitmap emptyBitmap; |
| 121 emptyBitmap.setConfig(SkBitmap::kNo_Config, layer_rect.width(), |
| 122 layer_rect.height()); |
| 123 skia::AnalysisDevice device(emptyBitmap); |
| 124 skia::AnalysisCanvas canvas(&device); |
| 125 |
| 126 canvas.drawPicture(*picture_); |
| 127 return canvas.isCheap(); |
| 117 } | 128 } |
| 118 | 129 |
| 119 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect, | 130 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect, |
| 120 std::list<skia::LazyPixelRef*>& pixel_ref_list) { | 131 std::list<skia::LazyPixelRef*>& pixel_ref_list) { |
| 121 DCHECK(picture_); | 132 DCHECK(picture_); |
| 122 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( | 133 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( |
| 123 picture_.get(), SkRect::MakeXYWH(layer_rect.x(), | 134 picture_.get(), SkRect::MakeXYWH(layer_rect.x(), |
| 124 layer_rect.y(), | 135 layer_rect.y(), |
| 125 layer_rect.width(), | 136 layer_rect.width(), |
| 126 layer_rect.height())); | 137 layer_rect.height())); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 138 if (*refs && (*refs)->getURI() && !strncmp( | 149 if (*refs && (*refs)->getURI() && !strncmp( |
| 139 (*refs)->getURI(), labelLazyDecoded, 4)) { | 150 (*refs)->getURI(), labelLazyDecoded, 4)) { |
| 140 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); | 151 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
| 141 } | 152 } |
| 142 refs++; | 153 refs++; |
| 143 } | 154 } |
| 144 pixel_refs->unref(); | 155 pixel_refs->unref(); |
| 145 } | 156 } |
| 146 | 157 |
| 147 } // namespace cc | 158 } // namespace cc |
| OLD | NEW |