Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / shell / renderer / test_runner / TestPlugin.cpp
index 22f56f5..cb33167 100644 (file)
@@ -8,8 +8,8 @@
 #include "base/bind.h"
 #include "base/logging.h"
 #include "base/memory/shared_memory.h"
+#include "base/strings/stringprintf.h"
 #include "content/public/renderer/render_thread.h"
-#include "content/shell/renderer/test_runner/TestCommon.h"
 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
 #include "third_party/skia/include/core/SkBitmap.h"
 #include "third_party/skia/include/core/SkCanvas.h"
@@ -25,7 +25,6 @@
 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
 
 using namespace blink;
-using namespace std;
 
 namespace content {
 
@@ -88,14 +87,10 @@ const char* pointState(WebTouchPoint::State state)
 void printTouchList(WebTestDelegate* delegate, const WebTouchPoint* points, int length)
 {
     for (int i = 0; i < length; ++i) {
-        char buffer[100];
-        snprintf(buffer,
-                 sizeof(buffer),
-                 "* %.2f, %.2f: %s\n",
-                 points[i].position.x,
-                 points[i].position.y,
-                 pointState(points[i].state));
-        delegate->printMessage(buffer);
+      delegate->printMessage(base::StringPrintf("* %.2f, %.2f: %s\n",
+                                                points[i].position.x,
+                                                points[i].position.y,
+                                                pointState(points[i].state)));
     }
 }
 
@@ -108,14 +103,12 @@ void printEventDetails(WebTestDelegate* delegate, const WebInputEvent& event)
         printTouchList(delegate, touch.targetTouches, touch.targetTouchesLength);
     } else if (WebInputEvent::isMouseEventType(event.type) || event.type == WebInputEvent::MouseWheel) {
         const WebMouseEvent& mouse = static_cast<const WebMouseEvent&>(event);
-        char buffer[100];
-        snprintf(buffer, sizeof(buffer), "* %d, %d\n", mouse.x, mouse.y);
-        delegate->printMessage(buffer);
+        delegate->printMessage(
+            base::StringPrintf("* %d, %d\n", mouse.x, mouse.y));
     } else if (WebInputEvent::isGestureEventType(event.type)) {
         const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(event);
-        char buffer[100];
-        snprintf(buffer, sizeof(buffer), "* %d, %d\n", gesture.x, gesture.y);
-        delegate->printMessage(buffer);
+        delegate->printMessage(
+            base::StringPrintf("* %d, %d\n", gesture.x, gesture.y));
     }
 }
 
@@ -429,9 +422,10 @@ void TestPlugin::drawSceneSoftware(void* memory, size_t bytes) {
                            m_scene.backgroundColor[1],
                            m_scene.backgroundColor[2]);
 
+    const SkImageInfo info = SkImageInfo::MakeN32Premul(m_rect.width,
+                                                        m_rect.height);
     SkBitmap bitmap;
-    bitmap.setConfig(SkBitmap::kARGB_8888_Config, m_rect.width, m_rect.height);
-    bitmap.setPixels(memory);
+    bitmap.installPixels(info, memory, info.minRowBytes());
     SkCanvas canvas(bitmap);
     canvas.clear(backgroundColor);
 
@@ -477,14 +471,14 @@ void TestPlugin::destroyScene()
 
 bool TestPlugin::initProgram()
 {
-    const string vertexSource(
+    const std::string vertexSource(
         "attribute vec4 position;  \n"
         "void main() {             \n"
         "  gl_Position = position; \n"
         "}                         \n"
     );
 
-    const string fragmentSource(
+    const std::string fragmentSource(
         "precision mediump float; \n"
         "uniform vec4 color;      \n"
         "void main() {            \n"
@@ -539,7 +533,7 @@ void TestPlugin::drawPrimitive()
     m_context->drawArrays(GL_TRIANGLES, 0, 3);
 }
 
-unsigned TestPlugin::loadShader(unsigned type, const string& source)
+unsigned TestPlugin::loadShader(unsigned type, const std::string& source)
 {
     unsigned shader = m_context->createShader(type);
     if (shader) {
@@ -556,7 +550,7 @@ unsigned TestPlugin::loadShader(unsigned type, const string& source)
     return shader;
 }
 
-unsigned TestPlugin::loadProgram(const string& vertexSource, const string& fragmentSource)
+unsigned TestPlugin::loadProgram(const std::string& vertexSource, const std::string& fragmentSource)
 {
     unsigned vertexShader = loadShader(GL_VERTEX_SHADER, vertexSource);
     unsigned fragmentShader = loadShader(GL_FRAGMENT_SHADER, fragmentSource);