Home | History | Annotate | Download | only in renderthread
      1 /*
      2  * Copyright (C) 2016 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 #pragma once
     18 
     19 #include <stdint.h>
     20 
     21 struct SkRect;
     22 typedef void* EGLSurface;
     23 
     24 namespace android {
     25 namespace uirenderer {
     26 namespace renderthread {
     27 
     28 class Frame {
     29 public:
     30     Frame(int32_t width, int32_t height, int32_t bufferAge)
     31             : mWidth(width), mHeight(height), mBufferAge(bufferAge) {}
     32 
     33     int32_t width() const { return mWidth; }
     34     int32_t height() const { return mHeight; }
     35 
     36     // See: https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_buffer_age.txt
     37     // for what this means
     38     int32_t bufferAge() const { return mBufferAge; }
     39 
     40 private:
     41     Frame() {}
     42     friend class EglManager;
     43 
     44     int32_t mWidth;
     45     int32_t mHeight;
     46     int32_t mBufferAge;
     47 
     48     EGLSurface mSurface;
     49 
     50     // Maps from 0,0 in top-left to 0,0 in bottom-left
     51     // If out is not an int32_t[4] you're going to have a bad time
     52     void map(const SkRect& in, int32_t* out) const;
     53 };
     54 
     55 } /* namespace renderthread */
     56 } /* namespace uirenderer */
     57 } /* namespace android */
     58