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

Side by Side Diff: cc/tiles/gpu_image_decode_controller_unittest.cc

Issue 1910663002: Fix ImageUploadTaskImpl with null dependencies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@skskp
Patch Set: sk_sp rebase Created 4 years, 8 months 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 | « cc/tiles/gpu_image_decode_controller.cc ('k') | 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/tiles/gpu_image_decode_controller.h" 5 #include "cc/tiles/gpu_image_decode_controller.h"
6 6
7 #include "cc/playback/draw_image.h" 7 #include "cc/playback/draw_image.h"
8 #include "cc/raster/tile_task.h" 8 #include "cc/raster/tile_task.h"
9 #include "cc/test/test_context_provider.h" 9 #include "cc/test/test_context_provider.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 ProcessTask(first_task->dependencies()[0].get()); 124 ProcessTask(first_task->dependencies()[0].get());
125 ProcessTask(first_task.get()); 125 ProcessTask(first_task.get());
126 ProcessTask(second_task->dependencies()[0].get()); 126 ProcessTask(second_task->dependencies()[0].get());
127 ProcessTask(second_task.get()); 127 ProcessTask(second_task.get());
128 128
129 controller.UnrefImage(first_draw_image); 129 controller.UnrefImage(first_draw_image);
130 controller.UnrefImage(second_draw_image); 130 controller.UnrefImage(second_draw_image);
131 } 131 }
132 132
133 TEST(GpuImageDecodeControllerTest, GetTaskForImageAlreadyDecoded) { 133 TEST(GpuImageDecodeControllerTest, GetTaskForImageAlreadyDecodedAndLocked) {
134 auto context_provider = TestContextProvider::Create(); 134 auto context_provider = TestContextProvider::Create();
135 context_provider->BindToCurrentThread(); 135 context_provider->BindToCurrentThread();
136 GpuImageDecodeController controller(context_provider.get(), 136 GpuImageDecodeController controller(context_provider.get(),
137 ResourceFormat::RGBA_8888);
138 bool is_decomposable = true;
139 uint64_t prepare_tiles_id = 1;
140 SkFilterQuality quality = kHigh_SkFilterQuality;
141
142 sk_sp<SkImage> image = CreateImage(100, 100);
143 DrawImage draw_image(image, SkIRect::MakeWH(image->width(), image->height()),
144 quality,
145 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
146 scoped_refptr<TileTask> task;
147 bool need_unref =
148 controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
149 EXPECT_TRUE(need_unref);
150 EXPECT_TRUE(task);
151 EXPECT_EQ(task->dependencies().size(), 1u);
152 EXPECT_TRUE(task->dependencies()[0]);
153
154 // Run the decode but don't complete it (this will keep the decode locked).
155 ScheduleTask(task->dependencies()[0].get());
156 RunTask(task->dependencies()[0].get());
157
158 // Cancel the upload.
159 ScheduleTask(task.get());
160 CompleteTask(task.get());
161
162 // Get the image again - we should have an upload task, but no dependent
163 // decode task, as the decode was already locked.
164 scoped_refptr<TileTask> another_task;
165 need_unref = controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id,
166 &another_task);
167 EXPECT_TRUE(need_unref);
168 EXPECT_TRUE(another_task);
169 EXPECT_EQ(another_task->dependencies().size(), 0u);
170
171 ProcessTask(another_task.get());
172
173 // Finally, complete the original decode task.
174 CompleteTask(task->dependencies()[0].get());
175
176 controller.UnrefImage(draw_image);
177 controller.UnrefImage(draw_image);
178 }
179
180 TEST(GpuImageDecodeControllerTest, GetTaskForImageAlreadyDecodedNotLocked) {
181 auto context_provider = TestContextProvider::Create();
182 context_provider->BindToCurrentThread();
183 GpuImageDecodeController controller(context_provider.get(),
184 ResourceFormat::RGBA_8888);
185 bool is_decomposable = true;
186 uint64_t prepare_tiles_id = 1;
187 SkFilterQuality quality = kHigh_SkFilterQuality;
188
189 sk_sp<SkImage> image = CreateImage(100, 100);
190 DrawImage draw_image(image, SkIRect::MakeWH(image->width(), image->height()),
191 quality,
192 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
193 scoped_refptr<TileTask> task;
194 bool need_unref =
195 controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
196 EXPECT_TRUE(need_unref);
197 EXPECT_TRUE(task);
198 EXPECT_EQ(task->dependencies().size(), 1u);
199 EXPECT_TRUE(task->dependencies()[0]);
200
201 // Run the decode.
202 ProcessTask(task->dependencies()[0].get());
203
204 // Cancel the upload.
205 ScheduleTask(task.get());
206 CompleteTask(task.get());
207
208 // Unref the image.
209 controller.UnrefImage(draw_image);
210
211 // Get the image again - we should have an upload task and a dependent decode
212 // task - this dependent task will typically just re-lock the image.
213 scoped_refptr<TileTask> another_task;
214 need_unref = controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id,
215 &another_task);
216 EXPECT_TRUE(need_unref);
217 EXPECT_TRUE(another_task);
218 EXPECT_EQ(another_task->dependencies().size(), 1u);
219 EXPECT_TRUE(task->dependencies()[0]);
220
221 ProcessTask(another_task->dependencies()[0].get());
222 ProcessTask(another_task.get());
223
224 controller.UnrefImage(draw_image);
225 }
226
227 TEST(GpuImageDecodeControllerTest, GetTaskForImageAlreadyUploaded) {
228 auto context_provider = TestContextProvider::Create();
229 context_provider->BindToCurrentThread();
230 GpuImageDecodeController controller(context_provider.get(),
137 ResourceFormat::RGBA_8888); 231 ResourceFormat::RGBA_8888);
138 bool is_decomposable = true; 232 bool is_decomposable = true;
139 uint64_t prepare_tiles_id = 1; 233 uint64_t prepare_tiles_id = 1;
140 SkFilterQuality quality = kHigh_SkFilterQuality; 234 SkFilterQuality quality = kHigh_SkFilterQuality;
141 235
142 sk_sp<SkImage> image = CreateImage(100, 100); 236 sk_sp<SkImage> image = CreateImage(100, 100);
143 DrawImage draw_image(image, SkIRect::MakeWH(image->width(), image->height()), 237 DrawImage draw_image(image, SkIRect::MakeWH(image->width(), image->height()),
144 quality, 238 quality,
145 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable)); 239 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
146 scoped_refptr<TileTask> task; 240 scoped_refptr<TileTask> task;
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 ProcessTask(task->dependencies()[0].get()); 691 ProcessTask(task->dependencies()[0].get());
598 ProcessTask(task.get()); 692 ProcessTask(task.get());
599 693
600 // The image should be in our cache after un-ref. 694 // The image should be in our cache after un-ref.
601 controller.UnrefImage(draw_image); 695 controller.UnrefImage(draw_image);
602 DCHECK_GT(controller.GetBytesUsedForTesting(), 0u); 696 DCHECK_GT(controller.GetBytesUsedForTesting(), 0u);
603 } 697 }
604 698
605 } // namespace 699 } // namespace
606 } // namespace cc 700 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/gpu_image_decode_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698