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

Unified Diff: cc/tiles/gpu_image_decode_controller_unittest.cc

Issue 1890903002: cc: Simplify Task and its derived classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_tile_task_runner
Patch Set: nits 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 side-by-side diff with in-line comments
Download patch
Index: cc/tiles/gpu_image_decode_controller_unittest.cc
diff --git a/cc/tiles/gpu_image_decode_controller_unittest.cc b/cc/tiles/gpu_image_decode_controller_unittest.cc
index 525110ead587b69126a6832f12885b4c7cf3a27d..8523aaa0d576ccf4e75cc220303711f3b1fea2cc 100644
--- a/cc/tiles/gpu_image_decode_controller_unittest.cc
+++ b/cc/tiles/gpu_image_decode_controller_unittest.cc
@@ -5,7 +5,7 @@
#include "cc/tiles/gpu_image_decode_controller.h"
#include "cc/playback/draw_image.h"
-#include "cc/raster/tile_task_runner.h"
+#include "cc/raster/task.h"
#include "cc/test/test_context_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -31,22 +31,22 @@ SkMatrix CreateMatrix(const SkSize& scale, bool is_decomposable) {
return matrix;
}
-void RunTask(ImageDecodeTask* task) {
+void RunTask(Task* task) {
task->WillRun();
task->RunOnWorkerThread();
task->DidRun();
}
-void CompleteTask(GpuImageDecodeController* controller, ImageDecodeTask* task) {
- if (task->GetTaskTypeId() == TASK_TYPE_IMAGE_DECODE)
+void CompleteTask(GpuImageDecodeController* controller, Task* task) {
+ if (task->GetTaskType() == TASK_TYPE_IMAGE_DECODE)
controller->ImageDecodeTaskCompleted(task);
- else if (task->GetTaskTypeId() == TASK_TYPE_IMAGE_UPLOAD)
+ else if (task->GetTaskType() == TASK_TYPE_IMAGE_UPLOAD)
controller->ImageUploadTaskCompleted(task);
task->DidComplete();
}
-void ProcessTask(GpuImageDecodeController* controller, ImageDecodeTask* task) {
+void ProcessTask(GpuImageDecodeController* controller, Task* task) {
RunTask(task);
CompleteTask(controller, task);
}
@@ -64,7 +64,7 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageSameImage) {
DrawImage draw_image(
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_TRUE(need_unref);
@@ -73,13 +73,13 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageSameImage) {
DrawImage another_draw_image(
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(1.5f, 1.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> another_task;
+ scoped_refptr<Task> another_task;
need_unref = controller.GetTaskForImageAndRef(
another_draw_image, prepare_tiles_id, &another_task);
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task.get() == another_task.get());
- ProcessTask(&controller, task->dependency().get());
+ ProcessTask(&controller, task->dependencies()[0].get());
ProcessTask(&controller, task.get());
controller.UnrefImage(draw_image);
@@ -100,7 +100,7 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageDifferentImage) {
first_image.get(),
SkIRect::MakeWH(first_image->width(), first_image->height()), quality,
CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> first_task;
+ scoped_refptr<Task> first_task;
bool need_unref = controller.GetTaskForImageAndRef(
first_draw_image, prepare_tiles_id, &first_task);
EXPECT_TRUE(need_unref);
@@ -111,16 +111,16 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageDifferentImage) {
second_image.get(),
SkIRect::MakeWH(second_image->width(), second_image->height()), quality,
CreateMatrix(SkSize::Make(0.25f, 0.25f), is_decomposable));
- scoped_refptr<ImageDecodeTask> second_task;
+ scoped_refptr<Task> second_task;
need_unref = controller.GetTaskForImageAndRef(second_draw_image,
prepare_tiles_id, &second_task);
EXPECT_TRUE(need_unref);
EXPECT_TRUE(second_task);
EXPECT_TRUE(first_task.get() != second_task.get());
- ProcessTask(&controller, first_task->dependency().get());
+ ProcessTask(&controller, first_task->dependencies()[0].get());
ProcessTask(&controller, first_task.get());
- ProcessTask(&controller, second_task->dependency().get());
+ ProcessTask(&controller, second_task->dependencies()[0].get());
ProcessTask(&controller, second_task.get());
controller.UnrefImage(first_draw_image);
@@ -140,17 +140,18 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageAlreadyDecoded) {
DrawImage draw_image(
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task);
- EXPECT_TRUE(task->dependency());
+ EXPECT_EQ(task->dependencies().size(), 1u);
+ EXPECT_TRUE(task->dependencies()[0]);
- ProcessTask(&controller, task->dependency().get());
+ ProcessTask(&controller, task->dependencies()[0].get());
RunTask(task.get());
- scoped_refptr<ImageDecodeTask> another_task;
+ scoped_refptr<Task> another_task;
need_unref = controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id,
&another_task);
EXPECT_TRUE(need_unref);
@@ -175,15 +176,15 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageCanceledGetsNewTask) {
DrawImage draw_image(
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task);
- ProcessTask(&controller, task->dependency().get());
+ ProcessTask(&controller, task->dependencies()[0].get());
- scoped_refptr<ImageDecodeTask> another_task;
+ scoped_refptr<Task> another_task;
need_unref = controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id,
&another_task);
EXPECT_TRUE(need_unref);
@@ -197,14 +198,14 @@ TEST(GpuImageDecodeControllerTest, GetTaskForImageCanceledGetsNewTask) {
controller.UnrefImage(draw_image);
// Here a new task is created.
- scoped_refptr<ImageDecodeTask> third_task;
+ scoped_refptr<Task> third_task;
need_unref = controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id,
&third_task);
EXPECT_TRUE(need_unref);
EXPECT_TRUE(third_task);
EXPECT_FALSE(third_task.get() == task.get());
- ProcessTask(&controller, third_task->dependency().get());
+ ProcessTask(&controller, third_task->dependencies()[0].get());
ProcessTask(&controller, third_task.get());
controller.UnrefImage(draw_image);
@@ -224,15 +225,15 @@ TEST(GpuImageDecodeControllerTest,
DrawImage draw_image(
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task);
- ProcessTask(&controller, task->dependency().get());
+ ProcessTask(&controller, task->dependencies()[0].get());
- scoped_refptr<ImageDecodeTask> another_task;
+ scoped_refptr<Task> another_task;
need_unref = controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id,
&another_task);
EXPECT_TRUE(need_unref);
@@ -243,14 +244,14 @@ TEST(GpuImageDecodeControllerTest,
// Note that here, everything is reffed, but a new task is created. This is
// possible with repeated schedule/cancel operations.
- scoped_refptr<ImageDecodeTask> third_task;
+ scoped_refptr<Task> third_task;
need_unref = controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id,
&third_task);
EXPECT_TRUE(need_unref);
EXPECT_TRUE(third_task);
EXPECT_FALSE(third_task.get() == task.get());
- ProcessTask(&controller, third_task->dependency().get());
+ ProcessTask(&controller, third_task->dependencies()[0].get());
ProcessTask(&controller, third_task.get());
// 3 Unrefs!
@@ -272,13 +273,13 @@ TEST(GpuImageDecodeControllerTest, GetDecodedImageForDraw) {
DrawImage draw_image(
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task);
- ProcessTask(&controller, task->dependency().get());
+ ProcessTask(&controller, task->dependencies()[0].get());
ProcessTask(&controller, task.get());
// Must hold context lock before calling GetDecodedImageForDraw /
@@ -307,13 +308,13 @@ TEST(GpuImageDecodeControllerTest, GetLargeDecodedImageForDraw) {
DrawImage draw_image(
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_TRUE(need_unref);
EXPECT_TRUE(task);
- ProcessTask(&controller, task->dependency().get());
+ ProcessTask(&controller, task->dependencies()[0].get());
ProcessTask(&controller, task.get());
// Must hold context lock before calling GetDecodedImageForDraw /
@@ -346,7 +347,7 @@ TEST(GpuImageDecodeControllerTest, GetDecodedImageForDrawAtRasterDecode) {
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_FALSE(need_unref);
@@ -381,7 +382,7 @@ TEST(GpuImageDecodeControllerTest, AtRasterUsedDirectlyIfSpaceAllows) {
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_FALSE(need_unref);
@@ -403,7 +404,7 @@ TEST(GpuImageDecodeControllerTest, AtRasterUsedDirectlyIfSpaceAllows) {
// cache.
controller.DrawWithImageFinished(draw_image, decoded_draw_image);
- scoped_refptr<ImageDecodeTask> another_task;
+ scoped_refptr<Task> another_task;
bool another_task_needs_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_TRUE(another_task_needs_unref);
@@ -460,7 +461,7 @@ TEST(GpuImageDecodeControllerTest, ZeroSizedImagesAreSkipped) {
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(0.f, 0.f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_FALSE(task);
@@ -490,7 +491,7 @@ TEST(GpuImageDecodeControllerTest, NonOverlappingSrcRectImagesAreSkipped) {
image.get(), SkIRect::MakeXYWH(150, 150, image->width(), image->height()),
quality, CreateMatrix(SkSize::Make(1.f, 1.f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_FALSE(task);
@@ -520,14 +521,14 @@ TEST(GpuImageDecodeControllerTest, CanceledTasksDoNotCountAgainstBudget) {
image.get(), SkIRect::MakeXYWH(0, 0, image->width(), image->height()),
quality, CreateMatrix(SkSize::Make(1.f, 1.f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
EXPECT_NE(0u, controller.GetBytesUsedForTesting());
EXPECT_TRUE(task);
EXPECT_TRUE(need_unref);
- CompleteTask(&controller, task->dependency().get());
+ CompleteTask(&controller, task->dependencies()[0].get());
CompleteTask(&controller, task.get());
controller.UnrefImage(draw_image);
@@ -547,7 +548,7 @@ TEST(GpuImageDecodeControllerTest, ShouldAggressivelyFreeResources) {
DrawImage draw_image(
image.get(), SkIRect::MakeWH(image->width(), image->height()), quality,
CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
- scoped_refptr<ImageDecodeTask> task;
+ scoped_refptr<Task> task;
{
bool need_unref =
controller.GetTaskForImageAndRef(draw_image, prepare_tiles_id, &task);
@@ -555,7 +556,7 @@ TEST(GpuImageDecodeControllerTest, ShouldAggressivelyFreeResources) {
EXPECT_TRUE(task);
}
- ProcessTask(&controller, task->dependency().get());
+ ProcessTask(&controller, task->dependencies()[0].get());
ProcessTask(&controller, task.get());
controller.UnrefImage(draw_image);
@@ -585,7 +586,7 @@ TEST(GpuImageDecodeControllerTest, ShouldAggressivelyFreeResources) {
EXPECT_TRUE(task);
}
- ProcessTask(&controller, task->dependency().get());
+ ProcessTask(&controller, task->dependencies()[0].get());
ProcessTask(&controller, task.get());
// The image should be in our cache after un-ref.

Powered by Google App Engine
This is Rietveld 408576698