| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/gl_renderer.h" | 5 #include "cc/gl_renderer.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "cc/compositor_frame_metadata.h" |
| 9 #include "cc/draw_quad.h" | 10 #include "cc/draw_quad.h" |
| 10 #include "cc/prioritized_resource_manager.h" | 11 #include "cc/prioritized_resource_manager.h" |
| 11 #include "cc/resource_provider.h" | 12 #include "cc/resource_provider.h" |
| 12 #include "cc/test/paths.h" | 13 #include "cc/test/paths.h" |
| 13 #include "cc/test/pixel_test_output_surface.h" | 14 #include "cc/test/pixel_test_output_surface.h" |
| 14 #include "cc/test/pixel_test_utils.h" | 15 #include "cc/test/pixel_test_utils.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/gfx/codec/png_codec.h" | 17 #include "ui/gfx/codec/png_codec.h" |
| 17 #include "ui/gl/gl_implementation.h" | 18 #include "ui/gl/gl_implementation.h" |
| 18 | 19 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 return fake_settings; | 36 return fake_settings; |
| 36 } | 37 } |
| 37 virtual void didLoseOutputSurface() OVERRIDE { } | 38 virtual void didLoseOutputSurface() OVERRIDE { } |
| 38 virtual void onSwapBuffersComplete() OVERRIDE { } | 39 virtual void onSwapBuffersComplete() OVERRIDE { } |
| 39 virtual void setFullRootLayerDamage() OVERRIDE { } | 40 virtual void setFullRootLayerDamage() OVERRIDE { } |
| 40 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy&) OVERRIDE {} | 41 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy&) OVERRIDE {} |
| 41 virtual void enforceManagedMemoryPolicy( | 42 virtual void enforceManagedMemoryPolicy( |
| 42 const ManagedMemoryPolicy&) OVERRIDE {} | 43 const ManagedMemoryPolicy&) OVERRIDE {} |
| 43 virtual bool hasImplThread() const OVERRIDE { return false; } | 44 virtual bool hasImplThread() const OVERRIDE { return false; } |
| 44 virtual bool shouldClearRootRenderPass() const { return true; } | 45 virtual bool shouldClearRootRenderPass() const { return true; } |
| 46 virtual CompositorFrameMetadata makeCompositorFrameMetadata() const |
| 47 OVERRIDE { return CompositorFrameMetadata(); } |
| 45 }; | 48 }; |
| 46 | 49 |
| 47 class GLRendererPixelTest : public testing::Test { | 50 class GLRendererPixelTest : public testing::Test { |
| 48 protected: | 51 protected: |
| 49 GLRendererPixelTest() {} | 52 GLRendererPixelTest() {} |
| 50 | 53 |
| 51 virtual void SetUp() { | 54 virtual void SetUp() { |
| 52 gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); | 55 gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); |
| 53 output_surface_ = PixelTestOutputSurface::create(); | 56 output_surface_ = PixelTestOutputSurface::create(); |
| 54 resource_provider_ = ResourceProvider::create(output_surface_.get()); | 57 resource_provider_ = ResourceProvider::create(output_surface_.get()); |
| 55 renderer_ = GLRenderer::create(&fake_client_, resource_provider_.get()); | 58 renderer_ = GLRenderer::create(&fake_client_, |
| 59 output_surface_.get(), |
| 60 resource_provider_.get()); |
| 56 } | 61 } |
| 57 | 62 |
| 58 bool PixelsMatchReference(FilePath ref_file, gfx::Rect viewport_rect) { | 63 bool PixelsMatchReference(FilePath ref_file, gfx::Rect viewport_rect) { |
| 59 SkBitmap bitmap; | 64 SkBitmap bitmap; |
| 60 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 65 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
| 61 viewport_rect.width(), viewport_rect.height()); | 66 viewport_rect.width(), viewport_rect.height()); |
| 62 bitmap.allocPixels(); | 67 bitmap.allocPixels(); |
| 63 unsigned char* pixels = static_cast<unsigned char*>(bitmap.getPixels()); | 68 unsigned char* pixels = static_cast<unsigned char*>(bitmap.getPixels()); |
| 64 renderer_->getFramebufferPixels(pixels, viewport_rect); | 69 renderer_->getFramebufferPixels(pixels, viewport_rect); |
| 65 | 70 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 renderer_->decideRenderPassAllocationsForFrame(pass_list); | 192 renderer_->decideRenderPassAllocationsForFrame(pass_list); |
| 188 renderer_->drawFrame(pass_list, pass_map); | 193 renderer_->drawFrame(pass_list, pass_map); |
| 189 | 194 |
| 190 EXPECT_TRUE(PixelsMatchReference( | 195 EXPECT_TRUE(PixelsMatchReference( |
| 191 FilePath(FILE_PATH_LITERAL("blue_yellow.png")), viewport_rect)); | 196 FilePath(FILE_PATH_LITERAL("blue_yellow.png")), viewport_rect)); |
| 192 } | 197 } |
| 193 #endif | 198 #endif |
| 194 | 199 |
| 195 } // namespace | 200 } // namespace |
| 196 } // namespace cc | 201 } // namespace cc |
| OLD | NEW |