#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"
#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
using namespace blink;
-using namespace std;
namespace content {
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)));
}
}
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));
}
}
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);
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"
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) {
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);