1 // Copyright 2018 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef THIRD_PARTY_QUIC_TRACE_TOOLS_RECTANGLE_RENDERER_H_ 16 #define THIRD_PARTY_QUIC_TRACE_TOOLS_RECTANGLE_RENDERER_H_ 17 18 #include "tools/render/program_state.h" 19 #include "tools/render/shader.h" 20 21 namespace quic_trace { 22 namespace render { 23 24 // Draws bunch of rectangles of specified color. 25 class RectangleRenderer { 26 public: 27 RectangleRenderer(const ProgramState* state); 28 29 void AddRectangle(Box box, uint32_t rgba); 30 void AddRectangleWithBorder(Box box, uint32_t rgba); 31 void Render(); 32 33 private: 34 struct Point { 35 float x; 36 float y; 37 uint32_t rgba; 38 }; 39 std::vector<Point> points_; 40 std::vector<uint16_t> line_indices_; 41 42 const ProgramState* state_; 43 Shader shader_; 44 Shader line_shader_; 45 }; 46 47 } // namespace render 48 } // namespace quic_trace 49 50 #endif // THIRD_PARTY_QUIC_TRACE_TOOLS_RECTANGLE_RENDERER_H_ 51