| 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/core/SkDrawFilter.h" | 12 #include "third_party/skia/include/core/SkDrawFilter.h" |
| 13 #include "third_party/skia/include/core/SkPaint.h" | 13 #include "third_party/skia/include/core/SkPaint.h" |
| 14 #include "third_party/skia/include/utils/SkPictureUtils.h" | 14 #include "third_party/skia/include/utils/SkPictureUtils.h" |
| 15 #include "ui/gfx/rect_conversions.h" | 15 #include "ui/gfx/rect_conversions.h" |
| 16 #include "ui/gfx/skia_util.h" | 16 #include "ui/gfx/skia_util.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 // URI label for a lazily decoded SkPixelRef. | 19 // URI label for a lazily decoded SkPixelRef. |
| 20 const char labelLazyDecoded[] = "lazy"; | 20 const char kLabelLazyDecoded[] = "lazy"; |
| 21 | 21 |
| 22 class DisableLCDTextFilter : public SkDrawFilter { | 22 class DisableLCDTextFilter : public SkDrawFilter { |
| 23 public: | 23 public: |
| 24 // SkDrawFilter interface. | 24 // SkDrawFilter interface. |
| 25 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) { | 25 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) { |
| 26 if (type != SkDrawFilter::kText_Type) | 26 if (type != SkDrawFilter::kText_Type) |
| 27 return true; | 27 return true; |
| 28 | 28 |
| 29 paint->setLCDRenderText(false); | 29 paint->setLCDRenderText(false); |
| 30 return true; | 30 return true; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 scoped_refptr<Picture> clone = make_scoped_refptr( | 74 scoped_refptr<Picture> clone = make_scoped_refptr( |
| 75 new Picture(skia::AdoptRef(new SkPicture(clones[i])), | 75 new Picture(skia::AdoptRef(new SkPicture(clones[i])), |
| 76 layer_rect_, | 76 layer_rect_, |
| 77 opaque_rect_)); | 77 opaque_rect_)); |
| 78 clones_.push_back(clone); | 78 clones_.push_back(clone); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 void Picture::Record(ContentLayerClient* painter, | 82 void Picture::Record(ContentLayerClient* painter, |
| 83 RenderingStats* stats, | 83 RenderingStats* stats, |
| 84 const SkTileGridPicture::TileGridInfo& tileGridInfo) { | 84 const SkTileGridPicture::TileGridInfo& tile_grid_info) { |
| 85 TRACE_EVENT2("cc", "Picture::Record", | 85 TRACE_EVENT2("cc", "Picture::Record", |
| 86 "width", layer_rect_.width(), "height", layer_rect_.height()); | 86 "width", layer_rect_.width(), "height", layer_rect_.height()); |
| 87 | 87 |
| 88 // Record() should only be called once. | 88 // Record() should only be called once. |
| 89 DCHECK(!picture_); | 89 DCHECK(!picture_); |
| 90 DCHECK(!tileGridInfo.fTileInterval.isEmpty()); | 90 DCHECK(!tile_grid_info.fTileInterval.isEmpty()); |
| 91 picture_ = skia::AdoptRef(new SkTileGridPicture( | 91 picture_ = skia::AdoptRef(new SkTileGridPicture( |
| 92 layer_rect_.width(), layer_rect_.height(), tileGridInfo)); | 92 layer_rect_.width(), layer_rect_.height(), tile_grid_info)); |
| 93 | 93 |
| 94 SkCanvas* canvas = picture_->beginRecording( | 94 SkCanvas* canvas = picture_->beginRecording( |
| 95 layer_rect_.width(), | 95 layer_rect_.width(), |
| 96 layer_rect_.height(), | 96 layer_rect_.height(), |
| 97 SkPicture::kUsePathBoundsForClip_RecordingFlag | | 97 SkPicture::kUsePathBoundsForClip_RecordingFlag | |
| 98 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); | 98 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); |
| 99 | 99 |
| 100 canvas->save(); | 100 canvas->save(); |
| 101 canvas->translate(SkFloatToScalar(-layer_rect_.x()), | 101 canvas->translate(SkFloatToScalar(-layer_rect_.x()), |
| 102 SkFloatToScalar(-layer_rect_.y())); | 102 SkFloatToScalar(-layer_rect_.y())); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 void* data = const_cast<void*>(pixel_refs->data()); | 165 void* data = const_cast<void*>(pixel_refs->data()); |
| 166 if (!data) { | 166 if (!data) { |
| 167 pixel_refs->unref(); | 167 pixel_refs->unref(); |
| 168 return; | 168 return; |
| 169 } | 169 } |
| 170 | 170 |
| 171 SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data); | 171 SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data); |
| 172 for (unsigned int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) { | 172 for (unsigned int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) { |
| 173 if (*refs && (*refs)->getURI() && !strncmp( | 173 if (*refs && (*refs)->getURI() && !strncmp( |
| 174 (*refs)->getURI(), labelLazyDecoded, 4)) { | 174 (*refs)->getURI(), kLabelLazyDecoded, 4)) { |
| 175 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); | 175 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
| 176 } | 176 } |
| 177 refs++; | 177 refs++; |
| 178 } | 178 } |
| 179 pixel_refs->unref(); | 179 pixel_refs->unref(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace cc | 182 } // namespace cc |
| OLD | NEW |