Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: cc/layers/texture_layer_impl_unittest.cc

Issue 2596593003: Fix use-after-free in TextureLayerImplTest.ResourceNotFreedOnGpuRasterToggle. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_impl.h" 5 #include "cc/layers/texture_layer_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/output/compositor_frame_sink.h" 9 #include "cc/output/compositor_frame_sink.h"
10 #include "cc/output/context_provider.h" 10 #include "cc/output/context_provider.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 impl.quad_list().front()->material); 143 impl.quad_list().front()->material);
144 const TextureDrawQuad* quad = 144 const TextureDrawQuad* quad =
145 TextureDrawQuad::MaterialCast(impl.quad_list().front()); 145 TextureDrawQuad::MaterialCast(impl.quad_list().front());
146 EXPECT_TRUE(quad->secure_output_only); 146 EXPECT_TRUE(quad->secure_output_only);
147 } 147 }
148 } 148 }
149 149
150 TEST(TextureLayerImplTest, ResourceNotFreedOnGpuRasterToggle) { 150 TEST(TextureLayerImplTest, ResourceNotFreedOnGpuRasterToggle) {
151 LayerTreeSettings settings; 151 LayerTreeSettings settings;
152 settings.gpu_rasterization_enabled = true; 152 settings.gpu_rasterization_enabled = true;
153 bool released = false;
153 LayerTestCommon::LayerImplTest impl(settings); 154 LayerTestCommon::LayerImplTest impl(settings);
154 impl.host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 155 impl.host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
155 156
156 gfx::Size layer_size(1000, 1000); 157 gfx::Size layer_size(1000, 1000);
157 gfx::Size viewport_size(1000, 1000); 158 gfx::Size viewport_size(1000, 1000);
158 159
159 gpu::Mailbox mailbox; 160 gpu::Mailbox mailbox;
160 impl.compositor_frame_sink() 161 impl.compositor_frame_sink()
161 ->context_provider() 162 ->context_provider()
162 ->ContextGL() 163 ->ContextGL()
163 ->GenMailboxCHROMIUM(mailbox.name); 164 ->GenMailboxCHROMIUM(mailbox.name);
164 TextureMailbox texture_mailbox( 165 TextureMailbox texture_mailbox(
165 mailbox, 166 mailbox,
166 gpu::SyncToken(gpu::CommandBufferNamespace::GPU_IO, 0x123, 167 gpu::SyncToken(gpu::CommandBufferNamespace::GPU_IO, 0x123,
167 gpu::CommandBufferId::FromUnsafeValue(0x234), 0x456), 168 gpu::CommandBufferId::FromUnsafeValue(0x234), 0x456),
168 GL_TEXTURE_2D); 169 GL_TEXTURE_2D);
169 170
170 TextureLayerImpl* texture_layer_impl = 171 TextureLayerImpl* texture_layer_impl =
171 impl.AddChildToRoot<TextureLayerImpl>(); 172 impl.AddChildToRoot<TextureLayerImpl>();
172 texture_layer_impl->SetBounds(layer_size); 173 texture_layer_impl->SetBounds(layer_size);
173 texture_layer_impl->SetDrawsContent(true); 174 texture_layer_impl->SetDrawsContent(true);
174 bool released = false;
175 texture_layer_impl->SetTextureMailbox( 175 texture_layer_impl->SetTextureMailbox(
176 texture_mailbox, 176 texture_mailbox,
177 SingleReleaseCallbackImpl::Create(base::Bind( 177 SingleReleaseCallbackImpl::Create(base::Bind(
178 [](bool* released, const gpu::SyncToken& sync_token, bool lost, 178 [](bool* released, const gpu::SyncToken& sync_token, bool lost,
179 BlockingTaskRunner* main_thread_task_runner) { *released = true; }, 179 BlockingTaskRunner* main_thread_task_runner) { *released = true; },
180 base::Unretained(&released)))); 180 base::Unretained(&released))));
181 181
182 impl.CalcDrawProps(viewport_size); 182 impl.CalcDrawProps(viewport_size);
183 183
184 // Gpu rasterization is disabled by default. 184 // Gpu rasterization is disabled by default.
185 EXPECT_FALSE(impl.host_impl()->use_gpu_rasterization()); 185 EXPECT_FALSE(impl.host_impl()->use_gpu_rasterization());
186 EXPECT_FALSE(released); 186 EXPECT_FALSE(released);
187 // Toggling the gpu rasterization clears all tilings on both trees. 187 // Toggling the gpu rasterization clears all tilings on both trees.
188 impl.host_impl()->SetHasGpuRasterizationTrigger(true); 188 impl.host_impl()->SetHasGpuRasterizationTrigger(true);
189 impl.host_impl()->SetContentIsSuitableForGpuRasterization(true); 189 impl.host_impl()->SetContentIsSuitableForGpuRasterization(true);
190 impl.host_impl()->CommitComplete(); 190 impl.host_impl()->CommitComplete();
191 EXPECT_TRUE(impl.host_impl()->use_gpu_rasterization()); 191 EXPECT_TRUE(impl.host_impl()->use_gpu_rasterization());
192 EXPECT_FALSE(released); 192 EXPECT_FALSE(released);
193 } 193 }
194 194
195 } // namespace 195 } // namespace
196 } // namespace cc 196 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698