DeferredDisplayList.h revision 1206b9bba91f7ed899c5c87427cce725fe5aadfc
1/* 2 * Copyright (C) 2013 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#ifndef ANDROID_HWUI_DEFERRED_DISPLAY_LIST_H 18#define ANDROID_HWUI_DEFERRED_DISPLAY_LIST_H 19 20#include <utils/Errors.h> 21#include <utils/Vector.h> 22 23#include "Matrix.h" 24#include "Rect.h" 25 26namespace android { 27namespace uirenderer { 28 29class ClipOp; 30class DrawOp; 31class SaveOp; 32class SaveLayerOp; 33class StateOp; 34class DrawOpBatch; 35class OpenGLRenderer; 36 37class DeferredDisplayList { 38public: 39 DeferredDisplayList() { clear(); } 40 ~DeferredDisplayList() { clear(); } 41 42 enum OpBatchId { 43 kOpBatch_None = -1, // Don't batch 44 kOpBatch_Bitmap, 45 kOpBatch_Patch, 46 kOpBatch_AlphaVertices, 47 kOpBatch_Vertices, 48 kOpBatch_AlphaMaskTexture, 49 kOpBatch_Text, 50 kOpBatch_ColorText, 51 52 kOpBatch_Count, // Add other batch ids before this 53 }; 54 55 bool isEmpty() { return mBatches.isEmpty(); } 56 57 /** 58 * Plays back all of the draw ops recorded into batches to the renderer. 59 * Adjusts the state of the renderer as necessary, and restores it when complete 60 */ 61 status_t flush(OpenGLRenderer& renderer, Rect& dirty); 62 63 void addClip(OpenGLRenderer& renderer, ClipOp* op); 64 void addSaveLayer(OpenGLRenderer& renderer, SaveLayerOp* op, int newSaveCount); 65 void addSave(OpenGLRenderer& renderer, SaveOp* op, int newSaveCount); 66 void addRestoreToCount(OpenGLRenderer& renderer, StateOp* op, int newSaveCount); 67 68 /** 69 * Add a draw op into the DeferredDisplayList, reordering as needed (for performance) if 70 * disallowReorder is false, respecting draw order when overlaps occur 71 */ 72 void addDrawOp(OpenGLRenderer& renderer, DrawOp* op); 73 74private: 75 /** 76 * Resets the batching back-pointers, creating a barrier in the operation stream so that no ops 77 * added in the future will be inserted into a batch that already exist. 78 */ 79 void resetBatchingState(); 80 81 void clear(); 82 83 void storeStateOpBarrier(OpenGLRenderer& renderer, StateOp* op); 84 void storeRestoreToCountBarrier(OpenGLRenderer& renderer, StateOp* op, int newSaveCount); 85 86 bool recordingComplexClip() const { return mComplexClipStackStart >= 0; } 87 88 int getStateOpDeferFlags() const; 89 int getDrawOpDeferFlags() const; 90 91 /** 92 * At defer time, stores the *defer time* savecount of save/saveLayer ops that were deferred, so 93 * that when an associated restoreToCount is deferred, it can be recorded as a 94 * RestoreToCountBatch 95 */ 96 Vector<int> mSaveStack; 97 int mComplexClipStackStart; 98 99 Vector<DrawOpBatch*> mBatches; 100 int mBatchIndices[kOpBatch_Count]; 101}; 102 103}; // namespace uirenderer 104}; // namespace android 105 106#endif // ANDROID_HWUI_DEFERRED_DISPLAY_LIST_H 107