2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
29 // Size of the VertexAttributeArray enables
30 // GLES specification states that there's a minimum of 8
31 const unsigned int TEST_MAX_ATTRIBUTE_CACHE_SIZE = 8;
45 // Create bitmap actor
46 static Actor CreateBitmapActor()
48 BufferImage image = BufferImage::New(4,4,Pixel::RGBA8888);
49 Actor actor = CreateRenderableActor( image );
50 actor.SetSize( 100.0f, 100.0f );
51 actor.SetName("Test Image Rendering Actor");
55 } // anonymous namespace
58 // Positive test case for a method
59 int UtcDaliContextVertexAttribStartup(void)
61 tet_infoline("Testing vertex attrib initial state in context");
63 TestApplication application;
66 application.SendNotification();
70 // check the locations
71 for (unsigned int i = 0; i < TEST_MAX_ATTRIBUTE_CACHE_SIZE; i++)
73 DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(i) == false);
80 // Tests to make the attribs only get set once when continually rendering an image actor
81 int UtcDaliContextVertexAttribImageRendering(void)
83 tet_infoline("Testing vertex attrib rendering state in context with images");
85 TestApplication application;
88 application.SendNotification();
92 // the vertex attribs get modified on startup to set them to disabled
93 // clear the flag to say they've changed
94 application.GetGlAbstraction().ClearVertexAttribArrayChanged();
97 // create a test bitmap actor
98 Actor actor(CreateBitmapActor());
99 Stage::GetCurrent().Add(actor);
102 application.SendNotification();
103 application.Render();
104 application.Render();
106 // check to make sure the state has changed (the image renderer will enable some
108 DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
110 // Now check to make sure the state is cached, and isn't being set each frame.
111 application.GetGlAbstraction().ClearVertexAttribArrayChanged();
113 application.Render();
114 application.Render();
115 application.Render();
117 // if it has changed then the caching has failed
118 DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged() == false);
121 tet_result(TET_PASS);