1 /**************************************************************************
2 *
3 * Copyright 2010, 2011 BMW Car IT GmbH
4 * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
5 *
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ****************************************************************************/
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <assert.h>
24 #include "WLSurface.h"
25
WLSurface(WLContext * wlContext)26 WLSurface::WLSurface(WLContext* wlContext)
27 : m_wlContext(wlContext)
28 , m_wlSurface(NULL)
29 , m_iviSurface(NULL)
30 , m_width(0)
31 , m_height(0)
32 , m_surfaceId(0)
33 {
34 assert(wlContext);
35 }
36
~WLSurface()37 WLSurface::~WLSurface()
38 {
39 if (m_surfaceId > 0)
40 ivi_surface_destroy(m_iviSurface);
41
42 if (m_wlSurface)
43 wl_surface_destroy(m_wlSurface);
44 }
45
46 bool
CreateSurface(const int width,const int height,const int surfaceId)47 WLSurface::CreateSurface(const int width, const int height, const int surfaceId)
48 {
49 m_width = width;
50 m_height = height;
51 m_surfaceId = surfaceId;
52
53 m_wlSurface = (struct wl_surface*)
54 wl_compositor_create_surface(m_wlContext->GetWLCompositor());
55 if (!m_wlSurface){
56 return false;
57 }
58
59 m_iviSurface = (struct ivi_surface*) ivi_application_surface_create(m_wlContext->GetIviApp(),
60 m_surfaceId,
61 m_wlSurface);
62 if (!m_iviSurface){
63 return false;
64 }
65
66 return CreatePlatformSurface();
67 }
68
69 bool
CreatePlatformSurface()70 WLSurface::CreatePlatformSurface()
71 {
72 return true;
73 }
74