~xnox/ubuntu/trusty/gcc-arm-linux-androideabi/dima

« back to all changes in this revision

Viewing changes to android/frameworks/native/services/surfaceflinger/SurfaceTextureLayer.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-07-05 10:12:24 UTC
  • Revision ID: package-import@ubuntu.com-20130705101224-6qo3e8jbz8p31aa1
Tags: upstream-0.20130705.1
ImportĀ upstreamĀ versionĀ 0.20130705.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 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 <stdlib.h>
 
18
#include <stdint.h>
 
19
#include <sys/types.h>
 
20
 
 
21
#include <utils/Errors.h>
 
22
 
 
23
#include "Layer.h"
 
24
#include "SurfaceTextureLayer.h"
 
25
 
 
26
namespace android {
 
27
// ---------------------------------------------------------------------------
 
28
 
 
29
 
 
30
SurfaceTextureLayer::SurfaceTextureLayer()
 
31
    : BufferQueue(true) {
 
32
}
 
33
 
 
34
SurfaceTextureLayer::~SurfaceTextureLayer() {
 
35
}
 
36
 
 
37
status_t SurfaceTextureLayer::connect(int api, QueueBufferOutput* output) {
 
38
    status_t err = BufferQueue::connect(api, output);
 
39
    if (err == NO_ERROR) {
 
40
        switch(api) {
 
41
            case NATIVE_WINDOW_API_MEDIA:
 
42
            case NATIVE_WINDOW_API_CAMERA:
 
43
                // Camera preview and videos are rate-limited on the producer
 
44
                // side.  If enabled for this build, we use async mode to always
 
45
                // show the most recent frame at the cost of requiring an
 
46
                // additional buffer.
 
47
#ifndef NEVER_DEFAULT_TO_ASYNC_MODE
 
48
                err = setSynchronousMode(false);
 
49
                break;
 
50
#endif
 
51
                // fall through to set synchronous mode when not defaulting to
 
52
                // async mode.
 
53
            default:
 
54
                err = setSynchronousMode(true);
 
55
                break;
 
56
        }
 
57
        if (err != NO_ERROR) {
 
58
            disconnect(api);
 
59
        }
 
60
    }
 
61
    return err;
 
62
}
 
63
 
 
64
// ---------------------------------------------------------------------------
 
65
}; // namespace android