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

Unified Diff: src/codec/SkRawCodec.cpp

Issue 1738913002: Enable RAW codec for Windows (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Re-throw exception with better error code Created 4 years, 10 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
« no previous file with comments | « gyp/dng_sdk.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkRawCodec.cpp
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp
index a006e508379ed598f005b22619a9ad9d9b21e8fb..e0704ee3511ef99021ba8608b83cef9a74943b95 100644
--- a/src/codec/SkRawCodec.cpp
+++ b/src/codec/SkRawCodec.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkAtomics.h"
#include "SkCodec.h"
#include "SkCodecPriv.h"
#include "SkColorPriv.h"
@@ -21,6 +22,7 @@
#include "dng_area_task.h"
#include "dng_color_space.h"
+#include "dng_errors.h"
#include "dng_exceptions.h"
#include "dng_host.h"
#include "dng_info.h"
@@ -105,15 +107,26 @@ public:
const std::vector<dng_rect> taskAreas = compute_task_areas(maxTasks, area, tileSize);
const int numTasks = static_cast<int>(taskAreas.size());
+ SkAtomic<dng_error_code> dngErrorCode(dng_error_none);
mtklein 2016/02/26 13:29:11 Generally I'd prefer that we use a mutex until it
yujieqin 2016/02/26 14:02:37 Thanks for the tips. I will store all the except
task.Start(numTasks, tileSize, &Allocator(), Sniffer());
for (int taskIndex = 0; taskIndex < numTasks; ++taskIndex) {
- taskGroup.add([&task, this, taskIndex, taskAreas, tileSize] {
- task.ProcessOnThread(taskIndex, taskAreas[taskIndex], tileSize, this->Sniffer());
+ taskGroup.add([&task, &dngErrorCode, this, taskIndex, taskAreas, tileSize] {
+ try {
+ task.ProcessOnThread(taskIndex, taskAreas[taskIndex], tileSize, this->Sniffer());
+ } catch (dng_exception& except) {
+ dngErrorCode = except.ErrorCode();
+ } catch (...) {
+ dngErrorCode = dng_error_unknown;
+ }
});
}
taskGroup.wait();
task.Finish(numTasks);
+
+ if (dngErrorCode != dng_error_none) {
+ Throw_dng_error(dngErrorCode, nullptr, nullptr);
+ }
}
uint32 PerformAreaTaskThreads() override {
@@ -428,15 +441,15 @@ public:
}
}
- // render() takes ownership of fHost, fInfo, fNegative and fDngStream when available.
- SkAutoTDelete<dng_host> host(fHost.release());
- SkAutoTDelete<dng_info> info(fInfo.release());
- SkAutoTDelete<dng_negative> negative(fNegative.release());
- SkAutoTDelete<dng_stream> dngStream(fDngStream.release());
-
// DNG SDK preserves the aspect ratio, so it only needs to know the longer dimension.
const int preferredSize = SkTMax(width, height);
try {
+ // render() takes ownership of fHost, fInfo, fNegative and fDngStream when available.
+ SkAutoTDelete<dng_host> host(fHost.release());
+ SkAutoTDelete<dng_info> info(fInfo.release());
+ SkAutoTDelete<dng_negative> negative(fNegative.release());
+ SkAutoTDelete<dng_stream> dngStream(fDngStream.release());
+
host->SetPreferredSize(preferredSize);
host->ValidateSizes();
@@ -506,11 +519,12 @@ private:
}
bool readDng() {
- // Due to the limit of DNG SDK, we need to reset host and info.
- fHost.reset(new SkDngHost(&fAllocator));
- fInfo.reset(new dng_info);
- fDngStream.reset(new SkDngStream(fStream));
try {
+ // Due to the limit of DNG SDK, we need to reset host and info.
+ fHost.reset(new SkDngHost(&fAllocator));
+ fInfo.reset(new dng_info);
+ fDngStream.reset(new SkDngStream(fStream));
+
fHost->ValidateSizes();
fInfo->Parse(*fHost, *fDngStream);
fInfo->PostParse(*fHost);
« no previous file with comments | « gyp/dng_sdk.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698