| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/trace_event/trace_event.h" | 6 #include "base/trace_event/trace_event.h" |
| 7 #include "skia/ext/analysis_canvas.h" | 7 #include "skia/ext/analysis_canvas.h" |
| 8 #include "third_party/skia/include/core/SkDraw.h" | 8 #include "third_party/skia/include/core/SkDraw.h" |
| 9 #include "third_party/skia/include/core/SkPath.h" | 9 #include "third_party/skia/include/core/SkPath.h" |
| 10 #include "third_party/skia/include/core/SkRRect.h" | 10 #include "third_party/skia/include/core/SkRRect.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 SkBlendMode bmode, | 325 SkBlendMode bmode, |
| 326 const uint16_t indices[], | 326 const uint16_t indices[], |
| 327 int index_count, | 327 int index_count, |
| 328 const SkPaint& paint) { | 328 const SkPaint& paint) { |
| 329 TRACE_EVENT0("disabled-by-default-skia", "AnalysisCanvas::onDrawVertices"); | 329 TRACE_EVENT0("disabled-by-default-skia", "AnalysisCanvas::onDrawVertices"); |
| 330 is_solid_color_ = false; | 330 is_solid_color_ = false; |
| 331 is_transparent_ = false; | 331 is_transparent_ = false; |
| 332 ++draw_op_count_; | 332 ++draw_op_count_; |
| 333 } | 333 } |
| 334 | 334 |
| 335 // Needed for now, since SkCanvas requires a bitmap, even if it is not backed | |
| 336 // by any pixels | |
| 337 static SkBitmap MakeEmptyBitmap(int width, int height) { | |
| 338 SkBitmap bitmap; | |
| 339 bitmap.setInfo(SkImageInfo::MakeUnknown(width, height)); | |
| 340 return bitmap; | |
| 341 } | |
| 342 | |
| 343 AnalysisCanvas::AnalysisCanvas(int width, int height) | 335 AnalysisCanvas::AnalysisCanvas(int width, int height) |
| 344 : INHERITED(MakeEmptyBitmap(width, height)), | 336 : INHERITED(width, height), |
| 345 saved_stack_size_(0), | 337 saved_stack_size_(0), |
| 346 force_not_solid_stack_level_(kNoLayer), | 338 force_not_solid_stack_level_(kNoLayer), |
| 347 force_not_transparent_stack_level_(kNoLayer), | 339 force_not_transparent_stack_level_(kNoLayer), |
| 348 is_forced_not_solid_(false), | 340 is_forced_not_solid_(false), |
| 349 is_forced_not_transparent_(false), | 341 is_forced_not_transparent_(false), |
| 350 is_solid_color_(true), | 342 is_solid_color_(true), |
| 351 color_(SK_ColorTRANSPARENT), | 343 color_(SK_ColorTRANSPARENT), |
| 352 is_transparent_(true), | 344 is_transparent_(true), |
| 353 draw_op_count_(0), | 345 draw_op_count_(0), |
| 354 rejected_op_count_(0) { | 346 rejected_op_count_(0) {} |
| 355 } | |
| 356 | 347 |
| 357 AnalysisCanvas::~AnalysisCanvas() {} | 348 AnalysisCanvas::~AnalysisCanvas() {} |
| 358 | 349 |
| 359 bool AnalysisCanvas::GetColorIfSolid(SkColor* color) const { | 350 bool AnalysisCanvas::GetColorIfSolid(SkColor* color) const { |
| 360 if (is_transparent_) { | 351 if (is_transparent_) { |
| 361 *color = SK_ColorTRANSPARENT; | 352 *color = SK_ColorTRANSPARENT; |
| 362 return true; | 353 return true; |
| 363 } | 354 } |
| 364 if (is_solid_color_) { | 355 if (is_solid_color_) { |
| 365 *color = color_; | 356 *color = color_; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 force_not_transparent_stack_level_ = kNoLayer; | 507 force_not_transparent_stack_level_ = kNoLayer; |
| 517 } | 508 } |
| 518 } | 509 } |
| 519 | 510 |
| 520 INHERITED::willRestore(); | 511 INHERITED::willRestore(); |
| 521 } | 512 } |
| 522 | 513 |
| 523 } // namespace skia | 514 } // namespace skia |
| 524 | 515 |
| 525 | 516 |
| OLD | NEW |