LayerManagerCommands: log screen/layer/surface IDs in decimal and hex
[profile/ivi/layer-management.git] / LayerManagerCommands / src / LayerSetChromaKeyCommand.cpp
1 /***************************************************************************
2 *
3 * Copyright 2010,2011 BMW Car IT GmbH
4 * Copyright (C) 2012 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 "LayerSetChromaKeyCommand.h"
21 #include "ICommandExecutor.h"
22 #include "Scene.h"
23 #include "Log.h"
24
25 LayerSetChromaKeyCommand::~LayerSetChromaKeyCommand()
26 {
27     delete[] m_array;
28 }
29
30 ExecutionResult LayerSetChromaKeyCommand::execute(ICommandExecutor* executor)
31 {
32     Scene& scene = *(executor->getScene());
33
34     ExecutionResult result = ExecutionFailed;
35
36     Layer* layer = scene.getLayer(m_layerid);
37
38     if (NULL == m_array)
39     {
40         if (layer)
41         {
42             LOG_DEBUG("LayerSetChromaKeyCommand","new chromakey disable for id: " << m_layerid);
43             result = layer->setChromaKeyEnabled(false) ? ExecutionSuccessRedraw : ExecutionSuccess;
44         }
45     }
46     else
47     {
48         if (layer)
49         {
50             LOG_DEBUG("LayerSetChromaKeyCommand","new chromakey ("
51                 << m_array[0] << ", " << m_array[1] << ", " << m_array[2] << ") for id: " << m_layerid);
52             bool ansSetEnabled = layer->setChromaKeyEnabled(true);
53             bool ansSetValues = layer->setChromaKey((unsigned char)m_array[0], (unsigned char)m_array[1], (unsigned char)m_array[2]);
54             if ((true == ansSetEnabled) | (true == ansSetValues))
55             {
56                 result = ExecutionSuccessRedraw;
57             }
58             else
59             {
60                 result = ExecutionSuccess;
61             }
62         }
63     }
64
65     return result;
66 }
67
68 const std::string LayerSetChromaKeyCommand::getString()
69 {
70     std::stringstream description;
71     description << "LayerSetChromaKeyCommand("
72                 << "layerid=" << m_layerid << "(0x" << std::hex << m_layerid << ")" << std::dec
73                 << ", m_array=[";
74
75     for (unsigned int i = 0; i < m_length; ++i)
76     {
77         description << m_array[i] << ",";
78     }
79     description << "], m_length=" << m_length
80                 << ")";
81     return description.str();
82 }