| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "platform/WebTaskRunner.h" | 35 #include "platform/WebTaskRunner.h" |
| 36 #include "platform/graphics/ImageBuffer.h" | 36 #include "platform/graphics/ImageBuffer.h" |
| 37 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 37 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 38 #include "platform/graphics/test/FakeGLES2Interface.h" | 38 #include "platform/graphics/test/FakeGLES2Interface.h" |
| 39 #include "platform/graphics/test/FakeWebGraphicsContext3DProvider.h" | 39 #include "platform/graphics/test/FakeWebGraphicsContext3DProvider.h" |
| 40 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
| 41 #include "public/platform/WebExternalBitmap.h" | 41 #include "public/platform/WebExternalBitmap.h" |
| 42 #include "public/platform/WebScheduler.h" | 42 #include "public/platform/WebScheduler.h" |
| 43 #include "public/platform/WebThread.h" | 43 #include "public/platform/WebThread.h" |
| 44 #include "public/platform/WebTraceLocation.h" | 44 #include "public/platform/WebTraceLocation.h" |
| 45 #include "skia/ext/cdl_paint.h" |
| 46 #include "skia/ext/cdl_surface.h" |
| 45 #include "skia/ext/texture_handle.h" | 47 #include "skia/ext/texture_handle.h" |
| 46 #include "testing/gmock/include/gmock/gmock.h" | 48 #include "testing/gmock/include/gmock/gmock.h" |
| 47 #include "testing/gtest/include/gtest/gtest.h" | 49 #include "testing/gtest/include/gtest/gtest.h" |
| 48 #include "third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h" | 50 #include "third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h" |
| 49 #include "third_party/skia/include/core/SkCanvas.h" | 51 #include "third_party/skia/include/core/SkCanvas.h" |
| 50 #include "third_party/skia/include/core/SkSurface.h" | 52 #include "third_party/skia/include/core/SkSurface.h" |
| 51 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" | 53 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
| 52 #include "wtf/PtrUtil.h" | 54 #include "wtf/PtrUtil.h" |
| 53 #include "wtf/RefPtr.h" | 55 #include "wtf/RefPtr.h" |
| 54 | 56 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 void noDrawOnContextLostTest() { | 205 void noDrawOnContextLostTest() { |
| 204 FakeGLES2Interface gl; | 206 FakeGLES2Interface gl; |
| 205 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = | 207 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = |
| 206 wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); | 208 wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); |
| 207 | 209 |
| 208 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge( | 210 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge( |
| 209 std::move(contextProvider), IntSize(300, 150), 0, NonOpaque, | 211 std::move(contextProvider), IntSize(300, 150), 0, NonOpaque, |
| 210 Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr, | 212 Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr, |
| 211 kN32_SkColorType))); | 213 kN32_SkColorType))); |
| 212 EXPECT_TRUE(bridge->checkSurfaceValid()); | 214 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 213 SkPaint paint; | 215 CdlPaint paint; |
| 214 uint32_t genID = bridge->getOrCreateSurface()->generationID(); | 216 uint32_t genID = bridge->getOrCreateSurface()->generationID(); |
| 215 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); | 217 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); |
| 216 EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID()); | 218 EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID()); |
| 217 gl.setIsContextLost(true); | 219 gl.setIsContextLost(true); |
| 218 EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID()); | 220 EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID()); |
| 219 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); | 221 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); |
| 220 EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID()); | 222 EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID()); |
| 221 // This results in the internal surface being torn down in response to the | 223 // This results in the internal surface being torn down in response to the |
| 222 // context loss. | 224 // context loss. |
| 223 EXPECT_FALSE(bridge->checkSurfaceValid()); | 225 EXPECT_FALSE(bridge->checkSurfaceValid()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 302 } |
| 301 | 303 |
| 302 void accelerationHintTest() { | 304 void accelerationHintTest() { |
| 303 { | 305 { |
| 304 FakeGLES2Interface gl; | 306 FakeGLES2Interface gl; |
| 305 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = | 307 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = |
| 306 wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); | 308 wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); |
| 307 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge( | 309 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge( |
| 308 std::move(contextProvider), IntSize(300, 300), 0, NonOpaque, | 310 std::move(contextProvider), IntSize(300, 300), 0, NonOpaque, |
| 309 Canvas2DLayerBridge::EnableAcceleration, nullptr, kN32_SkColorType))); | 311 Canvas2DLayerBridge::EnableAcceleration, nullptr, kN32_SkColorType))); |
| 310 SkPaint paint; | 312 CdlPaint paint; |
| 311 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); | 313 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); |
| 312 sk_sp<SkImage> image = | 314 sk_sp<SkImage> image = |
| 313 bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests); | 315 bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests); |
| 314 EXPECT_TRUE(bridge->checkSurfaceValid()); | 316 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 315 EXPECT_TRUE(bridge->isAccelerated()); | 317 EXPECT_TRUE(bridge->isAccelerated()); |
| 316 } | 318 } |
| 317 | 319 |
| 318 { | 320 { |
| 319 FakeGLES2Interface gl; | 321 FakeGLES2Interface gl; |
| 320 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = | 322 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = |
| 321 wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); | 323 wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); |
| 322 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge( | 324 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge( |
| 323 std::move(contextProvider), IntSize(300, 300), 0, NonOpaque, | 325 std::move(contextProvider), IntSize(300, 300), 0, NonOpaque, |
| 324 Canvas2DLayerBridge::EnableAcceleration, nullptr, kN32_SkColorType))); | 326 Canvas2DLayerBridge::EnableAcceleration, nullptr, kN32_SkColorType))); |
| 325 SkPaint paint; | 327 CdlPaint paint; |
| 326 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); | 328 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); |
| 327 sk_sp<SkImage> image = bridge->newImageSnapshot(PreferNoAcceleration, | 329 sk_sp<SkImage> image = bridge->newImageSnapshot(PreferNoAcceleration, |
| 328 SnapshotReasonUnitTests); | 330 SnapshotReasonUnitTests); |
| 329 EXPECT_TRUE(bridge->checkSurfaceValid()); | 331 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 330 EXPECT_FALSE(bridge->isAccelerated()); | 332 EXPECT_FALSE(bridge->isAccelerated()); |
| 331 } | 333 } |
| 332 } | 334 } |
| 333 }; | 335 }; |
| 334 | 336 |
| 335 TEST_F(Canvas2DLayerBridgeTest, FullLifecycleSingleThreaded) { | 337 TEST_F(Canvas2DLayerBridgeTest, FullLifecycleSingleThreaded) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 postSetIsHiddenTask(location, testThread, bridge, value, doneEvent.get()); | 455 postSetIsHiddenTask(location, testThread, bridge, value, doneEvent.get()); |
| 454 doneEvent->wait(); | 456 doneEvent->wait(); |
| 455 } | 457 } |
| 456 | 458 |
| 457 class MockImageBuffer : public ImageBuffer { | 459 class MockImageBuffer : public ImageBuffer { |
| 458 public: | 460 public: |
| 459 MockImageBuffer() | 461 MockImageBuffer() |
| 460 : ImageBuffer( | 462 : ImageBuffer( |
| 461 wrapUnique(new UnacceleratedImageBufferSurface(IntSize(1, 1)))) {} | 463 wrapUnique(new UnacceleratedImageBufferSurface(IntSize(1, 1)))) {} |
| 462 | 464 |
| 463 MOCK_CONST_METHOD1(resetCanvas, void(SkCanvas*)); | 465 MOCK_CONST_METHOD1(resetCanvas, void(CdlCanvas*)); |
| 464 | 466 |
| 465 virtual ~MockImageBuffer() {} | 467 virtual ~MockImageBuffer() {} |
| 466 }; | 468 }; |
| 467 | 469 |
| 468 #if CANVAS2D_HIBERNATION_ENABLED | 470 #if CANVAS2D_HIBERNATION_ENABLED |
| 469 TEST_F(Canvas2DLayerBridgeTest, HibernationLifeCycle) | 471 TEST_F(Canvas2DLayerBridgeTest, HibernationLifeCycle) |
| 470 #else | 472 #else |
| 471 TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationLifeCycle) | 473 TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationLifeCycle) |
| 472 #endif | 474 #endif |
| 473 { | 475 { |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 } | 1272 } |
| 1271 | 1273 |
| 1272 bool lostResource = false; | 1274 bool lostResource = false; |
| 1273 releaseCallback->Run(gpu::SyncToken(), lostResource); | 1275 releaseCallback->Run(gpu::SyncToken(), lostResource); |
| 1274 | 1276 |
| 1275 EXPECT_EQ(1u, gl.createImageCount()); | 1277 EXPECT_EQ(1u, gl.createImageCount()); |
| 1276 EXPECT_EQ(1u, gl.destroyImageCount()); | 1278 EXPECT_EQ(1u, gl.destroyImageCount()); |
| 1277 } | 1279 } |
| 1278 | 1280 |
| 1279 } // namespace blink | 1281 } // namespace blink |
| OLD | NEW |