Skip to content

Commit af94d9d

Browse files
TreeHugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "Remove GLES wording from SurfaceFlinger."
2 parents eb1cdc5 + f3ffc4e commit af94d9d

File tree

8 files changed

+81
-79
lines changed

8 files changed

+81
-79
lines changed

services/surfaceflinger/BufferLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class BufferLayer : public Layer {
190190

191191
static bool getOpacityForFormat(uint32_t format);
192192

193-
// from GLES
193+
// from graphics API
194194
const uint32_t mTextureName;
195195

196196
bool mRefreshPending{false};

services/surfaceflinger/CompositionEngine/include/compositionengine/DisplaySurface.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ class DisplaySurface : public virtual RefBase {
4545
// prepareFrame is called after the composition configuration is known but
4646
// before composition takes place. The DisplaySurface can use the
4747
// composition type to decide how to manage the flow of buffers between
48-
// GLES and HWC for this frame.
48+
// GPU and HWC for this frame.
4949
enum CompositionType {
5050
COMPOSITION_UNKNOWN = 0,
51-
COMPOSITION_GLES = 1,
51+
COMPOSITION_GPU = 1,
5252
COMPOSITION_HWC = 2,
53-
COMPOSITION_MIXED = COMPOSITION_GLES | COMPOSITION_HWC
53+
COMPOSITION_MIXED = COMPOSITION_GPU | COMPOSITION_HWC
5454
};
5555
virtual status_t prepareFrame(CompositionType compositionType) = 0;
5656

57-
// Inform the surface that GLES composition is complete for this frame, and
57+
// Inform the surface that GPU composition is complete for this frame, and
5858
// the surface should make sure that HWComposer has the correct buffer for
5959
// this frame. Some implementations may only push a new buffer to
60-
// HWComposer if GLES composition took place, others need to push a new
60+
// HWComposer if GPU composition took place, others need to push a new
6161
// buffer on every frame.
6262
//
6363
// advanceFrame must be followed by a call to onFrameCommitted before

services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ void RenderSurface::prepareFrame(bool usesClientComposition, bool usesDeviceComp
117117
if (usesClientComposition && usesDeviceComposition) {
118118
compositionType = DisplaySurface::COMPOSITION_MIXED;
119119
} else if (usesClientComposition) {
120-
compositionType = DisplaySurface::COMPOSITION_GLES;
120+
compositionType = DisplaySurface::COMPOSITION_GPU;
121121
} else if (usesDeviceComposition) {
122122
compositionType = DisplaySurface::COMPOSITION_HWC;
123123
} else {
124124
// Nothing to do -- when turning the screen off we get a frame like
125-
// this. Call it a HWC frame since we won't be doing any GLES work but
125+
// this. Call it a HWC frame since we won't be doing any GPU work but
126126
// will do a prepare/set cycle.
127127
compositionType = DisplaySurface::COMPOSITION_HWC;
128128
}

services/surfaceflinger/CompositionEngine/tests/RenderSurfaceTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ TEST_F(RenderSurfaceTest, prepareFrameHandlesMixedComposition) {
192192
mSurface.prepareFrame(true, true);
193193
}
194194

195-
TEST_F(RenderSurfaceTest, prepareFrameHandlesOnlyGlesComposition) {
196-
EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::COMPOSITION_GLES))
195+
TEST_F(RenderSurfaceTest, prepareFrameHandlesOnlyGpuComposition) {
196+
EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::COMPOSITION_GPU))
197197
.WillOnce(Return(NO_ERROR));
198198

199199
mSurface.prepareFrame(true, false);

services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ static const char* dbgCompositionTypeStr(compositionengine::DisplaySurface::Comp
4242
switch (type) {
4343
case compositionengine::DisplaySurface::COMPOSITION_UNKNOWN:
4444
return "UNKNOWN";
45-
case compositionengine::DisplaySurface::COMPOSITION_GLES:
46-
return "GLES";
45+
case compositionengine::DisplaySurface::COMPOSITION_GPU:
46+
return "GPU";
4747
case compositionengine::DisplaySurface::COMPOSITION_HWC:
4848
return "HWC";
4949
case compositionengine::DisplaySurface::COMPOSITION_MIXED:
5050
return "MIXED";
51-
default: return "<INVALID>";
51+
default:
52+
return "<INVALID>";
5253
}
5354
}
5455

@@ -92,7 +93,7 @@ VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc,
9293
mSinkBufferHeight = sinkHeight;
9394

9495
// Pick the buffer format to request from the sink when not rendering to it
95-
// with GLES. If the consumer needs CPU access, use the default format
96+
// with GPU. If the consumer needs CPU access, use the default format
9697
// set by the consumer. Otherwise allow gralloc to decide the format based
9798
// on usage bits.
9899
int sinkUsage;
@@ -143,10 +144,10 @@ status_t VirtualDisplaySurface::prepareFrame(CompositionType compositionType) {
143144
mDbgState = DBG_STATE_PREPARED;
144145

145146
mCompositionType = compositionType;
146-
if (mForceHwcCopy && mCompositionType == COMPOSITION_GLES) {
147+
if (mForceHwcCopy && mCompositionType == COMPOSITION_GPU) {
147148
// Some hardware can do RGB->YUV conversion more efficiently in hardware
148149
// controlled by HWC than in hardware controlled by the video encoder.
149-
// Forcing GLES-composed frames to go through an extra copy by the HWC
150+
// Forcing GPU-composed frames to go through an extra copy by the HWC
150151
// allows the format conversion to happen there, rather than passing RGB
151152
// directly to the consumer.
152153
//
@@ -161,18 +162,17 @@ status_t VirtualDisplaySurface::prepareFrame(CompositionType compositionType) {
161162
mDbgLastCompositionType = mCompositionType;
162163
}
163164

164-
if (mCompositionType != COMPOSITION_GLES &&
165-
(mOutputFormat != mDefaultOutputFormat ||
166-
mOutputUsage != GRALLOC_USAGE_HW_COMPOSER)) {
167-
// We must have just switched from GLES-only to MIXED or HWC
168-
// composition. Stop using the format and usage requested by the GLES
165+
if (mCompositionType != COMPOSITION_GPU &&
166+
(mOutputFormat != mDefaultOutputFormat || mOutputUsage != GRALLOC_USAGE_HW_COMPOSER)) {
167+
// We must have just switched from GPU-only to MIXED or HWC
168+
// composition. Stop using the format and usage requested by the GPU
169169
// driver; they may be suboptimal when HWC is writing to the output
170170
// buffer. For example, if the output is going to a video encoder, and
171171
// HWC can write directly to YUV, some hardware can skip a
172172
// memory-to-memory RGB-to-YUV conversion step.
173173
//
174-
// If we just switched *to* GLES-only mode, we'll change the
175-
// format/usage and get a new buffer when the GLES driver calls
174+
// If we just switched *to* GPU-only mode, we'll change the
175+
// format/usage and get a new buffer when the GPU driver calls
176176
// dequeueBuffer().
177177
mOutputFormat = mDefaultOutputFormat;
178178
mOutputUsage = GRALLOC_USAGE_HW_COMPOSER;
@@ -192,17 +192,16 @@ status_t VirtualDisplaySurface::advanceFrame() {
192192
"Unexpected advanceFrame() in %s state on HWC frame",
193193
dbgStateStr());
194194
} else {
195-
VDS_LOGW_IF(mDbgState != DBG_STATE_GLES_DONE,
196-
"Unexpected advanceFrame() in %s state on GLES/MIXED frame",
197-
dbgStateStr());
195+
VDS_LOGW_IF(mDbgState != DBG_STATE_GPU_DONE,
196+
"Unexpected advanceFrame() in %s state on GPU/MIXED frame", dbgStateStr());
198197
}
199198
mDbgState = DBG_STATE_HWC;
200199

201200
if (mOutputProducerSlot < 0 ||
202201
(mCompositionType != COMPOSITION_HWC && mFbProducerSlot < 0)) {
203202
// Last chance bailout if something bad happened earlier. For example,
204-
// in a GLES configuration, if the sink disappears then dequeueBuffer
205-
// will fail, the GLES driver won't queue a buffer, but SurfaceFlinger
203+
// in a graphics API configuration, if the sink disappears then dequeueBuffer
204+
// will fail, the GPU driver won't queue a buffer, but SurfaceFlinger
206205
// will soldier on. So we end up here without a buffer. There should
207206
// be lots of scary messages in the log just before this.
208207
VDS_LOGE("advanceFrame: no buffer, bailing out");
@@ -302,9 +301,8 @@ status_t VirtualDisplaySurface::requestBuffer(int pslot,
302301
return mSource[SOURCE_SINK]->requestBuffer(pslot, outBuf);
303302
}
304303

305-
VDS_LOGW_IF(mDbgState != DBG_STATE_GLES,
306-
"Unexpected requestBuffer pslot=%d in %s state",
307-
pslot, dbgStateStr());
304+
VDS_LOGW_IF(mDbgState != DBG_STATE_GPU, "Unexpected requestBuffer pslot=%d in %s state", pslot,
305+
dbgStateStr());
308306

309307
*outBuf = mProducerBuffers[pslot];
310308
return NO_ERROR;
@@ -374,7 +372,7 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, uint
374372

375373
VDS_LOGW_IF(mDbgState != DBG_STATE_PREPARED,
376374
"Unexpected dequeueBuffer() in %s state", dbgStateStr());
377-
mDbgState = DBG_STATE_GLES;
375+
mDbgState = DBG_STATE_GPU;
378376

379377
VDS_LOGV("dequeueBuffer %dx%d fmt=%d usage=%#" PRIx64, w, h, format, usage);
380378

@@ -385,18 +383,18 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, uint
385383

386384
if (mOutputProducerSlot < 0) {
387385
// Last chance bailout if something bad happened earlier. For example,
388-
// in a GLES configuration, if the sink disappears then dequeueBuffer
389-
// will fail, the GLES driver won't queue a buffer, but SurfaceFlinger
386+
// in a graphics API configuration, if the sink disappears then dequeueBuffer
387+
// will fail, the GPU driver won't queue a buffer, but SurfaceFlinger
390388
// will soldier on. So we end up here without a buffer. There should
391389
// be lots of scary messages in the log just before this.
392390
VDS_LOGE("dequeueBuffer: no buffer, bailing out");
393391
return NO_MEMORY;
394392
}
395393

396-
// We already dequeued the output buffer. If the GLES driver wants
394+
// We already dequeued the output buffer. If the GPU driver wants
397395
// something incompatible, we have to cancel and get a new one. This
398396
// will mean that HWC will see a different output buffer between
399-
// prepare and set, but since we're in GLES-only mode already it
397+
// prepare and set, but since we're in GPU-only mode already it
400398
// shouldn't matter.
401399

402400
usage |= GRALLOC_USAGE_HW_COMPOSER;
@@ -458,10 +456,9 @@ status_t VirtualDisplaySurface::queueBuffer(int pslot,
458456
return mSource[SOURCE_SINK]->queueBuffer(pslot, input, output);
459457
}
460458

461-
VDS_LOGW_IF(mDbgState != DBG_STATE_GLES,
462-
"Unexpected queueBuffer(pslot=%d) in %s state", pslot,
463-
dbgStateStr());
464-
mDbgState = DBG_STATE_GLES_DONE;
459+
VDS_LOGW_IF(mDbgState != DBG_STATE_GPU, "Unexpected queueBuffer(pslot=%d) in %s state", pslot,
460+
dbgStateStr());
461+
mDbgState = DBG_STATE_GPU_DONE;
465462

466463
VDS_LOGV("queueBuffer pslot=%d", pslot);
467464

@@ -488,11 +485,11 @@ status_t VirtualDisplaySurface::queueBuffer(int pslot,
488485
mFbFence = mSlots[item.mSlot].mFence;
489486

490487
} else {
491-
LOG_FATAL_IF(mCompositionType != COMPOSITION_GLES,
492-
"Unexpected queueBuffer in state %s for compositionType %s",
493-
dbgStateStr(), dbgCompositionTypeStr(mCompositionType));
488+
LOG_FATAL_IF(mCompositionType != COMPOSITION_GPU,
489+
"Unexpected queueBuffer in state %s for compositionType %s", dbgStateStr(),
490+
dbgCompositionTypeStr(mCompositionType));
494491

495-
// Extract the GLES release fence for HWC to acquire
492+
// Extract the GPU release fence for HWC to acquire
496493
int64_t timestamp;
497494
bool isAutoTimestamp;
498495
android_dataspace dataSpace;
@@ -517,9 +514,8 @@ status_t VirtualDisplaySurface::cancelBuffer(int pslot,
517514
return mSource[SOURCE_SINK]->cancelBuffer(mapProducer2SourceSlot(SOURCE_SINK, pslot), fence);
518515
}
519516

520-
VDS_LOGW_IF(mDbgState != DBG_STATE_GLES,
521-
"Unexpected cancelBuffer(pslot=%d) in %s state", pslot,
522-
dbgStateStr());
517+
VDS_LOGW_IF(mDbgState != DBG_STATE_GPU, "Unexpected cancelBuffer(pslot=%d) in %s state", pslot,
518+
dbgStateStr());
523519
VDS_LOGV("cancelBuffer pslot=%d", pslot);
524520
Source source = fbSourceForCompositionType(mCompositionType);
525521
return mSource[source]->cancelBuffer(
@@ -641,8 +637,8 @@ status_t VirtualDisplaySurface::refreshOutputBuffer() {
641637
return result;
642638
mOutputProducerSlot = mapSource2ProducerSlot(SOURCE_SINK, sslot);
643639

644-
// On GLES-only frames, we don't have the right output buffer acquire fence
645-
// until after GLES calls queueBuffer(). So here we just set the buffer
640+
// On GPU-only frames, we don't have the right output buffer acquire fence
641+
// until after GPU calls queueBuffer(). So here we just set the buffer
646642
// (for use in HWC prepare) but not the fence; we'll call this again with
647643
// the proper fence once we have it.
648644
result = mHwc.setOutputBuffer(*mDisplayId, Fence::NO_FENCE,
@@ -672,12 +668,18 @@ VirtualDisplaySurface::fbSourceForCompositionType(CompositionType type) {
672668

673669
const char* VirtualDisplaySurface::dbgStateStr() const {
674670
switch (mDbgState) {
675-
case DBG_STATE_IDLE: return "IDLE";
676-
case DBG_STATE_PREPARED: return "PREPARED";
677-
case DBG_STATE_GLES: return "GLES";
678-
case DBG_STATE_GLES_DONE: return "GLES_DONE";
679-
case DBG_STATE_HWC: return "HWC";
680-
default: return "INVALID";
671+
case DBG_STATE_IDLE:
672+
return "IDLE";
673+
case DBG_STATE_PREPARED:
674+
return "PREPARED";
675+
case DBG_STATE_GPU:
676+
return "GPU";
677+
case DBG_STATE_GPU_DONE:
678+
return "GPU_DONE";
679+
case DBG_STATE_HWC:
680+
return "HWC";
681+
default:
682+
return "INVALID";
681683
}
682684
}
683685

services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ namespace android {
3434
class HWComposer;
3535
class IProducerListener;
3636

37-
/* This DisplaySurface implementation supports virtual displays, where GLES
37+
/* This DisplaySurface implementation supports virtual displays, where GPU
3838
* and/or HWC compose into a buffer that is then passed to an arbitrary
3939
* consumer (the sink) running in another process.
4040
*
4141
* The simplest case is when the virtual display will never use the h/w
4242
* composer -- either the h/w composer doesn't support writing to buffers, or
4343
* there are more virtual displays than it supports simultaneously. In this
44-
* case, the GLES driver works directly with the output buffer queue, and
44+
* case, the GPU driver works directly with the output buffer queue, and
4545
* calls to the VirtualDisplay from SurfaceFlinger and DisplayHardware do
4646
* nothing.
4747
*
4848
* If h/w composer might be used, then each frame will fall into one of three
49-
* configurations: GLES-only, HWC-only, and MIXED composition. In all of these,
49+
* configurations: GPU-only, HWC-only, and MIXED composition. In all of these,
5050
* we must provide a FB target buffer and output buffer for the HWC set() call.
5151
*
52-
* In GLES-only composition, the GLES driver is given a buffer from the sink to
53-
* render into. When the GLES driver queues the buffer to the
52+
* In GPU-only composition, the GPU driver is given a buffer from the sink to
53+
* render into. When the GPU driver queues the buffer to the
5454
* VirtualDisplaySurface, the VirtualDisplaySurface holds onto it instead of
5555
* immediately queueing it to the sink. The buffer is used as both the FB
5656
* target and output buffer for HWC, though on these frames the HWC doesn't
@@ -65,7 +65,7 @@ class IProducerListener;
6565
*
6666
* On MIXED frames, things become more complicated, since some h/w composer
6767
* implementations can't read from and write to the same buffer. This class has
68-
* an internal BufferQueue that it uses as a scratch buffer pool. The GLES
68+
* an internal BufferQueue that it uses as a scratch buffer pool. The GPU
6969
* driver is given a scratch buffer to render into. When it finishes rendering,
7070
* the buffer is queued and then immediately acquired by the
7171
* VirtualDisplaySurface. The scratch buffer is then used as the FB target
@@ -99,7 +99,7 @@ class VirtualDisplaySurface : public compositionengine::DisplaySurface,
9999
virtual ~VirtualDisplaySurface();
100100

101101
//
102-
// IGraphicBufferProducer interface, used by the GLES driver.
102+
// IGraphicBufferProducer interface, used by the GPU driver.
103103
//
104104
virtual status_t requestBuffer(int pslot, sp<GraphicBuffer>* outBuf);
105105
virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers);
@@ -144,7 +144,7 @@ class VirtualDisplaySurface : public compositionengine::DisplaySurface,
144144

145145
// Both the sink and scratch buffer pools have their own set of slots
146146
// ("source slots", or "sslot"). We have to merge these into the single
147-
// set of slots used by the GLES producer ("producer slots" or "pslot") and
147+
// set of slots used by the graphics producer ("producer slots" or "pslot") and
148148
// internally in the VirtualDisplaySurface. To minimize the number of times
149149
// a producer slot switches which source it comes from, we map source slot
150150
// numbers to producer slot numbers differently for each source.
@@ -166,12 +166,12 @@ class VirtualDisplaySurface : public compositionengine::DisplaySurface,
166166

167167
// To avoid buffer reallocations, we track the buffer usage and format
168168
// we used on the previous frame and use it again on the new frame. If
169-
// the composition type changes or the GLES driver starts requesting
169+
// the composition type changes or the GPU driver starts requesting
170170
// different usage/format, we'll get a new buffer.
171171
uint32_t mOutputFormat;
172172
uint64_t mOutputUsage;
173173

174-
// Since we present a single producer interface to the GLES driver, but
174+
// Since we present a single producer interface to the GPU driver, but
175175
// are internally muxing between the sink and scratch producers, we have
176176
// to keep track of which source last returned each producer slot from
177177
// dequeueBuffer. Each bit in mProducerSlotSource corresponds to a producer
@@ -181,7 +181,7 @@ class VirtualDisplaySurface : public compositionengine::DisplaySurface,
181181
sp<GraphicBuffer> mProducerBuffers[BufferQueueDefs::NUM_BUFFER_SLOTS];
182182

183183
// The QueueBufferOutput with the latest info from the sink, and with the
184-
// transform hint cleared. Since we defer queueBuffer from the GLES driver
184+
// transform hint cleared. Since we defer queueBuffer from the GPU driver
185185
// to the sink, we have to return the previous version.
186186
// Moves instead of copies are performed to avoid duplicate
187187
// FrameEventHistoryDeltas.
@@ -195,7 +195,7 @@ class VirtualDisplaySurface : public compositionengine::DisplaySurface,
195195
// Intra-frame state
196196
//
197197

198-
// Composition type and GLES buffer source for the current frame.
198+
// Composition type and graphics buffer source for the current frame.
199199
// Valid after prepareFrame(), cleared in onFrameCommitted.
200200
CompositionType mCompositionType;
201201

@@ -221,13 +221,13 @@ class VirtualDisplaySurface : public compositionengine::DisplaySurface,
221221
// +-----------+-------------------+-------------+
222222
// | IDLE | beginFrame || BEGUN |
223223
// | BEGUN | prepareFrame || PREPARED |
224-
// | PREPARED | dequeueBuffer [1] || GLES |
224+
// | PREPARED | dequeueBuffer [1] || GPU |
225225
// | PREPARED | advanceFrame [2] || HWC |
226-
// | GLES | queueBuffer || GLES_DONE |
227-
// | GLES_DONE | advanceFrame || HWC |
226+
// | GPU | queueBuffer || GPU_DONE |
227+
// | GPU_DONE | advanceFrame || HWC |
228228
// | HWC | onFrameCommitted || IDLE |
229229
// +-----------+-------------------++------------+
230-
// [1] COMPOSITION_GLES and COMPOSITION_MIXED frames.
230+
// [1] COMPOSITION_GPU and COMPOSITION_MIXED frames.
231231
// [2] COMPOSITION_HWC frames.
232232
//
233233
enum DbgState {
@@ -236,12 +236,12 @@ class VirtualDisplaySurface : public compositionengine::DisplaySurface,
236236
// output buffer dequeued, framebuffer source not yet known
237237
DBG_STATE_BEGUN,
238238
// output buffer dequeued, framebuffer source known but not provided
239-
// to GLES yet.
239+
// to GPU yet.
240240
DBG_STATE_PREPARED,
241-
// GLES driver has a buffer dequeued
242-
DBG_STATE_GLES,
243-
// GLES driver has queued the buffer, we haven't sent it to HWC yet
244-
DBG_STATE_GLES_DONE,
241+
// GPU driver has a buffer dequeued
242+
DBG_STATE_GPU,
243+
// GPU driver has queued the buffer, we haven't sent it to HWC yet
244+
DBG_STATE_GPU_DONE,
245245
// HWC has the buffer for this frame
246246
DBG_STATE_HWC,
247247
};

0 commit comments

Comments
 (0)