| 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/layers/texture_layer.h" | 5 #include "cc/layers/texture_layer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "cc/layers/texture_layer_client.h" | 10 #include "cc/layers/texture_layer_client.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); | 198 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); |
| 199 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); | 199 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); |
| 200 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTextureId(1)); | 200 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTextureId(1)); |
| 201 | 201 |
| 202 // Calling SetTextureId can call AcquireLayerTextures. | 202 // Calling SetTextureId can call AcquireLayerTextures. |
| 203 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AnyNumber()); | 203 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AnyNumber()); |
| 204 } | 204 } |
| 205 | 205 |
| 206 class FakeTextureLayerClient : public TextureLayerClient { | 206 class FakeTextureLayerClient : public TextureLayerClient { |
| 207 public: | 207 public: |
| 208 FakeTextureLayerClient() : context_(TestWebGraphicsContext3D::Create()) {} | 208 FakeTextureLayerClient() |
| 209 : context_(TestWebGraphicsContext3D::CreateShared()) {} |
| 209 | 210 |
| 210 virtual unsigned PrepareTexture() OVERRIDE { | 211 virtual unsigned PrepareTexture() OVERRIDE { |
| 211 return 0; | 212 return 0; |
| 212 } | 213 } |
| 213 | 214 |
| 214 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 215 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
| 215 return context_.get(); | 216 return context_.get(); |
| 216 } | 217 } |
| 217 | 218 |
| 218 virtual bool PrepareTextureMailbox(TextureMailbox* mailbox, | 219 virtual bool PrepareTextureMailbox(TextureMailbox* mailbox, |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 public: | 761 public: |
| 761 TextureLayerClientTest() | 762 TextureLayerClientTest() |
| 762 : context_(NULL), | 763 : context_(NULL), |
| 763 texture_(0), | 764 texture_(0), |
| 764 commit_count_(0), | 765 commit_count_(0), |
| 765 expected_used_textures_on_draw_(0), | 766 expected_used_textures_on_draw_(0), |
| 766 expected_used_textures_on_commit_(0) {} | 767 expected_used_textures_on_commit_(0) {} |
| 767 | 768 |
| 768 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { | 769 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { |
| 769 scoped_ptr<TestWebGraphicsContext3D> context( | 770 scoped_ptr<TestWebGraphicsContext3D> context( |
| 770 TestWebGraphicsContext3D::Create()); | 771 TestWebGraphicsContext3D::CreateShared()); |
| 771 context_ = context.get(); | 772 context_ = context.get(); |
| 772 texture_ = context->createTexture(); | 773 texture_ = context->createTexture(); |
| 773 return FakeOutputSurface::Create3d( | 774 return FakeOutputSurface::Create3d( |
| 774 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); | 775 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); |
| 775 } | 776 } |
| 776 | 777 |
| 777 virtual unsigned PrepareTexture() OVERRIDE { | 778 virtual unsigned PrepareTexture() OVERRIDE { |
| 778 return texture_; | 779 return texture_; |
| 779 } | 780 } |
| 780 | 781 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 // Test recovering from a lost context. | 874 // Test recovering from a lost context. |
| 874 class TextureLayerLostContextTest | 875 class TextureLayerLostContextTest |
| 875 : public LayerTreeTest, | 876 : public LayerTreeTest, |
| 876 public TextureLayerClient { | 877 public TextureLayerClient { |
| 877 public: | 878 public: |
| 878 TextureLayerLostContextTest() | 879 TextureLayerLostContextTest() |
| 879 : texture_(0), | 880 : texture_(0), |
| 880 draw_count_(0) {} | 881 draw_count_(0) {} |
| 881 | 882 |
| 882 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { | 883 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { |
| 883 texture_context_ = TestWebGraphicsContext3D::Create(); | 884 texture_context_ = TestWebGraphicsContext3D::CreateShared(); |
| 884 texture_ = texture_context_->createTexture(); | 885 texture_ = texture_context_->createTexture(); |
| 885 scoped_ptr<TestWebGraphicsContext3D> context( | 886 return CreateFakeOutputSurface(); |
| 886 TestWebGraphicsContext3D::Create()); | |
| 887 return FakeOutputSurface::Create3d( | |
| 888 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); | |
| 889 } | 887 } |
| 890 | 888 |
| 891 virtual unsigned PrepareTexture() OVERRIDE { | 889 virtual unsigned PrepareTexture() OVERRIDE { |
| 892 if (draw_count_ == 0) { | 890 if (draw_count_ == 0) { |
| 893 texture_context_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 891 texture_context_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 894 GL_INNOCENT_CONTEXT_RESET_ARB); | 892 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 895 } | 893 } |
| 896 return texture_; | 894 return texture_; |
| 897 } | 895 } |
| 898 | 896 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 scoped_refptr<TextureLayer> texture_layer_; | 944 scoped_refptr<TextureLayer> texture_layer_; |
| 947 scoped_ptr<TestWebGraphicsContext3D> texture_context_; | 945 scoped_ptr<TestWebGraphicsContext3D> texture_context_; |
| 948 unsigned texture_; | 946 unsigned texture_; |
| 949 int draw_count_; | 947 int draw_count_; |
| 950 }; | 948 }; |
| 951 | 949 |
| 952 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerLostContextTest); | 950 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerLostContextTest); |
| 953 | 951 |
| 954 } // namespace | 952 } // namespace |
| 955 } // namespace cc | 953 } // namespace cc |
| OLD | NEW |