Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / common / gpu / client / gl_helper_benchmark.cc
index 6bb4309..225db42 100644 (file)
 #include "base/mac/scoped_nsautorelease_pool.h"
 #endif
 
-#if defined(TOOLKIT_GTK)
-#include "ui/gfx/gtk_util.h"
-#endif
-
 namespace content {
 
-using WebKit::WebGLId;
-using WebKit::WebGraphicsContext3D;
+using blink::WebGLId;
+using blink::WebGraphicsContext3D;
 
 content::GLHelper::ScalerQuality kQualities[] = {
   content::GLHelper::SCALER_QUALITY_BEST,
@@ -62,14 +58,16 @@ class GLHelperTest : public testing::Test {
  protected:
   virtual void SetUp() {
     WebGraphicsContext3D::Attributes attributes;
+    bool lose_context_when_out_of_memory = false;
     context_ = webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl::
-        CreateOffscreenContext(attributes);
+        CreateOffscreenContext(attributes, lose_context_when_out_of_memory);
     context_->makeContextCurrent();
 
     helper_.reset(
-        new content::GLHelper(context_.get(), context_->GetContextSupport()));
+        new content::GLHelper(context_->GetGLInterface(),
+                              context_->GetContextSupport()));
     helper_scaling_.reset(new content::GLHelperScaling(
-        context_.get(),
+        context_->GetGLInterface(),
         helper_.get()));
   }
 
@@ -102,11 +100,11 @@ class GLHelperTest : public testing::Test {
         std::vector<gfx::PNGCodec::Comment>(),
         &compressed));
     ASSERT_TRUE(compressed.size());
-    FILE* f = file_util::OpenFile(filename, "wb");
+    FILE* f = base::OpenFile(filename, "wb");
     ASSERT_TRUE(f);
     ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f),
               compressed.size());
-    file_util::CloseFile(f);
+    base::CloseFile(f);
   }
 
   scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
@@ -143,18 +141,10 @@ TEST_F(GLHelperTest, ScaleBenchmark) {
         const gfx::Size dst_size(output_sizes[outsize],
                                  output_sizes[outsize + 1]);
         SkBitmap input;
-        input.setConfig(SkBitmap::kARGB_8888_Config,
-                        src_size.width(),
-                        src_size.height());
-        input.allocPixels();
-        SkAutoLockPixels lock(input);
+        input.allocN32Pixels(src_size.width(), src_size.height());
 
         SkBitmap output_pixels;
-        input.setConfig(SkBitmap::kARGB_8888_Config,
-                        dst_size.width(),
-                        dst_size.height());
-        output_pixels.allocPixels();
-        SkAutoLockPixels output_lock(output_pixels);
+        output_pixels.allocN32Pixels(dst_size.width(), dst_size.height());
 
         context_->bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
         context_->bindTexture(GL_TEXTURE_2D, dst_texture);
@@ -280,23 +270,20 @@ TEST_F(GLHelperTest, DISABLED_ScaleTestImage) {
         kQualities[q]);
 
       SkBitmap output_pixels;
-      input.setConfig(SkBitmap::kARGB_8888_Config,
-                      dst_size.width(),
-                      dst_size.height());
-      output_pixels.allocPixels();
-      SkAutoLockPixels lock(output_pixels);
+      output_pixels.allocN32Pixels(dst_size.width(), dst_size.height());
 
       helper_->ReadbackTextureSync(
           dst_texture,
           gfx::Rect(0, 0,
                     dst_size.width(),
                     dst_size.height()),
-          static_cast<unsigned char *>(output_pixels.getPixels()));
+          static_cast<unsigned char *>(output_pixels.getPixels()),
+          kN32_SkColorType);
       context_->deleteTexture(dst_texture);
       std::string filename = base::StringPrintf("testoutput_%s_%d.ppm",
                                                 kQualityNames[q],
                                                 percents[p]);
-      LOG(INFO) << "Writing " <<  filename;
+      VLOG(0) << "Writing " <<  filename;
       SaveToFile(&output_pixels, base::FilePath::FromUTF8Unsafe(filename));
     }
   }
@@ -309,14 +296,11 @@ TEST_F(GLHelperTest, DISABLED_ScaleTestImage) {
 // These tests needs to run against a proper GL environment, so we
 // need to set it up before we can run the tests.
 int main(int argc, char** argv) {
-  CommandLine::Init(argc, argv);
+  base::CommandLine::Init(argc, argv);
   base::TestSuite* suite = new content::ContentTestSuite(argc, argv);
 #if defined(OS_MACOSX)
   base::mac::ScopedNSAutoreleasePool pool;
 #endif
-#if defined(TOOLKIT_GTK)
-  gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess());
-#endif
   gfx::GLSurface::InitializeOneOff();
 
   return content::UnitTestTestSuite(suite).Run();