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 "base/containers/stack_container.h" | 7 #include "base/containers/stack_container.h" |
8 #include "cc/paint/display_item_list.h" | 8 #include "cc/paint/display_item_list.h" |
9 #include "cc/paint/paint_record.h" | 9 #include "cc/paint/paint_record.h" |
10 #include "third_party/skia/include/core/SkAnnotation.h" | 10 #include "third_party/skia/include/core/SkAnnotation.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 static bool g_is_draw_op[kNumOpTypes] = {TYPES(M)}; | 187 static bool g_is_draw_op[kNumOpTypes] = {TYPES(M)}; |
188 #undef M | 188 #undef M |
189 | 189 |
190 #define M(T) \ | 190 #define M(T) \ |
191 static_assert(sizeof(T) <= sizeof(LargestPaintOp), \ | 191 static_assert(sizeof(T) <= sizeof(LargestPaintOp), \ |
192 #T " must be no bigger than LargestPaintOp"); | 192 #T " must be no bigger than LargestPaintOp"); |
193 TYPES(M); | 193 TYPES(M); |
194 #undef M | 194 #undef M |
195 | 195 |
196 #define M(T) \ | 196 #define M(T) \ |
197 static_assert(ALIGNOF(T) <= PaintOpBuffer::PaintOpAlign, \ | 197 static_assert(alignof(T) <= PaintOpBuffer::PaintOpAlign, \ |
198 #T " must have alignment no bigger than PaintOpAlign"); | 198 #T " must have alignment no bigger than PaintOpAlign"); |
199 TYPES(M); | 199 TYPES(M); |
200 #undef M | 200 #undef M |
201 | 201 |
202 #undef TYPES | 202 #undef TYPES |
203 | 203 |
204 SkRect PaintOp::kUnsetRect = {SK_ScalarInfinity, 0, 0, 0}; | 204 SkRect PaintOp::kUnsetRect = {SK_ScalarInfinity, 0, 0, 0}; |
205 | 205 |
206 void AnnotateOp::Raster(const PaintOp* base_op, | 206 void AnnotateOp::Raster(const PaintOp* base_op, |
207 SkCanvas* canvas, | 207 SkCanvas* canvas, |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 size_t bytes) { | 773 size_t bytes) { |
774 if (!op_count_) { | 774 if (!op_count_) { |
775 if (bytes) { | 775 if (bytes) { |
776 // Internal first_op buffer doesn't have room for extra data. | 776 // Internal first_op buffer doesn't have room for extra data. |
777 // If the op wants extra bytes, then we'll just store a Noop | 777 // If the op wants extra bytes, then we'll just store a Noop |
778 // in the first_op and proceed from there. This seems unlikely | 778 // in the first_op and proceed from there. This seems unlikely |
779 // to be a common case. | 779 // to be a common case. |
780 push<NoopOp>(); | 780 push<NoopOp>(); |
781 } else { | 781 } else { |
782 op_count_++; | 782 op_count_++; |
783 return std::make_pair(first_op_.void_data(), 0); | 783 return std::pair<void*, size_t>(&first_op_, 0); |
784 } | 784 } |
785 } | 785 } |
786 | 786 |
787 // We've filled |first_op_| by now so we need to allocate space in |data_|. | 787 // We've filled |first_op_| by now so we need to allocate space in |data_|. |
788 DCHECK(op_count_); | 788 DCHECK(op_count_); |
789 | 789 |
790 // Compute a skip such that all ops in the buffer are aligned to the | 790 // Compute a skip such that all ops in the buffer are aligned to the |
791 // maximum required alignment of all ops. | 791 // maximum required alignment of all ops. |
792 size_t skip = MathUtil::UncheckedRoundUp(sizeof_op + bytes, PaintOpAlign); | 792 size_t skip = MathUtil::UncheckedRoundUp(sizeof_op + bytes, PaintOpAlign); |
793 DCHECK_LT(skip, static_cast<size_t>(1) << 24); | 793 DCHECK_LT(skip, static_cast<size_t>(1) << 24); |
(...skipping 13 matching lines...) Expand all Loading... |
807 return std::make_pair(op, skip); | 807 return std::make_pair(op, skip); |
808 } | 808 } |
809 | 809 |
810 void PaintOpBuffer::ShrinkToFit() { | 810 void PaintOpBuffer::ShrinkToFit() { |
811 if (!used_ || used_ == reserved_) | 811 if (!used_ || used_ == reserved_) |
812 return; | 812 return; |
813 ReallocBuffer(used_); | 813 ReallocBuffer(used_); |
814 } | 814 } |
815 | 815 |
816 } // namespace cc | 816 } // namespace cc |
OLD | NEW |