108aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy/*
208aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * Copyright (C) 2011 The Android Open Source Project
308aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy *
408aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * Licensed under the Apache License, Version 2.0 (the "License");
508aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * you may not use this file except in compliance with the License.
608aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * You may obtain a copy of the License at
708aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy *
808aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy *      http://www.apache.org/licenses/LICENSE-2.0
908aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy *
1008aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * Unless required by applicable law or agreed to in writing, software
1108aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * distributed under the License is distributed on an "AS IS" BASIS,
1208aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1308aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * See the License for the specific language governing permissions and
1408aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * limitations under the License.
1508aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy */
1608aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy
1708aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy#ifndef ANDROID_HWUI_DRAW_GL_INFO_H
1808aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy#define ANDROID_HWUI_DRAW_GL_INFO_H
1908aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy
2008aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guynamespace android {
2108aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guynamespace uirenderer {
2208aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy
2308aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy/**
2408aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * Structure used by OpenGLRenderer::callDrawGLFunction() to pass and
2508aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy * receive data from OpenGL functors.
2608aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy */
2708aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guystruct DrawGlInfo {
2808aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    // Input: current clip rect
2908aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    int clipLeft;
3008aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    int clipTop;
3108aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    int clipRight;
3208aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    int clipBottom;
3308aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy
347b6a75872bd2df96a23453d31c2e2e7fcc373554Chet Haase    // Input: current width/height of destination surface
357b6a75872bd2df96a23453d31c2e2e7fcc373554Chet Haase    int width;
367b6a75872bd2df96a23453d31c2e2e7fcc373554Chet Haase    int height;
377b6a75872bd2df96a23453d31c2e2e7fcc373554Chet Haase
3808aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    // Input: is the render target an FBO
3908aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    bool isLayer;
4008aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy
4108aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    // Input: current transform matrix, in OpenGL format
4208aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    float transform[16];
4308aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy
4408aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    // Output: dirty region to redraw
4508aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    float dirtyLeft;
4608aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    float dirtyTop;
4708aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    float dirtyRight;
4808aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy    float dirtyBottom;
496554943a1dd6854c0f4976900956e556767b49e1Romain Guy
506554943a1dd6854c0f4976900956e556767b49e1Romain Guy    /**
518f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy     * Values used as the "what" parameter of the functor.
528f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy     */
538f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    enum Mode {
548f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy        // Indicates that the functor is called to perform a draw
558f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy        kModeDraw,
568f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy        // Indicates the the functor is called only to perform
578f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy        // processing and that no draw should be attempted
580d1f634f4b5e1bb37aa51777efb6a68619488d01John Reck        kModeProcess,
590d1f634f4b5e1bb37aa51777efb6a68619488d01John Reck        // Same as kModeProcess, however there is no GL context because it was
600d1f634f4b5e1bb37aa51777efb6a68619488d01John Reck        // lost or destroyed
6109d5cddf67b676018700bcc10a72242641cd7eecJohn Reck        kModeProcessNoContext,
6209d5cddf67b676018700bcc10a72242641cd7eecJohn Reck        // Invoked every time the UI thread pushes over a frame to the render thread
6309d5cddf67b676018700bcc10a72242641cd7eecJohn Reck        // *and the owning view has a dirty display list*. This is a signal to sync
6409d5cddf67b676018700bcc10a72242641cd7eecJohn Reck        // any data that needs to be shared between the UI thread and the render thread.
6509d5cddf67b676018700bcc10a72242641cd7eecJohn Reck        // During this time the UI thread is blocked.
6609d5cddf67b676018700bcc10a72242641cd7eecJohn Reck        kModeSync
678f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    };
688f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy
698f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    /**
706554943a1dd6854c0f4976900956e556767b49e1Romain Guy     * Values used by OpenGL functors to tell the framework
716554943a1dd6854c0f4976900956e556767b49e1Romain Guy     * what to do next.
726554943a1dd6854c0f4976900956e556767b49e1Romain Guy     */
736554943a1dd6854c0f4976900956e556767b49e1Romain Guy    enum Status {
746554943a1dd6854c0f4976900956e556767b49e1Romain Guy        // The functor is done
758f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy        kStatusDone = 0x0,
76486590963e2207d68eebd6944fec70d50d41116aChet Haase        // DisplayList actually issued GL drawing commands.
77486590963e2207d68eebd6944fec70d50d41116aChet Haase        // This is used to signal the HardwareRenderer that the
78486590963e2207d68eebd6944fec70d50d41116aChet Haase        // buffers should be flipped - otherwise, there were no
79486590963e2207d68eebd6944fec70d50d41116aChet Haase        // changes to the buffer, so no need to flip. Some hardware
80486590963e2207d68eebd6944fec70d50d41116aChet Haase        // has issues with stale buffer contents when no GL
81486590963e2207d68eebd6944fec70d50d41116aChet Haase        // commands are issued.
82486590963e2207d68eebd6944fec70d50d41116aChet Haase        kStatusDrew = 0x4
836554943a1dd6854c0f4976900956e556767b49e1Romain Guy    };
8408aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy}; // struct DrawGlInfo
8508aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy
8608aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy}; // namespace uirenderer
8708aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy}; // namespace android
8808aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy
8908aa2cbd5e62e7ca140f78f8bea0477a19880fd9Romain Guy#endif // ANDROID_HWUI_DRAW_GL_INFO_H
90