1 /*
2 // Copyright (c) 2014 Intel Corporation
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 #include <HwcTrace.h>
17 #include <PlatfBufferManager.h>
18 #include <tangier/TngGrallocBuffer.h>
19 #include <tangier/TngGrallocBufferMapper.h>
20 #include <sync/sync.h>
21
22 namespace android {
23 namespace intel {
24
PlatfBufferManager()25 PlatfBufferManager::PlatfBufferManager()
26 : BufferManager()
27 {
28
29 }
30
~PlatfBufferManager()31 PlatfBufferManager::~PlatfBufferManager()
32 {
33
34 }
35
initialize()36 bool PlatfBufferManager::initialize()
37 {
38 return BufferManager::initialize();
39 }
40
deinitialize()41 void PlatfBufferManager::deinitialize()
42 {
43 BufferManager::deinitialize();
44 }
45
createDataBuffer(buffer_handle_t handle)46 DataBuffer* PlatfBufferManager::createDataBuffer(buffer_handle_t handle)
47 {
48 return new TngGrallocBuffer(handle);
49 }
50
createBufferMapper(DataBuffer & buffer)51 BufferMapper* PlatfBufferManager::createBufferMapper(DataBuffer& buffer)
52 {
53 return new TngGrallocBufferMapper(*mGralloc, buffer);
54 }
55
blit(buffer_handle_t srcHandle,buffer_handle_t destHandle,const crop_t & destRect,bool filter,bool async)56 bool PlatfBufferManager::blit(buffer_handle_t srcHandle, buffer_handle_t destHandle,
57 const crop_t& destRect, bool filter, bool async)
58
59 {
60 int fenceFd;
61
62 if (gralloc_blit_handle_to_handle_img(mGralloc,
63 srcHandle,
64 destHandle,
65 destRect.w, destRect.h, destRect.x,
66 destRect.y, 0, -1, &fenceFd)) {
67 ETRACE("Blit failed");
68 return false;
69 }
70
71 if (!async) {
72 sync_wait(fenceFd, -1);
73 }
74 close(fenceFd);
75
76 return true;
77 }
78
79 } // namespace intel
80 } // namespace android
81