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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::Picture", this); | 188 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::Picture", this); |
189 } | 189 } |
190 | 190 |
191 Picture* Picture::GetCloneForDrawingOnThread(unsigned thread_index) { | 191 Picture* Picture::GetCloneForDrawingOnThread(unsigned thread_index) { |
192 // SkPicture is not thread-safe to rasterize with, this returns a clone | 192 // SkPicture is not thread-safe to rasterize with, this returns a clone |
193 // to rasterize with on a specific thread. | 193 // to rasterize with on a specific thread. |
194 CHECK_GE(clones_.size(), thread_index); | 194 CHECK_GE(clones_.size(), thread_index); |
195 return thread_index == clones_.size() ? this : clones_[thread_index].get(); | 195 return thread_index == clones_.size() ? this : clones_[thread_index].get(); |
196 } | 196 } |
197 | 197 |
| 198 bool Picture::IsSuitableForGpuRasterization() const { |
| 199 DCHECK(picture_); |
| 200 |
| 201 // TODO(alokp): SkPicture::suitableForGpuRasterization needs a GrContext. |
| 202 // Ideally this GrContext should be the same as that for rasterizing this |
| 203 // picture. But we are on the main thread while the rasterization context |
| 204 // may be on the compositor or raster thread. |
| 205 // SkPicture::suitableForGpuRasterization is not implemented yet. |
| 206 // Pass a NULL context for now and discuss with skia folks if the context |
| 207 // is really needed. |
| 208 return picture_->suitableForGpuRasterization(NULL); |
| 209 } |
| 210 |
198 void Picture::CloneForDrawing(int num_threads) { | 211 void Picture::CloneForDrawing(int num_threads) { |
199 TRACE_EVENT1("cc", "Picture::CloneForDrawing", "num_threads", num_threads); | 212 TRACE_EVENT1("cc", "Picture::CloneForDrawing", "num_threads", num_threads); |
200 | 213 |
201 DCHECK(picture_); | 214 DCHECK(picture_); |
202 DCHECK(clones_.empty()); | 215 DCHECK(clones_.empty()); |
203 | 216 |
204 // We can re-use this picture for one raster worker thread. | 217 // We can re-use this picture for one raster worker thread. |
205 raster_thread_checker_.DetachFromThread(); | 218 raster_thread_checker_.DetachFromThread(); |
206 | 219 |
207 if (num_threads > 1) { | 220 if (num_threads > 1) { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 516 |
504 scoped_refptr<base::debug::ConvertableToTraceFormat> | 517 scoped_refptr<base::debug::ConvertableToTraceFormat> |
505 Picture::AsTraceableRecordData() const { | 518 Picture::AsTraceableRecordData() const { |
506 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); | 519 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
507 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); | 520 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); |
508 record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release()); | 521 record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release()); |
509 return TracedValue::FromValue(record_data.release()); | 522 return TracedValue::FromValue(record_data.release()); |
510 } | 523 } |
511 | 524 |
512 } // namespace cc | 525 } // namespace cc |
OLD | NEW |