1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "guest/hals/hwcomposer/common/screen_view.h" 18 19 #include "common/libs/utils/size_utils.h" 20 21 namespace cuttlefish { 22 NextBuffer()23int ScreenView::NextBuffer() { 24 int num_buffers = this->num_buffers(); 25 last_buffer_ = num_buffers > 0 ? (last_buffer_ + 1) % num_buffers : -1; 26 return last_buffer_; 27 } 28 buffer_size() const29size_t ScreenView::buffer_size() const { 30 return line_length() * y_res() + 4 /* swiftshader padding */; 31 } 32 line_length() const33size_t ScreenView::line_length() const { 34 return cuttlefish::AlignToPowerOf2(x_res() * bytes_per_pixel(), 4); 35 } 36 bytes_per_pixel() const37int ScreenView::bytes_per_pixel() const { return 4; } 38 } // namespace cuttlefish 39