18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file. 48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "third_party/skia/include/core/SkCanvas.h" 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "third_party/skia/include/core/SkColor.h" 88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "third_party/skia/include/core/SkDevice.h" 9f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ui/gfx/ozone/dri/dri_skbitmap.h" 10f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ui/gfx/ozone/dri/dri_surface.h" 11f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ui/gfx/ozone/dri/hardware_display_controller.h" 128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace { 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Create a basic mode for a 6x4 screen. 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)const drmModeModeInfo kDefaultMode = 178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; 188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Mock file descriptor ID. 208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)const int kFd = 3; 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Mock connector ID. 238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)const uint32_t kConnectorId = 1; 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Mock CRTC ID. 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)const uint32_t kCrtcId = 1; 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Mock DPMS property ID. 291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)const uint32_t kDPMSPropertyId = 1; 301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 31f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class MockDriWrapper : public gfx::DriWrapper { 328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 33f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) MockDriWrapper() : DriWrapper(""), id_(1) { fd_ = kFd; } 34f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual ~MockDriWrapper() { fd_ = -1; } 358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual drmModeCrtc* GetCrtc(uint32_t crtc_id) OVERRIDE { return NULL; } 378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void FreeCrtc(drmModeCrtc* crtc) OVERRIDE {} 388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool SetCrtc(uint32_t crtc_id, 398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t framebuffer, 408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t* connectors, 418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) drmModeModeInfo* mode) OVERRIDE { return true; } 428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool SetCrtc(drmModeCrtc* crtc, uint32_t* connectors) OVERRIDE { 438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return true; 448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool AddFramebuffer(const drmModeModeInfo& mode, 468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint8_t depth, 478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint8_t bpp, 488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t stride, 498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t handle, 508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t* framebuffer) OVERRIDE { 518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) *framebuffer = id_++; 528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return true; 538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool RemoveFramebuffer(uint32_t framebuffer) OVERRIDE { return true; } 558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool PageFlip(uint32_t crtc_id, 568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) uint32_t framebuffer, 578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void* data) OVERRIDE { 588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return true; 598bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual bool ConnectorSetProperty(uint32_t connector_id, 611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint32_t property_id, 621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) uint64_t value) OVERRIDE { return true; } 638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) int id_; 66f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(MockDriWrapper); 678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 69f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class MockDriSkBitmap : public gfx::DriSkBitmap { 708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 71f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) MockDriSkBitmap(int fd, 728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) bool initialize_expectation) 73f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) : DriSkBitmap(fd), 748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) initialize_expectation_(initialize_expectation) {} 75f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual ~MockDriSkBitmap() {} 768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual bool Initialize() OVERRIDE { 788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) if (!initialize_expectation_) 798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return false; 808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) allocPixels(); 828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Clear the bitmap to black. 838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) eraseColor(SK_ColorBLACK); 848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return true; 868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) bool initialize_expectation_; 898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 90f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(MockDriSkBitmap); 918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 93f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class MockDriSurface : public gfx::DriSurface { 948bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 95f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) MockDriSurface(gfx::HardwareDisplayController* controller) 96f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) : DriSurface(controller), 978bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) initialize_expectation_(true) {} 98f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual ~MockDriSurface() {} 998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1008bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void set_initialize_expectation(bool state) { 1018bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) initialize_expectation_ = state; 1028bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1038bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1048bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 105f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual gfx::DriSkBitmap* CreateBuffer() OVERRIDE { 106f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) return new MockDriSkBitmap(kFd, initialize_expectation_); 1078bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 1088bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1098bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) bool initialize_expectation_; 1108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 111f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(MockDriSurface); 1128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} // namespace 1158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 116f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class DriSurfaceTest : public testing::Test { 1178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public: 118f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) DriSurfaceTest() {} 1198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SetUp() OVERRIDE; 1218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void TearDown() OVERRIDE; 1228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) protected: 124f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_ptr<MockDriWrapper> drm_; 125f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_ptr<gfx::HardwareDisplayController> controller_; 126f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_ptr<MockDriSurface> surface_; 1278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) private: 129f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(DriSurfaceTest); 1308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}; 1318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 132f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)void DriSurfaceTest::SetUp() { 133f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) drm_.reset(new MockDriWrapper()); 134f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) controller_.reset(new gfx::HardwareDisplayController()); 1358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) controller_->SetControllerInfo( 1361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) drm_.get(), kConnectorId, kCrtcId, kDPMSPropertyId, kDefaultMode); 1378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 138f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) surface_.reset(new MockDriSurface(controller_.get())); 1398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 1408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 141f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)void DriSurfaceTest::TearDown() { 1428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) surface_.reset(); 1438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) controller_.reset(); 1448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) drm_.reset(); 1458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 1468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 147f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)TEST_F(DriSurfaceTest, FailInitialization) { 1488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) surface_->set_initialize_expectation(false); 1498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_FALSE(surface_->Initialize()); 1508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 1518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 152f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)TEST_F(DriSurfaceTest, SuccessfulInitialization) { 1538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_TRUE(surface_->Initialize()); 1548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 1558bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 156f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)TEST_F(DriSurfaceTest, CheckFBIDOnSwap) { 1578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_TRUE(surface_->Initialize()); 1588bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) controller_->BindSurfaceToController( 159f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) surface_.PassAs<gfx::DriSurface>()); 1608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Check that the framebuffer ID is correct. 1628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ(2u, controller_->get_surface()->GetFramebufferId()); 1638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) controller_->get_surface()->SwapBuffers(); 1658bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1668bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ(1u, controller_->get_surface()->GetFramebufferId()); 1678bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 1688bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 169f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)TEST_F(DriSurfaceTest, CheckPixelPointerOnSwap) { 1708bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_TRUE(surface_->Initialize()); 1718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void* bitmap_pixels1 = surface_->GetDrawableForWidget()->getDevice() 1738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ->accessBitmap(false).getPixels(); 1748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) surface_->SwapBuffers(); 1768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void* bitmap_pixels2 = surface_->GetDrawableForWidget()->getDevice() 1788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ->accessBitmap(false).getPixels(); 1798bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1808bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Check that once the buffers have been swapped the drawable's underlying 1818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // pixels have been changed. 1828bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_NE(bitmap_pixels1, bitmap_pixels2); 1838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 1848bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 185f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)TEST_F(DriSurfaceTest, CheckCorrectBufferSync) { 1868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_TRUE(surface_->Initialize()); 1878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1888bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SkCanvas* canvas = surface_->GetDrawableForWidget(); 1898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) SkRect clip; 1908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Modify part of the canvas. 1918bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) clip.set(0, 0, 1928bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) canvas->getDeviceSize().width() / 2, 1938bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) canvas->getDeviceSize().height() / 2); 1948bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) canvas->clipRect(clip, SkRegion::kReplace_Op); 1958bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1968bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) canvas->drawColor(SK_ColorWHITE); 1978bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 1988bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) surface_->SwapBuffers(); 1998bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 2008bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Verify that the modified contents have been copied over on swap (make sure 2018bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // the 2 buffers have the same content). 2028bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) for (int i = 0; i < canvas->getDeviceSize().height(); ++i) { 2038bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) for (int j = 0; j < canvas->getDeviceSize().width(); ++j) { 2048bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) if (i < clip.height() && j < clip.width()) 2058bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ(SK_ColorWHITE, 2068bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) canvas->getDevice()->accessBitmap(false).getColor(j, i)); 2078bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) else 2088bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) EXPECT_EQ(SK_ColorBLACK, 2098bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) canvas->getDevice()->accessBitmap(false).getColor(j, i)); 2108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 2128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 213