OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/paint/paint_op_buffer.h" | 5 #include "cc/paint/paint_op_buffer.h" |
6 | 6 |
7 #include "cc/paint/display_item_list.h" | 7 #include "cc/paint/display_item_list.h" |
8 #include "cc/paint/paint_record.h" | 8 #include "cc/paint/paint_record.h" |
9 #include "third_party/skia/include/core/SkAnnotation.h" | 9 #include "third_party/skia/include/core/SkAnnotation.h" |
10 | 10 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 }; | 105 }; |
106 | 106 |
107 template <> | 107 template <> |
108 struct Rasterizer<DrawRecordOp, false> { | 108 struct Rasterizer<DrawRecordOp, false> { |
109 static void RasterWithAlpha(const DrawRecordOp* op, | 109 static void RasterWithAlpha(const DrawRecordOp* op, |
110 SkCanvas* canvas, | 110 SkCanvas* canvas, |
111 uint8_t alpha) { | 111 uint8_t alpha) { |
112 // This "looking into records" optimization is done here instead of | 112 // This "looking into records" optimization is done here instead of |
113 // in the PaintOpBuffer::Raster function as DisplayItemList calls | 113 // in the PaintOpBuffer::Raster function as DisplayItemList calls |
114 // into RasterWithAlpha directly. | 114 // into RasterWithAlpha directly. |
115 if (op->record->approximateOpCount() == 1) { | 115 if (op->record->size() == 1u) { |
116 PaintOp* single_op = op->record->GetFirstOp(); | 116 PaintOp* single_op = op->record->GetFirstOp(); |
117 // RasterWithAlpha only supported for draw ops. | 117 // RasterWithAlpha only supported for draw ops. |
118 if (single_op->IsDrawOp()) { | 118 if (single_op->IsDrawOp()) { |
119 single_op->RasterWithAlpha(canvas, alpha); | 119 single_op->RasterWithAlpha(canvas, alpha); |
120 return; | 120 return; |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 canvas->saveLayerAlpha(nullptr, alpha); | 124 canvas->saveLayerAlpha(nullptr, alpha); |
125 SkMatrix unused_matrix; | 125 SkMatrix unused_matrix; |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 : PaintOpWithArray(flags, bytes, count) {} | 559 : PaintOpWithArray(flags, bytes, count) {} |
560 | 560 |
561 DrawPosTextOp::~DrawPosTextOp() = default; | 561 DrawPosTextOp::~DrawPosTextOp() = default; |
562 | 562 |
563 DrawRecordOp::DrawRecordOp(sk_sp<const PaintRecord> record) | 563 DrawRecordOp::DrawRecordOp(sk_sp<const PaintRecord> record) |
564 : record(std::move(record)) {} | 564 : record(std::move(record)) {} |
565 | 565 |
566 DrawRecordOp::~DrawRecordOp() = default; | 566 DrawRecordOp::~DrawRecordOp() = default; |
567 | 567 |
568 size_t DrawRecordOp::AdditionalBytesUsed() const { | 568 size_t DrawRecordOp::AdditionalBytesUsed() const { |
569 return record->approximateBytesUsed(); | 569 return record->bytes_used(); |
570 } | 570 } |
571 | 571 |
572 bool DrawRecordOp::HasDiscardableImages() const { | 572 bool DrawRecordOp::HasDiscardableImages() const { |
573 return record->HasDiscardableImages(); | 573 return record->HasDiscardableImages(); |
574 } | 574 } |
575 | 575 |
576 DrawTextBlobOp::DrawTextBlobOp(sk_sp<SkTextBlob> blob, | 576 DrawTextBlobOp::DrawTextBlobOp(sk_sp<SkTextBlob> blob, |
577 SkScalar x, | 577 SkScalar x, |
578 SkScalar y, | 578 SkScalar y, |
579 const PaintFlags& flags) | 579 const PaintFlags& flags) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 return std::make_pair(op, skip); | 712 return std::make_pair(op, skip); |
713 } | 713 } |
714 | 714 |
715 void PaintOpBuffer::ShrinkToFit() { | 715 void PaintOpBuffer::ShrinkToFit() { |
716 if (!used_ || used_ == reserved_) | 716 if (!used_ || used_ == reserved_) |
717 return; | 717 return; |
718 ReallocBuffer(used_); | 718 ReallocBuffer(used_); |
719 } | 719 } |
720 | 720 |
721 } // namespace cc | 721 } // namespace cc |
OLD | NEW |