Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b0828d7

Browse files
committed
doc comments
1 parent 05fa21b commit b0828d7

File tree

1 file changed

+125
-2
lines changed

1 file changed

+125
-2
lines changed

display_list/display_list.h

Lines changed: 125 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ class DisplayList : public SkRefCnt {
378378
/// be required for the indicated blend mode to do its work.
379379
DlBlendMode max_root_blend_mode() const { return max_root_blend_mode_; }
380380

381+
/// @brief Iterator utility class used for the |DisplayList::begin|
382+
/// and |DisplayList::end| methods. It implements just the
383+
/// basic methods to enable iteration-style for loops.
381384
class Iterator {
382385
public:
383386
DlIndex operator*() const { return value_; }
@@ -395,16 +398,136 @@ class DisplayList : public SkRefCnt {
395398
friend class DisplayList;
396399
};
397400

401+
/// @brief Return the number of stored records in the DisplayList.
402+
///
403+
/// Each stored record represents a dispatchable operation that will be
404+
/// sent to a |DlOpReceiver| by the |Dispatch| method. You can directly
405+
/// simulate the |Dispatch| method using a simple for loop on the indices:
406+
///
407+
/// {
408+
/// for (DlIndex i = 0u; i < display_list->GetRecordCount(); i++) {
409+
/// display_list->Dispatch(my_receiver, i);
410+
/// }
411+
/// }
412+
///
413+
/// @see |Dispatch(receiver, index)|
414+
/// @see |begin|
415+
/// @see |end|
416+
/// @see |GetCulledIndices|
398417
DlIndex GetRecordCount() const { return offsets_.size(); }
418+
419+
/// @brief Return an iterator to the start of the stored records,
420+
/// enabling the iteration form of a for loop.
421+
///
422+
/// Each stored record represents a dispatchable operation that will be
423+
/// sent to a |DlOpReceiver| by the |Dispatch| method. You can directly
424+
/// simulate the |Dispatch| method using a simple for loop on the indices:
425+
///
426+
/// {
427+
/// for (DlIndex i : *display_list) {
428+
/// display_list->Dispatch(my_receiver, i);
429+
/// }
430+
/// }
431+
///
432+
/// @see |end|
433+
/// @see |GetCulledIndices|
399434
Iterator begin() const { return Iterator(0u); }
400-
Iterator end() const { return Iterator(offsets_.size()); }
401435

402-
bool Dispatch(DlOpReceiver& ctx, DlIndex index) const;
436+
/// @brief Return an iterator to the end of the stored records,
437+
/// enabling the iteration form of a for loop.
438+
///
439+
/// Each stored record represents a dispatchable operation that will be
440+
/// sent to a |DlOpReceiver| by the |Dispatch| method. You can directly
441+
/// simulate the |Dispatch| method using a simple for loop on the indices:
442+
///
443+
/// {
444+
/// for (DlIndex i : *display_list) {
445+
/// display_list->Dispatch(my_receiver, i);
446+
/// }
447+
/// }
448+
///
449+
/// @see |begin|
450+
/// @see |GetCulledIndices|
451+
Iterator end() const { return Iterator(offsets_.size()); }
403452

453+
/// @brief Dispatch a single stored operation by its index.
454+
///
455+
/// Each stored record represents a dispatchable operation that will be
456+
/// sent to a |DlOpReceiver| by the |Dispatch| method. You can use this
457+
/// method to dispatch a single operation to your receiver with an index
458+
/// between |0u| (inclusive) and |GetRecordCount()| (exclusive), as in:
459+
///
460+
/// {
461+
/// for (DlIndex i = 0u; i < display_list->GetRecordCount(); i++) {
462+
/// display_list->Dispatch(my_receiver, i);
463+
/// }
464+
/// }
465+
///
466+
/// If the index is out of the range of the stored records, this method
467+
/// will not call any methods on the receiver and return false. You can
468+
/// check the return value for true if you want to make sure you are
469+
/// using valid indices.
470+
///
471+
/// @see |GetRecordCount|
472+
/// @see |begin|
473+
/// @see |end|
474+
/// @see |GetCulledIndices|
475+
bool Dispatch(DlOpReceiver& receiver, DlIndex index) const;
476+
477+
/// @brief Return an enum describing the specific op type stored at
478+
/// the indicated index.
479+
///
480+
/// The specific types of the records are subject to change without notice
481+
/// as the DisplayList code is developed and optimized. These values are
482+
/// useful mostly for debugging purposes and should not be used in
483+
/// production code.
484+
///
485+
/// @see |GetOpCategory| for a more stable description of the records
404486
DisplayListOpType GetOpType(DlIndex index) const;
487+
488+
/// @brief Return an enum describing the general category of the
489+
/// operation record stored at the indicated index.
490+
///
491+
/// The categories are general and stable and can be used fairly safely
492+
/// in production code to plan how to dispatch or reorder ops during
493+
/// final rendering.
494+
///
495+
/// @see |GetOpType| for a more detailed description of the records
496+
/// primarily for debugging use
405497
DisplayListOpCategory GetOpCategory(DlIndex index) const;
498+
499+
/// @brief Return an enum describing the general category of the
500+
/// operation record with the given type.
501+
///
502+
/// @see |GetOpType| for a more detailed description of the records
503+
/// primarily for debugging use
406504
static DisplayListOpCategory GetOpCategory(DisplayListOpType type);
407505

506+
/// @brief Return a vector of valid indices for records stored in
507+
/// the DisplayList that must be dispatched if you are
508+
/// restricted to the indicated cull_rect.
509+
///
510+
/// This method can be used along with indexed dispatching to implement
511+
/// RTree culling while still maintaining control over planning of
512+
/// operations to be rendered, as in:
513+
///
514+
/// {
515+
/// std::vector<DlIndex> indices =
516+
/// display_list->GetCulledIndices(cull-rect);
517+
/// for (DlIndex i : indices) {
518+
/// display_list->Dispatch(my_receiver, i);
519+
/// }
520+
/// }
521+
///
522+
/// The indices returned in the vector will automatically deal with
523+
/// including or culling related operations such as attributes, clips
524+
/// and transforms that will provide state for any rendering operations
525+
/// selected by the culling checks.
526+
///
527+
/// @see |GetOpType| for a more detailed description of the records
528+
/// primarily for debugging use
529+
///
530+
/// @see |Dispatch(receiver, index)|
408531
std::vector<DlIndex> GetCulledIndices(const SkRect& cull_rect) const;
409532

410533
private:

0 commit comments

Comments
 (0)