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

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

Issue 1933723002: cc: Unittest for checking already failed image decode task. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@land_task_manager
Patch Set: Created 4 years, 7 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 ProcessTask(third_task->dependencies()[0].get()); 351 ProcessTask(third_task->dependencies()[0].get());
352 ProcessTask(third_task.get()); 352 ProcessTask(third_task.get());
353 353
354 // 3 Unrefs! 354 // 3 Unrefs!
355 controller.UnrefImage(draw_image); 355 controller.UnrefImage(draw_image);
356 controller.UnrefImage(draw_image); 356 controller.UnrefImage(draw_image);
357 controller.UnrefImage(draw_image); 357 controller.UnrefImage(draw_image);
358 } 358 }
359 359
360 TEST(GpuImageDecodeControllerTest, NoTaskForImageAlreadyFailedDecoding) {
361 auto context_provider = TestContextProvider::Create();
362 context_provider->BindToCurrentThread();
363 GpuImageDecodeController controller(context_provider.get(),
364 ResourceFormat::RGBA_8888);
365 bool is_decomposable = true;
366 SkFilterQuality quality = kHigh_SkFilterQuality;
367
368 sk_sp<SkImage> image = CreateImage(100, 100);
369 DrawImage draw_image(image, SkIRect::MakeWH(image->width(), image->height()),
370 quality,
371 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
372 scoped_refptr<TileTask> task;
373 bool need_unref = controller.GetTaskForImageAndRef(
374 draw_image, ImageDecodeController::TracingInfo(), &task);
375 EXPECT_TRUE(need_unref);
376 EXPECT_TRUE(task);
377
378 ProcessTask(task->dependencies()[0].get());
379 ScheduleTask(task.get());
380 // Didn't run the task, complete it (it was canceled).
381 CompleteTask(task.get());
382
383 controller.SetImageDecodingFailedForTesting(draw_image);
384
385 scoped_refptr<TileTask> another_task;
386 need_unref = controller.GetTaskForImageAndRef(
387 draw_image, ImageDecodeController::TracingInfo(), &another_task);
388 EXPECT_FALSE(need_unref);
389 EXPECT_EQ(another_task.get(), nullptr);
390
391 controller.UnrefImage(draw_image);
392 }
393
360 TEST(GpuImageDecodeControllerTest, GetDecodedImageForDraw) { 394 TEST(GpuImageDecodeControllerTest, GetDecodedImageForDraw) {
361 auto context_provider = TestContextProvider::Create(); 395 auto context_provider = TestContextProvider::Create();
362 context_provider->BindToCurrentThread(); 396 context_provider->BindToCurrentThread();
363 GpuImageDecodeController controller(context_provider.get(), 397 GpuImageDecodeController controller(context_provider.get(),
364 ResourceFormat::RGBA_8888); 398 ResourceFormat::RGBA_8888);
365 bool is_decomposable = true; 399 bool is_decomposable = true;
366 SkFilterQuality quality = kHigh_SkFilterQuality; 400 SkFilterQuality quality = kHigh_SkFilterQuality;
367 401
368 sk_sp<SkImage> image = CreateImage(100, 100); 402 sk_sp<SkImage> image = CreateImage(100, 100);
369 DrawImage draw_image(image, SkIRect::MakeWH(image->width(), image->height()), 403 DrawImage draw_image(image, SkIRect::MakeWH(image->width(), image->height()),
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 ProcessTask(task->dependencies()[0].get()); 714 ProcessTask(task->dependencies()[0].get());
681 ProcessTask(task.get()); 715 ProcessTask(task.get());
682 716
683 // The image should be in our cache after un-ref. 717 // The image should be in our cache after un-ref.
684 controller.UnrefImage(draw_image); 718 controller.UnrefImage(draw_image);
685 DCHECK_GT(controller.GetBytesUsedForTesting(), 0u); 719 DCHECK_GT(controller.GetBytesUsedForTesting(), 0u);
686 } 720 }
687 721
688 } // namespace 722 } // namespace
689 } // namespace cc 723 } // 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