aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/codec/SkRawCodec.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp
index e8b49f8bfa..bc3efcbf5f 100644
--- a/src/codec/SkRawCodec.cpp
+++ b/src/codec/SkRawCodec.cpp
@@ -98,16 +98,12 @@ public:
explicit SkDngHost(dng_memory_allocator* allocater) : dng_host(allocater) {}
void PerformAreaTask(dng_area_task& task, const dng_rect& area) override {
- // The area task gets split up into max_tasks sub-tasks. The max_tasks is defined by the
- // dng-sdks default implementation of dng_area_task::MaxThreads() which returns 8 or 32
- // sub-tasks depending on the architecture.
- const int maxTasks = static_cast<int>(task.MaxThreads());
-
SkTaskGroup taskGroup;
// tileSize is typically 256x256
const dng_point tileSize(task.FindTileSize(area));
- const std::vector<dng_rect> taskAreas = compute_task_areas(maxTasks, area, tileSize);
+ const std::vector<dng_rect> taskAreas = compute_task_areas(this->PerformAreaTaskThreads(),
+ area, tileSize);
const int numTasks = static_cast<int>(taskAreas.size());
SkMutex mutex;
@@ -130,15 +126,25 @@ public:
taskGroup.wait();
task.Finish(numTasks);
- // Currently we only re-throw the first catched exception.
+ // We only re-throw the first exception.
if (!exceptions.empty()) {
Throw_dng_error(exceptions.front().ErrorCode(), nullptr, nullptr);
}
}
uint32 PerformAreaTaskThreads() override {
- // FIXME: Need to get the real amount of available threads used in the SkTaskGroup.
+#ifdef SK_BUILD_FOR_ANDROID
+ // According to https://codereview.chromium.org/1634763002/diff/20001/src/codec/SkRawCodec.cpp#newcode71,
+ // having more tasks than CPU threads typically helps performance due
+ // to uneven task runtime. Today's Android devices tend to only have two
+ // cores, so above two should be enough. Too many threads raises the risk
+ // of running out of memory, as each task may allocate a large amount of
+ // memory, so keep this low. This value allows a marlin to decode a
+ // memory-intensive dng file successfully.
+ return 4;
+#else
return kMaxMPThreads;
+#endif
}
private: