| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "platform/graphics/gpu/DrawingBuffer.h" | 31 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 32 | 32 |
| 33 #include "gpu/command_buffer/client/gles2_interface_stub.h" | 33 #include "gpu/command_buffer/client/gles2_interface_stub.h" |
| 34 #include "platform/RuntimeEnabledFeatures.h" | 34 #include "platform/RuntimeEnabledFeatures.h" |
| 35 #include "platform/graphics/ImageBuffer.h" | 35 #include "platform/graphics/ImageBuffer.h" |
| 36 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 36 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 37 #include "platform/graphics/gpu/Extensions3DUtil.h" | 37 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 38 #include "platform/graphics/test/MockWebGraphicsContext3D.h" | |
| 39 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
| 40 #include "public/platform/WebExternalTextureMailbox.h" | 39 #include "public/platform/WebExternalTextureMailbox.h" |
| 41 #include "public/platform/WebGraphicsContext3D.h" | 40 #include "public/platform/WebGraphicsContext3D.h" |
| 42 #include "public/platform/WebGraphicsContext3DProvider.h" | 41 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 43 #include "public/platform/callback/WebClosure.h" | 42 #include "public/platform/callback/WebClosure.h" |
| 44 #include "testing/gmock/include/gmock/gmock.h" | 43 #include "testing/gmock/include/gmock/gmock.h" |
| 45 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
| 46 #include "wtf/RefPtr.h" | 45 #include "wtf/RefPtr.h" |
| 47 | 46 |
| 48 using testing::Test; | 47 using testing::Test; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 void GenTextures(GLsizei n, GLuint* textures) override | 173 void GenTextures(GLsizei n, GLuint* textures) override |
| 175 { | 174 { |
| 176 static GLuint id = 1; | 175 static GLuint id = 1; |
| 177 for (GLsizei i = 0; i < n; ++i) | 176 for (GLsizei i = 0; i < n; ++i) |
| 178 textures[i] = id++; | 177 textures[i] = id++; |
| 179 } | 178 } |
| 180 | 179 |
| 181 GLuint boundTexture() const { return m_boundTexture; } | 180 GLuint boundTexture() const { return m_boundTexture; } |
| 182 GLuint boundTextureTarget() const { return m_boundTextureTarget; } | 181 GLuint boundTextureTarget() const { return m_boundTextureTarget; } |
| 183 GLuint mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSync
Token; } | 182 GLuint mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSync
Token; } |
| 184 GLuint currentImageId() const { return m_currentImageId; } | 183 GLuint nextImageIdToBeCreated() const { return m_currentImageId; } |
| 185 IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize
; } | 184 IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize
; } |
| 186 bool allowImageChromium() const { return m_allowImageChromium; } | 185 bool allowImageChromium() const { return m_allowImageChromium; } |
| 187 | 186 |
| 188 void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; } | 187 void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; } |
| 189 | 188 |
| 190 private: | 189 private: |
| 191 GLuint m_boundTexture = 0; | 190 GLuint m_boundTexture = 0; |
| 192 GLuint m_boundTextureTarget = 0; | 191 GLuint m_boundTextureTarget = 0; |
| 193 GLuint m_mostRecentlyWaitedSyncToken = 0; | 192 GLuint m_mostRecentlyWaitedSyncToken = 0; |
| 194 GLbyte m_currentMailboxByte = 0; | 193 GLbyte m_currentMailboxByte = 0; |
| 195 IntSize m_mostRecentlyProducedSize; | 194 IntSize m_mostRecentlyProducedSize; |
| 196 bool m_allowImageChromium = true; | 195 bool m_allowImageChromium = true; |
| 197 GLuint m_currentImageId = 1; | 196 GLuint m_currentImageId = 1; |
| 198 HashMap<GLuint, IntSize> m_textureSizes; | 197 HashMap<GLuint, IntSize> m_textureSizes; |
| 199 HashMap<GLuint, IntSize> m_imageSizes; | 198 HashMap<GLuint, IntSize> m_imageSizes; |
| 200 HashMap<GLuint, GLuint> m_imageToTextureMap; | 199 HashMap<GLuint, GLuint> m_imageToTextureMap; |
| 201 }; | 200 }; |
| 202 | 201 |
| 203 class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D { | |
| 204 public: | |
| 205 WebGraphicsContext3DForTests(GLES2InterfaceForTests* contextGL) | |
| 206 : m_contextGL(contextGL) | |
| 207 { | |
| 208 } | |
| 209 | |
| 210 GLuint mostRecentlyWaitedSyncToken() | |
| 211 { | |
| 212 return m_contextGL->mostRecentlyWaitedSyncToken(); | |
| 213 } | |
| 214 | |
| 215 IntSize mostRecentlyProducedSize() | |
| 216 { | |
| 217 return m_contextGL->mostRecentlyProducedSize(); | |
| 218 } | |
| 219 | |
| 220 | |
| 221 GLuint nextImageIdToBeCreated() | |
| 222 { | |
| 223 return m_contextGL->currentImageId(); | |
| 224 } | |
| 225 | |
| 226 private: | |
| 227 GLES2InterfaceForTests* m_contextGL; | |
| 228 }; | |
| 229 | |
| 230 static const int initialWidth = 100; | 202 static const int initialWidth = 100; |
| 231 static const int initialHeight = 100; | 203 static const int initialHeight = 100; |
| 232 static const int alternateHeight = 50; | 204 static const int alternateHeight = 50; |
| 233 | 205 |
| 234 class DrawingBufferForTests : public DrawingBuffer { | 206 class DrawingBufferForTests : public DrawingBuffer { |
| 235 public: | 207 public: |
| 236 static PassRefPtr<DrawingBufferForTests> create(PassOwnPtr<WebGraphicsContex
t3DProvider> contextProvider, const IntSize& size, PreserveDrawingBuffer preserv
e) | 208 static PassRefPtr<DrawingBufferForTests> create(PassOwnPtr<WebGraphicsContex
t3DProvider> contextProvider, const IntSize& size, PreserveDrawingBuffer preserv
e) |
| 237 { | 209 { |
| 238 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(conte
xtProvider->contextGL()); | 210 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(conte
xtProvider->contextGL()); |
| 239 RefPtr<DrawingBufferForTests> drawingBuffer = adoptRef(new DrawingBuffer
ForTests(contextProvider, extensionsUtil.release(), preserve)); | 211 RefPtr<DrawingBufferForTests> drawingBuffer = adoptRef(new DrawingBuffer
ForTests(contextProvider, extensionsUtil.release(), preserve)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 256 { | 228 { |
| 257 if (m_live) | 229 if (m_live) |
| 258 *m_live = false; | 230 *m_live = false; |
| 259 } | 231 } |
| 260 | 232 |
| 261 bool* m_live; | 233 bool* m_live; |
| 262 }; | 234 }; |
| 263 | 235 |
| 264 class WebGraphicsContext3DProviderForTests : public WebGraphicsContext3DProvider
{ | 236 class WebGraphicsContext3DProviderForTests : public WebGraphicsContext3DProvider
{ |
| 265 public: | 237 public: |
| 266 WebGraphicsContext3DProviderForTests(PassOwnPtr<WebGraphicsContext3D> contex
t, PassOwnPtr<gpu::gles2::GLES2Interface> gl) | 238 WebGraphicsContext3DProviderForTests(PassOwnPtr<gpu::gles2::GLES2Interface>
gl) |
| 267 : m_context(std::move(context)) | 239 : m_gl(std::move(gl)) |
| 268 , m_gl(std::move(gl)) | |
| 269 { | 240 { |
| 270 } | 241 } |
| 271 | 242 |
| 272 WebGraphicsContext3D* context3d() override { return m_context.get(); } | 243 WebGraphicsContext3D* context3d() override { return nullptr; } |
| 273 gpu::gles2::GLES2Interface* contextGL() override { return m_gl.get(); } | 244 gpu::gles2::GLES2Interface* contextGL() override { return m_gl.get(); } |
| 274 // Not used by WebGL code. | 245 // Not used by WebGL code. |
| 275 GrContext* grContext() override { return nullptr; } | 246 GrContext* grContext() override { return nullptr; } |
| 276 void setLostContextCallback(WebClosure) {} | 247 void setLostContextCallback(WebClosure) {} |
| 277 | 248 |
| 278 private: | 249 private: |
| 279 OwnPtr<WebGraphicsContext3D> m_context; | |
| 280 OwnPtr<gpu::gles2::GLES2Interface> m_gl; | 250 OwnPtr<gpu::gles2::GLES2Interface> m_gl; |
| 281 }; | 251 }; |
| 282 | 252 |
| 283 class DrawingBufferTest : public Test { | 253 class DrawingBufferTest : public Test { |
| 284 protected: | 254 protected: |
| 285 void SetUp() override | 255 void SetUp() override |
| 286 { | 256 { |
| 287 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests)
; | 257 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests)
; |
| 288 m_gl = gl.get(); | 258 m_gl = gl.get(); |
| 289 OwnPtr<WebGraphicsContext3DForTests> context = adoptPtr(new WebGraphicsC
ontext3DForTests(m_gl)); | 259 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web
GraphicsContext3DProviderForTests(gl.release())); |
| 290 m_context = context.get(); | |
| 291 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web
GraphicsContext3DProviderForTests(context.release(), gl.release())); | |
| 292 m_drawingBuffer = DrawingBufferForTests::create(provider.release(), IntS
ize(initialWidth, initialHeight), DrawingBuffer::Preserve); | 260 m_drawingBuffer = DrawingBufferForTests::create(provider.release(), IntS
ize(initialWidth, initialHeight), DrawingBuffer::Preserve); |
| 293 CHECK(m_drawingBuffer); | 261 CHECK(m_drawingBuffer); |
| 294 } | 262 } |
| 295 | 263 |
| 296 WebGraphicsContext3DForTests* webContext() | |
| 297 { | |
| 298 return m_context; | |
| 299 } | |
| 300 | |
| 301 WebGraphicsContext3DForTests* m_context; | |
| 302 GLES2InterfaceForTests* m_gl; | 264 GLES2InterfaceForTests* m_gl; |
| 303 RefPtr<DrawingBufferForTests> m_drawingBuffer; | 265 RefPtr<DrawingBufferForTests> m_drawingBuffer; |
| 304 }; | 266 }; |
| 305 | 267 |
| 306 TEST_F(DrawingBufferTest, verifyResizingProperlyAffectsMailboxes) | 268 TEST_F(DrawingBufferTest, verifyResizingProperlyAffectsMailboxes) |
| 307 { | 269 { |
| 308 WebExternalTextureMailbox mailbox; | 270 WebExternalTextureMailbox mailbox; |
| 309 | 271 |
| 310 IntSize initialSize(initialWidth, initialHeight); | 272 IntSize initialSize(initialWidth, initialHeight); |
| 311 IntSize alternateSize(initialWidth, alternateHeight); | 273 IntSize alternateSize(initialWidth, alternateHeight); |
| 312 | 274 |
| 313 // Produce one mailbox at size 100x100. | 275 // Produce one mailbox at size 100x100. |
| 314 m_drawingBuffer->markContentsChanged(); | 276 m_drawingBuffer->markContentsChanged(); |
| 315 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 277 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 316 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); | 278 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 317 | 279 |
| 318 // Resize to 100x50. | 280 // Resize to 100x50. |
| 319 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight), false); | 281 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight), false); |
| 320 m_drawingBuffer->mailboxReleased(mailbox, false); | 282 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 321 | 283 |
| 322 // Produce a mailbox at this size. | 284 // Produce a mailbox at this size. |
| 323 m_drawingBuffer->markContentsChanged(); | 285 m_drawingBuffer->markContentsChanged(); |
| 324 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 286 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 325 EXPECT_EQ(alternateSize, webContext()->mostRecentlyProducedSize()); | 287 EXPECT_EQ(alternateSize, m_gl->mostRecentlyProducedSize()); |
| 326 | 288 |
| 327 // Reset to initial size. | 289 // Reset to initial size. |
| 328 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight), false); | 290 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight), false); |
| 329 m_drawingBuffer->mailboxReleased(mailbox, false); | 291 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 330 | 292 |
| 331 // Prepare another mailbox and verify that it's the correct size. | 293 // Prepare another mailbox and verify that it's the correct size. |
| 332 m_drawingBuffer->markContentsChanged(); | 294 m_drawingBuffer->markContentsChanged(); |
| 333 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 295 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 334 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); | 296 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 335 | 297 |
| 336 // Prepare one final mailbox and verify that it's the correct size. | 298 // Prepare one final mailbox and verify that it's the correct size. |
| 337 m_drawingBuffer->mailboxReleased(mailbox, false); | 299 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 338 m_drawingBuffer->markContentsChanged(); | 300 m_drawingBuffer->markContentsChanged(); |
| 339 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 301 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 340 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); | 302 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 341 m_drawingBuffer->mailboxReleased(mailbox, false); | 303 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 342 m_drawingBuffer->beginDestruction(); | 304 m_drawingBuffer->beginDestruction(); |
| 343 } | 305 } |
| 344 | 306 |
| 345 TEST_F(DrawingBufferTest, verifyDestructionCompleteAfterAllMailboxesReleased) | 307 TEST_F(DrawingBufferTest, verifyDestructionCompleteAfterAllMailboxesReleased) |
| 346 { | 308 { |
| 347 bool live = true; | 309 bool live = true; |
| 348 m_drawingBuffer->m_live = &live; | 310 m_drawingBuffer->m_live = &live; |
| 349 | 311 |
| 350 WebExternalTextureMailbox mailbox1; | 312 WebExternalTextureMailbox mailbox1; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 m_drawingBuffer->mailboxReleased(recycledMailbox2, false); | 438 m_drawingBuffer->mailboxReleased(recycledMailbox2, false); |
| 477 m_drawingBuffer->beginDestruction(); | 439 m_drawingBuffer->beginDestruction(); |
| 478 } | 440 } |
| 479 | 441 |
| 480 TEST_F(DrawingBufferTest, verifyInsertAndWaitSyncTokenCorrectly) | 442 TEST_F(DrawingBufferTest, verifyInsertAndWaitSyncTokenCorrectly) |
| 481 { | 443 { |
| 482 WebExternalTextureMailbox mailbox; | 444 WebExternalTextureMailbox mailbox; |
| 483 | 445 |
| 484 // Produce mailboxes. | 446 // Produce mailboxes. |
| 485 m_drawingBuffer->markContentsChanged(); | 447 m_drawingBuffer->markContentsChanged(); |
| 486 EXPECT_EQ(0u, webContext()->mostRecentlyWaitedSyncToken()); | 448 EXPECT_EQ(0u, m_gl->mostRecentlyWaitedSyncToken()); |
| 487 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 449 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 488 // prepareMailbox() does not wait for any sync point. | 450 // prepareMailbox() does not wait for any sync point. |
| 489 EXPECT_EQ(0u, webContext()->mostRecentlyWaitedSyncToken()); | 451 EXPECT_EQ(0u, m_gl->mostRecentlyWaitedSyncToken()); |
| 490 | 452 |
| 491 GLuint64 waitSyncToken = 0; | 453 GLuint64 waitSyncToken = 0; |
| 492 m_gl->GenSyncTokenCHROMIUM(m_gl->InsertFenceSyncCHROMIUM(), reinterpret_cast
<GLbyte*>(&waitSyncToken)); | 454 m_gl->GenSyncTokenCHROMIUM(m_gl->InsertFenceSyncCHROMIUM(), reinterpret_cast
<GLbyte*>(&waitSyncToken)); |
| 493 memcpy(mailbox.syncToken, &waitSyncToken, sizeof(waitSyncToken)); | 455 memcpy(mailbox.syncToken, &waitSyncToken, sizeof(waitSyncToken)); |
| 494 mailbox.validSyncToken = true; | 456 mailbox.validSyncToken = true; |
| 495 m_drawingBuffer->mailboxReleased(mailbox, false); | 457 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 496 // m_drawingBuffer will wait for the sync point when recycling. | 458 // m_drawingBuffer will wait for the sync point when recycling. |
| 497 EXPECT_EQ(0u, webContext()->mostRecentlyWaitedSyncToken()); | 459 EXPECT_EQ(0u, m_gl->mostRecentlyWaitedSyncToken()); |
| 498 | 460 |
| 499 m_drawingBuffer->markContentsChanged(); | 461 m_drawingBuffer->markContentsChanged(); |
| 500 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 462 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 501 // m_drawingBuffer waits for the sync point when recycling in prepareMailbox
(). | 463 // m_drawingBuffer waits for the sync point when recycling in prepareMailbox
(). |
| 502 EXPECT_EQ(waitSyncToken, webContext()->mostRecentlyWaitedSyncToken()); | 464 EXPECT_EQ(waitSyncToken, m_gl->mostRecentlyWaitedSyncToken()); |
| 503 | 465 |
| 504 m_drawingBuffer->beginDestruction(); | 466 m_drawingBuffer->beginDestruction(); |
| 505 m_gl->GenSyncTokenCHROMIUM(m_gl->InsertFenceSyncCHROMIUM(), reinterpret_cast
<GLbyte*>(&waitSyncToken)); | 467 m_gl->GenSyncTokenCHROMIUM(m_gl->InsertFenceSyncCHROMIUM(), reinterpret_cast
<GLbyte*>(&waitSyncToken)); |
| 506 memcpy(mailbox.syncToken, &waitSyncToken, sizeof(waitSyncToken)); | 468 memcpy(mailbox.syncToken, &waitSyncToken, sizeof(waitSyncToken)); |
| 507 mailbox.validSyncToken = true; | 469 mailbox.validSyncToken = true; |
| 508 m_drawingBuffer->mailboxReleased(mailbox, false); | 470 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 509 // m_drawingBuffer waits for the sync point because the destruction is in pr
ogress. | 471 // m_drawingBuffer waits for the sync point because the destruction is in pr
ogress. |
| 510 EXPECT_EQ(waitSyncToken, webContext()->mostRecentlyWaitedSyncToken()); | 472 EXPECT_EQ(waitSyncToken, m_gl->mostRecentlyWaitedSyncToken()); |
| 511 } | 473 } |
| 512 | 474 |
| 513 class DrawingBufferImageChromiumTest : public DrawingBufferTest { | 475 class DrawingBufferImageChromiumTest : public DrawingBufferTest { |
| 514 protected: | 476 protected: |
| 515 void SetUp() override | 477 void SetUp() override |
| 516 { | 478 { |
| 517 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests)
; | 479 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests)
; |
| 518 m_gl = gl.get(); | 480 m_gl = gl.get(); |
| 519 OwnPtr<WebGraphicsContext3DForTests> context = adoptPtr(new WebGraphicsC
ontext3DForTests(m_gl)); | 481 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web
GraphicsContext3DProviderForTests(gl.release())); |
| 520 m_context = context.get(); | |
| 521 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web
GraphicsContext3DProviderForTests(context.release(), gl.release())); | |
| 522 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true); | 482 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true); |
| 523 m_imageId0 = webContext()->nextImageIdToBeCreated(); | 483 m_imageId0 = m_gl->nextImageIdToBeCreated(); |
| 524 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId0)).Times(1); | 484 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId0)).Times(1); |
| 525 m_drawingBuffer = DrawingBufferForTests::create(provider.release(), | 485 m_drawingBuffer = DrawingBufferForTests::create(provider.release(), |
| 526 IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve); | 486 IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve); |
| 527 CHECK(m_drawingBuffer); | 487 CHECK(m_drawingBuffer); |
| 528 testing::Mock::VerifyAndClearExpectations(webContext()); | 488 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 529 } | 489 } |
| 530 | 490 |
| 531 void TearDown() override | 491 void TearDown() override |
| 532 { | 492 { |
| 533 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(false); | 493 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(false); |
| 534 } | 494 } |
| 535 | 495 |
| 536 GLuint m_imageId0; | 496 GLuint m_imageId0; |
| 537 }; | 497 }; |
| 538 | 498 |
| 539 TEST_F(DrawingBufferImageChromiumTest, verifyResizingReallocatesImages) | 499 TEST_F(DrawingBufferImageChromiumTest, verifyResizingReallocatesImages) |
| 540 { | 500 { |
| 541 WebExternalTextureMailbox mailbox; | 501 WebExternalTextureMailbox mailbox; |
| 542 | 502 |
| 543 IntSize initialSize(initialWidth, initialHeight); | 503 IntSize initialSize(initialWidth, initialHeight); |
| 544 IntSize alternateSize(initialWidth, alternateHeight); | 504 IntSize alternateSize(initialWidth, alternateHeight); |
| 545 | 505 |
| 546 GLuint m_imageId1 = webContext()->nextImageIdToBeCreated(); | 506 GLuint m_imageId1 = m_gl->nextImageIdToBeCreated(); |
| 547 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId1)).Times(1); | 507 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId1)).Times(1); |
| 548 // Produce one mailbox at size 100x100. | 508 // Produce one mailbox at size 100x100. |
| 549 m_drawingBuffer->markContentsChanged(); | 509 m_drawingBuffer->markContentsChanged(); |
| 550 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 510 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 551 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); | 511 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 552 EXPECT_TRUE(mailbox.allowOverlay); | 512 EXPECT_TRUE(mailbox.allowOverlay); |
| 553 testing::Mock::VerifyAndClearExpectations(webContext()); | 513 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 554 | 514 |
| 555 GLuint m_imageId2 = webContext()->nextImageIdToBeCreated(); | 515 GLuint m_imageId2 = m_gl->nextImageIdToBeCreated(); |
| 556 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId2)).Times(1); | 516 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId2)).Times(1); |
| 557 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId0)).Times(1); | 517 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId0)).Times(1); |
| 558 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId0)).Times(1); | 518 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId0)).Times(1); |
| 559 // Resize to 100x50. | 519 // Resize to 100x50. |
| 560 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight), false); | 520 m_drawingBuffer->reset(IntSize(initialWidth, alternateHeight), false); |
| 561 m_drawingBuffer->mailboxReleased(mailbox, false); | 521 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 562 testing::Mock::VerifyAndClearExpectations(webContext()); | 522 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 563 | 523 |
| 564 GLuint m_imageId3 = webContext()->nextImageIdToBeCreated(); | 524 GLuint m_imageId3 = m_gl->nextImageIdToBeCreated(); |
| 565 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId3)).Times(1); | 525 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId3)).Times(1); |
| 566 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId1)).Times(1); | 526 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId1)).Times(1); |
| 567 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId1)).Times(1); | 527 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId1)).Times(1); |
| 568 // Produce a mailbox at this size. | 528 // Produce a mailbox at this size. |
| 569 m_drawingBuffer->markContentsChanged(); | 529 m_drawingBuffer->markContentsChanged(); |
| 570 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 530 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 571 EXPECT_EQ(alternateSize, webContext()->mostRecentlyProducedSize()); | 531 EXPECT_EQ(alternateSize, m_gl->mostRecentlyProducedSize()); |
| 572 EXPECT_TRUE(mailbox.allowOverlay); | 532 EXPECT_TRUE(mailbox.allowOverlay); |
| 573 testing::Mock::VerifyAndClearExpectations(webContext()); | 533 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 574 | 534 |
| 575 GLuint m_imageId4 = webContext()->nextImageIdToBeCreated(); | 535 GLuint m_imageId4 = m_gl->nextImageIdToBeCreated(); |
| 576 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId4)).Times(1); | 536 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId4)).Times(1); |
| 577 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId2)).Times(1); | 537 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId2)).Times(1); |
| 578 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId2)).Times(1); | 538 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId2)).Times(1); |
| 579 // Reset to initial size. | 539 // Reset to initial size. |
| 580 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight), false); | 540 m_drawingBuffer->reset(IntSize(initialWidth, initialHeight), false); |
| 581 m_drawingBuffer->mailboxReleased(mailbox, false); | 541 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 582 testing::Mock::VerifyAndClearExpectations(webContext()); | 542 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 583 | 543 |
| 584 GLuint m_imageId5 = webContext()->nextImageIdToBeCreated(); | 544 GLuint m_imageId5 = m_gl->nextImageIdToBeCreated(); |
| 585 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId5)).Times(1); | 545 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId5)).Times(1); |
| 586 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId3)).Times(1); | 546 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId3)).Times(1); |
| 587 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId3)).Times(1); | 547 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId3)).Times(1); |
| 588 // Prepare another mailbox and verify that it's the correct size. | 548 // Prepare another mailbox and verify that it's the correct size. |
| 589 m_drawingBuffer->markContentsChanged(); | 549 m_drawingBuffer->markContentsChanged(); |
| 590 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 550 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 591 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); | 551 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 592 EXPECT_TRUE(mailbox.allowOverlay); | 552 EXPECT_TRUE(mailbox.allowOverlay); |
| 593 testing::Mock::VerifyAndClearExpectations(webContext()); | 553 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 594 | 554 |
| 595 // Prepare one final mailbox and verify that it's the correct size. | 555 // Prepare one final mailbox and verify that it's the correct size. |
| 596 m_drawingBuffer->mailboxReleased(mailbox, false); | 556 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 597 m_drawingBuffer->markContentsChanged(); | 557 m_drawingBuffer->markContentsChanged(); |
| 598 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 558 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 599 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); | 559 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 600 EXPECT_TRUE(mailbox.allowOverlay); | 560 EXPECT_TRUE(mailbox.allowOverlay); |
| 601 m_drawingBuffer->mailboxReleased(mailbox, false); | 561 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 602 | 562 |
| 603 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId5)).Times(1); | 563 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId5)).Times(1); |
| 604 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId5)).Times(1); | 564 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId5)).Times(1); |
| 605 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId4)).Times(1); | 565 EXPECT_CALL(*m_gl, DestroyImageMock(m_imageId4)).Times(1); |
| 606 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId4)).Times(1); | 566 EXPECT_CALL(*m_gl, ReleaseTexImage2DMock(m_imageId4)).Times(1); |
| 607 m_drawingBuffer->beginDestruction(); | 567 m_drawingBuffer->beginDestruction(); |
| 608 testing::Mock::VerifyAndClearExpectations(webContext()); | 568 testing::Mock::VerifyAndClearExpectations(m_gl); |
| 609 } | 569 } |
| 610 | 570 |
| 611 class DepthStencilTrackingGLES2Interface : public gpu::gles2::GLES2InterfaceStub
{ | 571 class DepthStencilTrackingGLES2Interface : public gpu::gles2::GLES2InterfaceStub
{ |
| 612 public: | 572 public: |
| 613 void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render
buffertarget, GLuint renderbuffer) override | 573 void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render
buffertarget, GLuint renderbuffer) override |
| 614 { | 574 { |
| 615 switch (attachment) { | 575 switch (attachment) { |
| 616 case GL_DEPTH_ATTACHMENT: | 576 case GL_DEPTH_ATTACHMENT: |
| 617 m_depthAttachment = renderbuffer; | 577 m_depthAttachment = renderbuffer; |
| 618 break; | 578 break; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 GLuint depthStencilAttachment() const { return m_depthStencilAttachment; } | 620 GLuint depthStencilAttachment() const { return m_depthStencilAttachment; } |
| 661 size_t numAllocatedRenderBuffer() const { return m_nextGenRenderbufferId - 1
; } | 621 size_t numAllocatedRenderBuffer() const { return m_nextGenRenderbufferId - 1
; } |
| 662 | 622 |
| 663 private: | 623 private: |
| 664 GLuint m_nextGenRenderbufferId = 1; | 624 GLuint m_nextGenRenderbufferId = 1; |
| 665 GLuint m_depthAttachment = 0; | 625 GLuint m_depthAttachment = 0; |
| 666 GLuint m_stencilAttachment = 0; | 626 GLuint m_stencilAttachment = 0; |
| 667 GLuint m_depthStencilAttachment = 0; | 627 GLuint m_depthStencilAttachment = 0; |
| 668 }; | 628 }; |
| 669 | 629 |
| 670 class DepthStencilTrackingContext : public MockWebGraphicsContext3D { | |
| 671 public: | |
| 672 DepthStencilTrackingContext(DepthStencilTrackingGLES2Interface* gl) | |
| 673 : m_contextGL(gl) | |
| 674 { | |
| 675 } | |
| 676 ~DepthStencilTrackingContext() override {} | |
| 677 | |
| 678 size_t numAllocatedRenderBuffer() const { return m_contextGL->numAllocatedRe
nderBuffer(); } | |
| 679 GLuint stencilAttachment() const { return m_contextGL->stencilAttachment();
} | |
| 680 GLuint depthAttachment() const { return m_contextGL->depthAttachment(); } | |
| 681 GLuint depthStencilAttachment() const { return m_contextGL->depthStencilAtta
chment(); } | |
| 682 | |
| 683 private: | |
| 684 DepthStencilTrackingGLES2Interface* m_contextGL; | |
| 685 }; | |
| 686 | |
| 687 struct DepthStencilTestCase { | 630 struct DepthStencilTestCase { |
| 688 DepthStencilTestCase(bool requestStencil, bool requestDepth, int expectedRen
derBuffers, const char* const testCaseName) | 631 DepthStencilTestCase(bool requestStencil, bool requestDepth, int expectedRen
derBuffers, const char* const testCaseName) |
| 689 : requestStencil(requestStencil) | 632 : requestStencil(requestStencil) |
| 690 , requestDepth(requestDepth) | 633 , requestDepth(requestDepth) |
| 691 , expectedRenderBuffers(expectedRenderBuffers) | 634 , expectedRenderBuffers(expectedRenderBuffers) |
| 692 , testCaseName(testCaseName) { } | 635 , testCaseName(testCaseName) { } |
| 693 | 636 |
| 694 bool requestStencil; | 637 bool requestStencil; |
| 695 bool requestDepth; | 638 bool requestDepth; |
| 696 size_t expectedRenderBuffers; | 639 size_t expectedRenderBuffers; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 708 DepthStencilTestCase(false, false, 0, "neither"), | 651 DepthStencilTestCase(false, false, 0, "neither"), |
| 709 DepthStencilTestCase(true, false, 1, "stencil only"), | 652 DepthStencilTestCase(true, false, 1, "stencil only"), |
| 710 DepthStencilTestCase(false, true, 1, "depth only"), | 653 DepthStencilTestCase(false, true, 1, "depth only"), |
| 711 DepthStencilTestCase(true, true, 1, "both"), | 654 DepthStencilTestCase(true, true, 1, "both"), |
| 712 }; | 655 }; |
| 713 | 656 |
| 714 for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); i++) { | 657 for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); i++) { |
| 715 SCOPED_TRACE(cases[i].testCaseName); | 658 SCOPED_TRACE(cases[i].testCaseName); |
| 716 OwnPtr<DepthStencilTrackingGLES2Interface> gl = adoptPtr(new DepthStenci
lTrackingGLES2Interface); | 659 OwnPtr<DepthStencilTrackingGLES2Interface> gl = adoptPtr(new DepthStenci
lTrackingGLES2Interface); |
| 717 DepthStencilTrackingGLES2Interface* trackingGL = gl.get(); | 660 DepthStencilTrackingGLES2Interface* trackingGL = gl.get(); |
| 718 OwnPtr<DepthStencilTrackingContext> context = adoptPtr(new DepthStencilT
rackingContext(trackingGL)); | 661 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web
GraphicsContext3DProviderForTests(gl.release())); |
| 719 DepthStencilTrackingContext* trackingContext = context.get(); | |
| 720 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web
GraphicsContext3DProviderForTests(context.release(), gl.release())); | |
| 721 DrawingBuffer::PreserveDrawingBuffer preserve = DrawingBuffer::Preserve; | 662 DrawingBuffer::PreserveDrawingBuffer preserve = DrawingBuffer::Preserve; |
| 722 | 663 |
| 723 bool premultipliedAlpha = false; | 664 bool premultipliedAlpha = false; |
| 724 bool wantAlphaChannel = true; | 665 bool wantAlphaChannel = true; |
| 725 bool wantDepthBuffer = cases[i].requestDepth; | 666 bool wantDepthBuffer = cases[i].requestDepth; |
| 726 bool wantStencilBuffer = cases[i].requestStencil; | 667 bool wantStencilBuffer = cases[i].requestStencil; |
| 727 bool wantAntialiasing = false; | 668 bool wantAntialiasing = false; |
| 728 RefPtr<DrawingBuffer> drawingBuffer = DrawingBuffer::create( | 669 RefPtr<DrawingBuffer> drawingBuffer = DrawingBuffer::create( |
| 729 provider.release(), | 670 provider.release(), |
| 730 IntSize(10, 10), | 671 IntSize(10, 10), |
| 731 premultipliedAlpha, | 672 premultipliedAlpha, |
| 732 wantAlphaChannel, | 673 wantAlphaChannel, |
| 733 wantDepthBuffer, | 674 wantDepthBuffer, |
| 734 wantStencilBuffer, | 675 wantStencilBuffer, |
| 735 wantAntialiasing, | 676 wantAntialiasing, |
| 736 preserve); | 677 preserve); |
| 737 | 678 |
| 738 // When we request a depth or a stencil buffer, we will get both. | 679 // When we request a depth or a stencil buffer, we will get both. |
| 739 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasDepthBuffer()); | 680 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasDepthBuffer()); |
| 740 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasStencilBuffer()); | 681 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasStencilBuffer()); |
| 741 EXPECT_EQ(cases[i].expectedRenderBuffers, trackingContext->numAllocatedR
enderBuffer()); | 682 EXPECT_EQ(cases[i].expectedRenderBuffers, trackingGL->numAllocatedRender
Buffer()); |
| 742 if (cases[i].requestDepth || cases[i].requestStencil) { | 683 if (cases[i].requestDepth || cases[i].requestStencil) { |
| 743 EXPECT_NE(0u, trackingContext->depthStencilAttachment()); | 684 EXPECT_NE(0u, trackingGL->depthStencilAttachment()); |
| 744 EXPECT_EQ(0u, trackingContext->depthAttachment()); | 685 EXPECT_EQ(0u, trackingGL->depthAttachment()); |
| 745 EXPECT_EQ(0u, trackingContext->stencilAttachment()); | 686 EXPECT_EQ(0u, trackingGL->stencilAttachment()); |
| 746 } else { | 687 } else { |
| 747 EXPECT_EQ(0u, trackingContext->depthStencilAttachment()); | 688 EXPECT_EQ(0u, trackingGL->depthStencilAttachment()); |
| 748 EXPECT_EQ(0u, trackingContext->depthAttachment()); | 689 EXPECT_EQ(0u, trackingGL->depthAttachment()); |
| 749 EXPECT_EQ(0u, trackingContext->stencilAttachment()); | 690 EXPECT_EQ(0u, trackingGL->stencilAttachment()); |
| 750 } | 691 } |
| 751 | 692 |
| 752 drawingBuffer->reset(IntSize(10, 20), false); | 693 drawingBuffer->reset(IntSize(10, 20), false); |
| 753 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasDepthBuffer()); | 694 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasDepthBuffer()); |
| 754 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasStencilBuffer()); | 695 EXPECT_EQ(cases[i].requestDepth || cases[i].requestStencil, drawingBuffe
r->hasStencilBuffer()); |
| 755 EXPECT_EQ(cases[i].expectedRenderBuffers, trackingContext->numAllocatedR
enderBuffer()); | 696 EXPECT_EQ(cases[i].expectedRenderBuffers, trackingGL->numAllocatedRender
Buffer()); |
| 756 if (cases[i].requestDepth || cases[i].requestStencil) { | 697 if (cases[i].requestDepth || cases[i].requestStencil) { |
| 757 EXPECT_NE(0u, trackingContext->depthStencilAttachment()); | 698 EXPECT_NE(0u, trackingGL->depthStencilAttachment()); |
| 758 EXPECT_EQ(0u, trackingContext->depthAttachment()); | 699 EXPECT_EQ(0u, trackingGL->depthAttachment()); |
| 759 EXPECT_EQ(0u, trackingContext->stencilAttachment()); | 700 EXPECT_EQ(0u, trackingGL->stencilAttachment()); |
| 760 } else { | 701 } else { |
| 761 EXPECT_EQ(0u, trackingContext->depthStencilAttachment()); | 702 EXPECT_EQ(0u, trackingGL->depthStencilAttachment()); |
| 762 EXPECT_EQ(0u, trackingContext->depthAttachment()); | 703 EXPECT_EQ(0u, trackingGL->depthAttachment()); |
| 763 EXPECT_EQ(0u, trackingContext->stencilAttachment()); | 704 EXPECT_EQ(0u, trackingGL->stencilAttachment()); |
| 764 } | 705 } |
| 765 | 706 |
| 766 drawingBuffer->beginDestruction(); | 707 drawingBuffer->beginDestruction(); |
| 767 } | 708 } |
| 768 } | 709 } |
| 769 | 710 |
| 770 TEST_F(DrawingBufferTest, verifySetIsHiddenProperlyAffectsMailboxes) | 711 TEST_F(DrawingBufferTest, verifySetIsHiddenProperlyAffectsMailboxes) |
| 771 { | 712 { |
| 772 blink::WebExternalTextureMailbox mailbox; | 713 blink::WebExternalTextureMailbox mailbox; |
| 773 | 714 |
| 774 // Produce mailboxes. | 715 // Produce mailboxes. |
| 775 m_drawingBuffer->markContentsChanged(); | 716 m_drawingBuffer->markContentsChanged(); |
| 776 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 717 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 777 | 718 |
| 778 m_gl->GenSyncTokenCHROMIUM(m_gl->InsertFenceSyncCHROMIUM(), mailbox.syncToke
n); | 719 m_gl->GenSyncTokenCHROMIUM(m_gl->InsertFenceSyncCHROMIUM(), mailbox.syncToke
n); |
| 779 mailbox.validSyncToken = true; | 720 mailbox.validSyncToken = true; |
| 780 m_drawingBuffer->setIsHidden(true); | 721 m_drawingBuffer->setIsHidden(true); |
| 781 m_drawingBuffer->mailboxReleased(mailbox); | 722 m_drawingBuffer->mailboxReleased(mailbox); |
| 782 // m_drawingBuffer deletes mailbox immediately when hidden. | 723 // m_drawingBuffer deletes mailbox immediately when hidden. |
| 783 | 724 |
| 784 GLuint waitSyncToken = 0; | 725 GLuint waitSyncToken = 0; |
| 785 memcpy(&waitSyncToken, mailbox.syncToken, sizeof(waitSyncToken)); | 726 memcpy(&waitSyncToken, mailbox.syncToken, sizeof(waitSyncToken)); |
| 786 EXPECT_EQ(waitSyncToken, webContext()->mostRecentlyWaitedSyncToken()); | 727 EXPECT_EQ(waitSyncToken, m_gl->mostRecentlyWaitedSyncToken()); |
| 787 | 728 |
| 788 m_drawingBuffer->beginDestruction(); | 729 m_drawingBuffer->beginDestruction(); |
| 789 } | 730 } |
| 790 | 731 |
| 791 class DrawingBufferImageChromiumFallbackTest : public DrawingBufferTest { | 732 class DrawingBufferImageChromiumFallbackTest : public DrawingBufferTest { |
| 792 protected: | 733 protected: |
| 793 void SetUp() override | 734 void SetUp() override |
| 794 { | 735 { |
| 795 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests)
; | 736 OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests)
; |
| 796 gl->setAllowImageChromium(false); | 737 gl->setAllowImageChromium(false); |
| 797 m_gl = gl.get(); | 738 m_gl = gl.get(); |
| 798 OwnPtr<WebGraphicsContext3DForTests> context = adoptPtr(new WebGraphicsC
ontext3DForTests(m_gl)); | 739 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web
GraphicsContext3DProviderForTests(gl.release())); |
| 799 m_context = context.get(); | |
| 800 OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new Web
GraphicsContext3DProviderForTests(context.release(), gl.release())); | |
| 801 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true); | 740 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true); |
| 802 m_drawingBuffer = DrawingBufferForTests::create(provider.release(), | 741 m_drawingBuffer = DrawingBufferForTests::create(provider.release(), |
| 803 IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve); | 742 IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve); |
| 804 } | 743 } |
| 805 | 744 |
| 806 void TearDown() override | 745 void TearDown() override |
| 807 { | 746 { |
| 808 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(false); | 747 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(false); |
| 809 } | 748 } |
| 810 }; | 749 }; |
| 811 | 750 |
| 812 TEST_F(DrawingBufferImageChromiumFallbackTest, verifyImageChromiumFallback) | 751 TEST_F(DrawingBufferImageChromiumFallbackTest, verifyImageChromiumFallback) |
| 813 { | 752 { |
| 814 WebExternalTextureMailbox mailbox; | 753 WebExternalTextureMailbox mailbox; |
| 815 | 754 |
| 816 IntSize initialSize(initialWidth, initialHeight); | 755 IntSize initialSize(initialWidth, initialHeight); |
| 817 m_drawingBuffer->markContentsChanged(); | 756 m_drawingBuffer->markContentsChanged(); |
| 818 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 757 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 819 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); | 758 EXPECT_EQ(initialSize, m_gl->mostRecentlyProducedSize()); |
| 820 EXPECT_FALSE(mailbox.allowOverlay); | 759 EXPECT_FALSE(mailbox.allowOverlay); |
| 821 | 760 |
| 822 m_drawingBuffer->mailboxReleased(mailbox, false); | 761 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 823 m_drawingBuffer->beginDestruction(); | 762 m_drawingBuffer->beginDestruction(); |
| 824 } | 763 } |
| 825 | 764 |
| 826 } // namespace blink | 765 } // namespace blink |
| OLD | NEW |