// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

syntax = "proto2";

import "display_item.proto";
import "layer_position_constraint.proto";
import "layer_sticky_position_constraint.proto";
import "point3f.proto";
import "pointf.proto";
import "rect.proto";
import "region.proto";
import "scroll_offset.proto";
import "size.proto";
import "skxfermode.proto";
import "transform.proto";
import "vector2df.proto";

package cc.proto;

option optimize_for = LITE_RUNTIME;

// Hierarchical structure for serializing the Layer tree.
message LayerNode {
  // Identifies the type of cc:Layer a LayerNode represents. It is used to
  // facilitate reconstruction of a Layer of the correct type on the client.
  enum Type {
    UNKNOWN = 0;
    LAYER = 1;
    PICTURE_LAYER = 2;
    SOLID_COLOR_SCROLLBAR_LAYER = 4;

    // Layer Types for testing only.
    FAKE_PICTURE_LAYER = 5;
    PUSH_PROPERTIES_COUNTING_LAYER = 6;

    // TODO(nyquist): Add the rest of the necessary LayerTypes.
  };

  // required
  optional int32 id = 1;
  // required
  optional Type type = 2;
  optional int32 parent_id = 3;
  // A List of all the children of the current LayerNode.
  repeated LayerNode children = 4;
  optional LayerNode mask_layer = 5;

  // Set for SolidColorScrollbarLayers.
  optional SolidColorScrollbarLayerProperties solid_scrollbar = 6;
}

// A container for a list of dirty layers.
message LayerUpdate {
  // A list of dirty layers.
  repeated LayerProperties layers = 1;
}

message LayerProperties {
  // required
  optional int32 id = 1;

  // The properties below are only read if |needs_push_properties| is set.
  // The Layer base class and each descendant have different proto messages
  // for their specific properties.
  optional BaseLayerProperties base = 5;

  // Only one of these fields may be set per LayerProperties.
  // TODO(dtrainor): use a 'oneof' union when it's supported in Chromium.  See
  // crbug.com/570371.
  optional PictureLayerProperties picture = 6;
}

// NEXT ID: 59
message BaseLayerProperties {
  // The following fields mirror the data stored in Layer::Inputs.
  optional Rect update_rect = 46;
  optional Size bounds = 3;
  optional bool masks_to_bounds = 14;
  optional float opacity = 22;
  optional SkXfermode.Mode blend_mode = 23;
  optional bool is_root_for_isolated_group = 24;
  optional bool contents_opaque = 21;
  optional PointF position = 25;
  optional Transform transform = 33;
  optional Point3F transform_origin = 1;
  optional bool is_drawable = 56;
  optional bool double_sided = 8;
  optional bool should_flatten_transform = 28;
  optional int32 sorting_context_id = 35;
  optional bool use_parent_backface_visibility = 32;
  optional uint32 background_color = 2;
  // TODO(nyquist): Add support for FilterOperation. See crbug.com/541321.
  // repeated FilterOperation filters = 12;
  // repeated FilterOperation background_filters = 13;
  // optional PointF filters_origin = 57
  optional ScrollOffset scroll_offset = 44;
  optional int32 scroll_clip_layer_id = 37;
  optional bool user_scrollable_horizontal = 38;
  optional bool user_scrollable_vertical = 39;
  optional uint32 main_thread_scrolling_reasons = 15;

  optional Region non_fast_scrollable_region = 18;
  // TODO(khushalsagar): Do we actually need these? Touch events are never sent
  // back to the engine.
  optional Region touch_event_handler_region = 19;

  optional bool is_container_for_fixed_position_layers = 26;
  optional LayerPositionConstraint position_constraint = 27;
  optional LayerStickyPositionConstraint sticky_position_constraint = 58;

  // ElementId and mutable properties ignored because these are used by
  // animations of Compositor-worker.

  optional int32 scroll_parent_id = 40;
  optional int32 clip_parent_id = 42;
  optional bool has_will_change_transform_hint = 48;
  optional bool hide_layer_and_subtree = 10;

  // TODO(nyquist): Add support for FilterOperation. See crbug.com/541321.
  // repeated FilterOperation filters = 12;
  // repeated FilterOperation background_filters = 13;
}

message PictureLayerProperties {
  // The following fields mirror the data stored in
  // PictureLayer::PictureLayerInputs.
  optional bool nearest_neighbor = 5;
  optional Rect recorded_viewport = 7;
  optional DisplayItemList display_list = 8;
}

message SolidColorScrollbarLayerProperties {
  enum ScrollbarOrientation {
    HORIZONTAL = 0;
    VERTICAL = 1;
  };

  optional int32 scroll_layer_id = 1;
  optional int32 thumb_thickness = 2;
  optional int32 track_start = 3;
  optional bool is_left_side_vertical_scrollbar = 4;
  optional ScrollbarOrientation orientation = 5;
}
