| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/throttled_texture_uploader.h" | 7 #include "cc/throttled_texture_uploader.h" |
| 8 | 8 |
| 9 #include "CCPrioritizedTexture.h" | 9 #include "CCPrioritizedTexture.h" |
| 10 #include "Extensions3DChromium.h" | 10 #include "Extensions3DChromium.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 unsigned m_resultAvailable; | 42 unsigned m_resultAvailable; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 | 45 |
| 46 TEST(ThrottledTextureUploaderTest, NumBlockingUploads) | 46 TEST(ThrottledTextureUploaderTest, NumBlockingUploads) |
| 47 { | 47 { |
| 48 scoped_ptr<FakeWebGraphicsContext3DWithQueryTesting> fakeContext(new FakeWeb
GraphicsContext3DWithQueryTesting); | 48 scoped_ptr<FakeWebGraphicsContext3DWithQueryTesting> fakeContext(new FakeWeb
GraphicsContext3DWithQueryTesting); |
| 49 scoped_ptr<ThrottledTextureUploader> uploader = ThrottledTextureUploader::cr
eate(fakeContext.get()); | 49 scoped_ptr<ThrottledTextureUploader> uploader = ThrottledTextureUploader::cr
eate(fakeContext.get()); |
| 50 scoped_ptr<CCPrioritizedTexture> texture = | 50 scoped_ptr<PrioritizedTexture> texture = |
| 51 CCPrioritizedTexture::create(NULL, IntSize(256, 256), GL_RGBA); | 51 PrioritizedTexture::create(NULL, IntSize(256, 256), GL_RGBA); |
| 52 TextureUploader::Parameters upload; | 52 TextureUploader::Parameters upload; |
| 53 upload.texture = texture.get(); | 53 upload.texture = texture.get(); |
| 54 upload.bitmap = NULL; | 54 upload.bitmap = NULL; |
| 55 upload.picture = NULL; | 55 upload.picture = NULL; |
| 56 upload.geometry.contentRect = IntRect(IntPoint(0,0), texture->size()); | 56 upload.geometry.contentRect = IntRect(IntPoint(0,0), texture->size()); |
| 57 upload.geometry.sourceRect = IntRect(IntPoint(0,0), texture->size()); | 57 upload.geometry.sourceRect = IntRect(IntPoint(0,0), texture->size()); |
| 58 upload.geometry.destOffset = IntSize(); | 58 upload.geometry.destOffset = IntSize(); |
| 59 | 59 |
| 60 fakeContext->setResultAvailable(0); | 60 fakeContext->setResultAvailable(0); |
| 61 EXPECT_EQ(0, uploader->numBlockingUploads()); | 61 EXPECT_EQ(0, uploader->numBlockingUploads()); |
| 62 uploader->uploadTexture(NULL, upload); | 62 uploader->uploadTexture(NULL, upload); |
| 63 EXPECT_EQ(1, uploader->numBlockingUploads()); | 63 EXPECT_EQ(1, uploader->numBlockingUploads()); |
| 64 uploader->uploadTexture(NULL, upload); | 64 uploader->uploadTexture(NULL, upload); |
| 65 EXPECT_EQ(2, uploader->numBlockingUploads()); | 65 EXPECT_EQ(2, uploader->numBlockingUploads()); |
| 66 | 66 |
| 67 fakeContext->setResultAvailable(1); | 67 fakeContext->setResultAvailable(1); |
| 68 EXPECT_EQ(0, uploader->numBlockingUploads()); | 68 EXPECT_EQ(0, uploader->numBlockingUploads()); |
| 69 uploader->uploadTexture(NULL, upload); | 69 uploader->uploadTexture(NULL, upload); |
| 70 EXPECT_EQ(0, uploader->numBlockingUploads()); | 70 EXPECT_EQ(0, uploader->numBlockingUploads()); |
| 71 uploader->uploadTexture(NULL, upload); | 71 uploader->uploadTexture(NULL, upload); |
| 72 uploader->uploadTexture(NULL, upload); | 72 uploader->uploadTexture(NULL, upload); |
| 73 EXPECT_EQ(0, uploader->numBlockingUploads()); | 73 EXPECT_EQ(0, uploader->numBlockingUploads()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 TEST(ThrottledTextureUploaderTest, MarkPendingUploadsAsNonBlocking) | 76 TEST(ThrottledTextureUploaderTest, MarkPendingUploadsAsNonBlocking) |
| 77 { | 77 { |
| 78 scoped_ptr<FakeWebGraphicsContext3DWithQueryTesting> fakeContext(new FakeWeb
GraphicsContext3DWithQueryTesting); | 78 scoped_ptr<FakeWebGraphicsContext3DWithQueryTesting> fakeContext(new FakeWeb
GraphicsContext3DWithQueryTesting); |
| 79 scoped_ptr<ThrottledTextureUploader> uploader = ThrottledTextureUploader::cr
eate(fakeContext.get()); | 79 scoped_ptr<ThrottledTextureUploader> uploader = ThrottledTextureUploader::cr
eate(fakeContext.get()); |
| 80 scoped_ptr<CCPrioritizedTexture> texture = | 80 scoped_ptr<PrioritizedTexture> texture = |
| 81 CCPrioritizedTexture::create(NULL, IntSize(256, 256), GL_RGBA); | 81 PrioritizedTexture::create(NULL, IntSize(256, 256), GL_RGBA); |
| 82 TextureUploader::Parameters upload; | 82 TextureUploader::Parameters upload; |
| 83 upload.texture = texture.get(); | 83 upload.texture = texture.get(); |
| 84 upload.bitmap = NULL; | 84 upload.bitmap = NULL; |
| 85 upload.picture = NULL; | 85 upload.picture = NULL; |
| 86 upload.geometry.contentRect = IntRect(IntPoint(0,0), texture->size()); | 86 upload.geometry.contentRect = IntRect(IntPoint(0,0), texture->size()); |
| 87 upload.geometry.sourceRect = IntRect(IntPoint(0,0), texture->size()); | 87 upload.geometry.sourceRect = IntRect(IntPoint(0,0), texture->size()); |
| 88 upload.geometry.destOffset = IntSize(); | 88 upload.geometry.destOffset = IntSize(); |
| 89 | 89 |
| 90 fakeContext->setResultAvailable(0); | 90 fakeContext->setResultAvailable(0); |
| 91 EXPECT_EQ(0, uploader->numBlockingUploads()); | 91 EXPECT_EQ(0, uploader->numBlockingUploads()); |
| 92 uploader->uploadTexture(NULL, upload); | 92 uploader->uploadTexture(NULL, upload); |
| 93 uploader->uploadTexture(NULL, upload); | 93 uploader->uploadTexture(NULL, upload); |
| 94 EXPECT_EQ(2, uploader->numBlockingUploads()); | 94 EXPECT_EQ(2, uploader->numBlockingUploads()); |
| 95 | 95 |
| 96 uploader->markPendingUploadsAsNonBlocking(); | 96 uploader->markPendingUploadsAsNonBlocking(); |
| 97 EXPECT_EQ(0, uploader->numBlockingUploads()); | 97 EXPECT_EQ(0, uploader->numBlockingUploads()); |
| 98 uploader->uploadTexture(NULL, upload); | 98 uploader->uploadTexture(NULL, upload); |
| 99 EXPECT_EQ(1, uploader->numBlockingUploads()); | 99 EXPECT_EQ(1, uploader->numBlockingUploads()); |
| 100 | 100 |
| 101 fakeContext->setResultAvailable(1); | 101 fakeContext->setResultAvailable(1); |
| 102 EXPECT_EQ(0, uploader->numBlockingUploads()); | 102 EXPECT_EQ(0, uploader->numBlockingUploads()); |
| 103 uploader->uploadTexture(NULL, upload); | 103 uploader->uploadTexture(NULL, upload); |
| 104 uploader->markPendingUploadsAsNonBlocking(); | 104 uploader->markPendingUploadsAsNonBlocking(); |
| 105 EXPECT_EQ(0, uploader->numBlockingUploads()); | 105 EXPECT_EQ(0, uploader->numBlockingUploads()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace | 108 } // namespace |
| OLD | NEW |