chromium/components/viz/service/compositor_frame_fuzzer/compositor_frame_fuzzer.proto

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

syntax = "proto2";

package viz.proto;

message CompositorRenderPass {
  required Rect output_rect = 1;
  required Rect damage_rect = 2;
  repeated DrawQuad quad_list = 3;
  optional Transform transform_to_root_target = 4;
}

message DrawQuad {
  // If not present, defaults to same dimensions as quad, with identity
  // transform (or with |transform_to_root_target| if quad is a
  // CompositorRenderPassDrawQuad).
  optional SharedQuadState sqs = 1;

  required Rect rect = 2;
  required Rect visible_rect = 3;

  // |oneof| means "at most one of", so be aware that this message could
  // have none of the following (consider it invalid and skip if so):
  oneof quad {
    SolidColorDrawQuad solid_color_quad = 4;
    TileDrawQuad tile_quad = 5;
    CompositorRenderPassDrawQuad render_pass_quad = 6;
  }
}

message SharedQuadState {
  required Transform transform = 1;
  required Rect layer_rect = 2;
  required Rect visible_rect = 3;

  // TODO(malaykeshav): add fuzzable rounded corner bounds.

  required Rect clip_rect = 4;
  required bool is_clipped = 5;
  required bool are_contents_opaque = 6;

  // Will be normalized to a float in [0,1].
  required fixed32 opacity = 7 [default = 0xffffffff];

  // TODO(kylechar): add fuzzable SkBlendMode, crbug.com/923088

  required sint32 sorting_context_id = 9;
}

// SolidColorDrawQuad defaults to white
message Color {
  required float r = 1 [default = 1];
  required float g = 2 [default = 1];
  required float b = 3 [default = 1];
  required float a = 4 [default = 1];
}

message SolidColorDrawQuad {
  required Color color = 1;
  required bool force_anti_aliasing_off = 2;
}

message TileDrawQuad {
  required bool needs_blending = 1;

  // Allocate an SkBitmap from these values and pass the ResourceId
  // to the TileDrawQuad.
  required Color texture_color = 2;
  required Size texture_size = 3;

  // TODO(kylechar): enable fuzzing gfx::RectF
  required Rect tex_coord_rect = 4;

  required bool swizzle_contents = 5;
  required bool is_premultiplied = 6;
  required bool nearest_neighbor = 7;
  required bool force_anti_aliasing_off = 8;
}

message CompositorRenderPassDrawQuad {
  required CompositorRenderPass render_pass = 1;

  // If not present, defaults to DrawQuad's |rect|
  optional Rect tex_coord_rect = 2;
}

// Spec to initialize a gfx::Rect.
// Defaults to the size of the renderer frame as defined in
// fuzzer_browser_process.cc, in the hopes that this generally yields more
// interesting values more quickly.
message Rect {
  required sint32 x = 1 [default = 0];
  required sint32 y = 2 [default = 0];
  required sint32 width = 3 [default = 620];
  required sint32 height = 4 [default = 400];
}

// maps to a gfx::Size, same defaults as gfx::Rect
message Size {
  required sint32 width = 1 [default = 620];
  required sint32 height = 2 [default = 400];
}

message Transform {
  required double rotate = 1 [default = 0];

  required float scale_x = 2 [default = 1];
  required float scale_y = 3 [default = 1];

  required float translate_x = 4 [default = 0];
  required float translate_y = 5 [default = 0];
}