From 840434d046cbaefb5a70875b7e364523c713c79b Mon Sep 17 00:00:00 2001 From: "gspencer@google.com" Date: Tue, 23 Jun 2009 21:35:54 +0000 Subject: These are code changes required to make the GYP build work. Mostly these are fixes to warnings (signed/unsigned mismatches were the most common), and some changes to include paths. I've updated the build.scons files and DEPS file to match these changes so that the scons build will still function with these changes. Review URL: http://codereview.chromium.org/146047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19062 0039d316-1c4b-4281-b951-d872f2087c98 --- o3d/DEPS | 2 +- o3d/breakpad/win/bluescreen_detector.cc | 3 +- o3d/core/cross/canvas.cc | 2 +- o3d/core/cross/canvas.h | 4 +- o3d/core/cross/canvas_paint.cc | 125 +++++++++++++- o3d/core/cross/canvas_paint.h | 2 +- o3d/core/cross/canvas_shader.cc | 4 +- o3d/core/cross/canvas_shader.h | 4 +- o3d/core/cross/canvas_utils.h | 2 +- o3d/plugin/build.scons | 5 +- o3d/plugin/cross/archive_request_glue.cc | 214 ------------------------ o3d/plugin/cross/archive_request_glue.h | 66 -------- o3d/plugin/cross/archive_request_static_glue.cc | 214 ++++++++++++++++++++++++ o3d/plugin/cross/archive_request_static_glue.h | 66 ++++++++ o3d/plugin/cross/np_v8_bridge.h | 2 +- o3d/plugin/idl/bounding_box.idl | 2 +- o3d/plugin/idl/texture.idl | 8 +- o3d/plugin/win/main_win.cc | 2 +- o3d/serializer/cross/serializer.cc | 2 +- o3d/serializer/cross/serializer_binary.cc | 16 +- o3d/svn_paths.scons | 2 +- 21 files changed, 430 insertions(+), 317 deletions(-) delete mode 100644 o3d/plugin/cross/archive_request_glue.cc delete mode 100644 o3d/plugin/cross/archive_request_glue.h create mode 100644 o3d/plugin/cross/archive_request_static_glue.cc create mode 100644 o3d/plugin/cross/archive_request_static_glue.h (limited to 'o3d') diff --git a/o3d/DEPS b/o3d/DEPS index 5515068..ef0111b 100644 --- a/o3d/DEPS +++ b/o3d/DEPS @@ -49,7 +49,7 @@ deps = { "http://o3d.googlecode.com/svn/trunk/googleclient/third_party/scons@" + Var("o3d_code_rev"), "o3d/third_party/skia": - "http://o3d.googlecode.com/svn/trunk/googleclient/third_party/skia@" + Var("o3d_code_rev"), + "http://o3d.googlecode.com/svn/trunk/googleclient/third_party/skia/files@" + Var("o3d_code_rev"), "o3d/third_party/vectormath": "http://o3d.googlecode.com/svn/trunk/googleclient/third_party/vectormath@" + Var("o3d_code_rev"), diff --git a/o3d/breakpad/win/bluescreen_detector.cc b/o3d/breakpad/win/bluescreen_detector.cc index 9cdd51f..0d68fb5 100644 --- a/o3d/breakpad/win/bluescreen_detector.cc +++ b/o3d/breakpad/win/bluescreen_detector.cc @@ -104,7 +104,8 @@ int MarkerFileManagerInterface::DetectStrayMarkerFiles() { // the machine was last booted int stray_file_count = 0; - for (int i = 0; i < marker_files.size(); ++i) { + for (vector::size_type i = 0; + i < marker_files.size(); ++i) { const MarkerFileInfo &file_info = marker_files[i]; if (time_manager_->IsMarkerFileOld(file_info)) { diff --git a/o3d/core/cross/canvas.cc b/o3d/core/cross/canvas.cc index d196fcc..26fabbd 100644 --- a/o3d/core/cross/canvas.cc +++ b/o3d/core/cross/canvas.cc @@ -39,7 +39,7 @@ #include "core/cross/client.h" #include "core/cross/error.h" -#include "third_party/skia/files/include/core/SkPath.h" +#include "third_party/skia/include/core/SkPath.h" namespace o3d { diff --git a/o3d/core/cross/canvas.h b/o3d/core/cross/canvas.h index 07c39f0..5c9c62e 100644 --- a/o3d/core/cross/canvas.h +++ b/o3d/core/cross/canvas.h @@ -41,8 +41,8 @@ #include "core/cross/param.h" #include "core/cross/texture.h" -#include "third_party/skia/files/include/core/SkBitmap.h" -#include "third_party/skia/files/include/core/SkCanvas.h" +#include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/skia/include/core/SkCanvas.h" namespace o3d { diff --git a/o3d/core/cross/canvas_paint.cc b/o3d/core/cross/canvas_paint.cc index fe56453..3e37877 100644 --- a/o3d/core/cross/canvas_paint.cc +++ b/o3d/core/cross/canvas_paint.cc @@ -37,14 +37,125 @@ #include "core/cross/canvas_utils.h" #include "core/cross/client.h" -#include "third_party/skia/files/include/core/SkDrawLooper.h" -#include "third_party/skia/files/include/core/SkPaint.h" -#include "third_party/skia/files/include/core/SkTypeface.h" -#include "third_party/skia/files/include/effects/SkBlurDrawLooper.h" -#include "third_party/skia/files/include/effects/SkStrokeDrawLooper.h" +#include "third_party/skia/include/core/SkCanvas.h" +#include "third_party/skia/include/core/SkColor.h" +#include "third_party/skia/include/core/SkDrawLooper.h" +#include "third_party/skia/include/core/SkPaint.h" +#include "third_party/skia/include/core/SkTypeface.h" +#include "third_party/skia/include/effects/SkBlurDrawLooper.h" namespace o3d { +namespace { + +/** StrokeDrawLooper This class draws an outline of the +* object, and then draws the original object in its original +* position. +*/ +class StrokeDrawLooper : public SkDrawLooper { + public: + StrokeDrawLooper(SkScalar radius, SkColor color); + virtual ~StrokeDrawLooper() {} + virtual void init(SkCanvas* canvas, SkPaint* paint); + virtual bool next(); + virtual void restore(); + + protected: + virtual Factory getFactory() { return CreateProc; } + void flatten(SkFlattenableWriteBuffer& buffer); + StrokeDrawLooper(SkFlattenableReadBuffer& buffer); + + private: + SkCanvas* fCanvas; + SkPaint* fPaint; + + // These are to save the state attributes that we want to change so + // we can restore them after we draw the stroke. + SkPaint::Style fSavedStyle; + SkScalar fSavedStrokeWidth; + SkColor fSavedColor; + + // These are the attribues of the stroke. + SkScalar fRadius; + SkColor fColor; + + // Possible machine states for this object. + enum State { + kBeforeEdge, + kAfterEdge, + kDone, + }; + State fState; + + // Factory method for ressurecting a StrokeDrawLooper. + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + return SkNEW_ARGS(StrokeDrawLooper, (buffer)); } + + typedef SkDrawLooper INHERITED; +}; + +StrokeDrawLooper::StrokeDrawLooper(SkScalar radius, SkColor color) + : fColor(color), fRadius(radius) { +} + +void StrokeDrawLooper::init(SkCanvas* canvas, SkPaint* paint) { + fState = kBeforeEdge; + fCanvas = canvas; + fPaint = paint; +} + +bool StrokeDrawLooper::next() { + switch (fState) { + case kBeforeEdge: + // Save the original values. + fSavedStyle = fPaint->getStyle(); + fSavedStrokeWidth = fPaint->getStrokeWidth(); + fSavedColor = fPaint->getColor(); + + // Override with stroke values. + fPaint->setColor(fColor); + fPaint->setStrokeWidth(fRadius); + fPaint->setStyle(SkPaint::kStroke_Style); + + // Change states. + fState = kAfterEdge; + return true; + case kAfterEdge: + // Restore original values. + fPaint->setColor(fSavedColor); + fPaint->setStrokeWidth(fSavedStrokeWidth); + fPaint->setStyle(fSavedStyle); + + // Now we're done. + fState = kDone; + return true; + default: + SkASSERT(kDone == fState); + return false; + } +} + +void StrokeDrawLooper::restore() { + if (kAfterEdge == fState) { + fPaint->setColor(fSavedColor); + fPaint->setStrokeWidth(fSavedStrokeWidth); + fPaint->setStyle(fSavedStyle); + fState = kDone; + } +} + +void StrokeDrawLooper::flatten(SkFlattenableWriteBuffer& buffer) { + buffer.writeScalar(fRadius); + buffer.write32(fColor); +} + +StrokeDrawLooper::StrokeDrawLooper(SkFlattenableReadBuffer& buffer) { + fRadius = buffer.readScalar(); + fColor = buffer.readU32(); +} + +} // end anonymous namespace + O3D_DEFN_CLASS(CanvasPaint, ParamObject); static SkPaint::Align ToSKAlign(CanvasPaint::TextAlign align) { @@ -88,8 +199,8 @@ void CanvasPaint::UpdateNativePaint() { // Note that shadow and ouline cannot both be active at the same time. if (outline_radius_ != 0.0) { - SkDrawLooper* l = new SkStrokeDrawLooper(SkFloatToScalar(outline_radius_), - Float4ToSkColor(outline_color_)); + SkDrawLooper* l = new StrokeDrawLooper(SkFloatToScalar(outline_radius_), + Float4ToSkColor(outline_color_)); sk_paint_.setLooper(l); l->unref(); } else if (shadow_radius_ != 0.0) { diff --git a/o3d/core/cross/canvas_paint.h b/o3d/core/cross/canvas_paint.h index ac76a70..aaec72a 100644 --- a/o3d/core/cross/canvas_paint.h +++ b/o3d/core/cross/canvas_paint.h @@ -39,7 +39,7 @@ #include "core/cross/param.h" #include "core/cross/canvas_shader.h" -#include "third_party/skia/files/include/core/SkPaint.h" +#include "third_party/skia/include/core/SkPaint.h" namespace o3d { diff --git a/o3d/core/cross/canvas_shader.cc b/o3d/core/cross/canvas_shader.cc index 9a5cb93..aeff7df 100644 --- a/o3d/core/cross/canvas_shader.cc +++ b/o3d/core/cross/canvas_shader.cc @@ -38,8 +38,8 @@ #include "core/cross/canvas_utils.h" #include "core/cross/error.h" -#include "third_party/skia/files/include/core/SkShader.h" -#include "third_party/skia/files/include/effects/SkGradientShader.h" +#include "third_party/skia/include/core/SkShader.h" +#include "third_party/skia/include/effects/SkGradientShader.h" namespace o3d { diff --git a/o3d/core/cross/canvas_shader.h b/o3d/core/cross/canvas_shader.h index ac86926..cf9fd0b 100644 --- a/o3d/core/cross/canvas_shader.h +++ b/o3d/core/cross/canvas_shader.h @@ -40,8 +40,8 @@ #include "core/cross/param_object.h" #include "core/cross/param.h" -#include "third_party/skia/files/include/core/SkColor.h" -#include "third_party/skia/files/include/core/SkPoint.h" +#include "third_party/skia/include/core/SkColor.h" +#include "third_party/skia/include/core/SkPoint.h" class SkShader; diff --git a/o3d/core/cross/canvas_utils.h b/o3d/core/cross/canvas_utils.h index 36e400e..87ce013 100644 --- a/o3d/core/cross/canvas_utils.h +++ b/o3d/core/cross/canvas_utils.h @@ -34,7 +34,7 @@ #define O3D_CORE_CROSS_CANVAS_UTILS_H_ #include "core/cross/float_n.h" -#include "third_party/skia/files/include/core/SkColor.h" +#include "third_party/skia/include/core/SkColor.h" // Helper function to convert from Float4 to an SkColor static SkColor Float4ToSkColor(const o3d::Float4& color) { diff --git a/o3d/plugin/build.scons b/o3d/plugin/build.scons index e6c344a..666cd7a 100644 --- a/o3d/plugin/build.scons +++ b/o3d/plugin/build.scons @@ -82,7 +82,8 @@ env.Append( '$NIXYSA_STATIC_GLUE', '$SCONSTRUCT_DIR/plugin/win', # for RES resource.h '$WTL_71_DIR/include', - ], + '$THIRD_PARTY', + ], LIBPATH = [ '$NACL_LIB_DIR', ], @@ -180,7 +181,7 @@ AUTOGEN_CC_FILES = [f for f in AUTOGEN_OUTPUT if f.suffix == '.cc'] inputs = AUTOGEN_CC_FILES + [ 'cross/async_loading.cc', - 'cross/archive_request_glue.cc', + 'cross/archive_request_static_glue.cc', 'cross/blacklist.cc', 'cross/o3d_glue.cc', 'cross/np_v8_bridge.cc', diff --git a/o3d/plugin/cross/archive_request_glue.cc b/o3d/plugin/cross/archive_request_glue.cc deleted file mode 100644 index 704aaa7..0000000 --- a/o3d/plugin/cross/archive_request_glue.cc +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright 2009, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "plugin/cross/archive_request_glue.h" - -#include "base/basictypes.h" -#include "plugin/cross/stream_manager.h" -#include "plugin/cross/o3d_glue.h" -#include "import/cross/archive_request.h" - -namespace glue { -namespace namespace_o3d { -namespace class_ArchiveRequest { - -using _o3d::PluginObject; -using o3d::Pack; -using o3d::ArchiveRequest; - -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Callbacks -// -// TODO : get rid of these horrible callback objects which end up just -// dispatching to the ArchiveRequest object. -// Need to change the StreamManager class to implement an interface: -// WriteReadyCallback -// WriteCallback -// FinishedCallback -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class ArchiveNewStreamCallback : public StreamManager::NewStreamCallback { - public: - explicit ArchiveNewStreamCallback(ArchiveRequest *request) - : request_(request) { } - - virtual void Run(DownloadStream *stream) { - request_->NewStreamCallback(stream); - } - - private: - ArchiveRequest::Ref request_; - DISALLOW_COPY_AND_ASSIGN(ArchiveNewStreamCallback); -}; - -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class ArchiveWriteReadyCallback : public StreamManager::WriteReadyCallback { - public: - explicit ArchiveWriteReadyCallback(ArchiveRequest *request) - : request_(request) { } - - virtual int32 Run(DownloadStream *stream) { - return request_->WriteReadyCallback(stream); - } - - private: - ArchiveRequest::Ref request_; - DISALLOW_COPY_AND_ASSIGN(ArchiveWriteReadyCallback); -}; - -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class ArchiveWriteCallback : public StreamManager::WriteCallback { - public: - explicit ArchiveWriteCallback(ArchiveRequest *request) : request_(request) { - } - - virtual int32 Run(DownloadStream *stream, - int32 offset, - int32 length, - void *data) { - return request_->WriteCallback(stream, offset, length, data); - } - - private: - ArchiveRequest::Ref request_; - DISALLOW_COPY_AND_ASSIGN(ArchiveWriteCallback); -}; - -class ArchiveFinishedCallback : public StreamManager::FinishedCallback { - public: - explicit ArchiveFinishedCallback(ArchiveRequest *request) - : request_(request) { - } - - virtual ~ArchiveFinishedCallback() { - // If the file request was interrupted (for example we moved to a new page - // before the file transfer was completed) then we tell the FileRequest - // object that the request failed. It's important to call this here since - // set_success() will release the pack reference that the FileRequest holds - // which will allow the pack to be garbage collected. - if (!request_->done()) { - request_->set_success(false); - } - } - - // Loads the Archive file, calls the JS callback to notify success. - virtual void Run(DownloadStream *stream, - bool success, - const std::string &filename, - const std::string &mime_type) { - request_->FinishedCallback(stream, success, filename, mime_type); - } - - private: - ArchiveRequest::Ref request_; - DISALLOW_COPY_AND_ASSIGN(ArchiveFinishedCallback); -}; - -// Sets up the parameters required for all ArchiveRequests. -void userglue_method_open(void *plugin_data, - ArchiveRequest *request, - const String &method, - const String &uri) { - if (request->done()) { - request->set_success(false); - request->set_ready_state(ArchiveRequest::STATE_INIT); // not ready - return; // We don't yet support reusing ArchiveRequests. - } - - String method_lower(method); - std::transform(method.begin(), method.end(), method_lower.begin(), ::tolower); - if (method_lower != "get") { - request->set_success(false); - return; // We don't yet support fetching files via POST. - } - request->set_uri(uri); - request->set_ready_state(ArchiveRequest::STATE_OPEN); -} - -// Starts progressively downloading the requested file -// The ArchiveRequest object will get callbacks as bytes stream in -void userglue_method_send(void *plugin_data, - ArchiveRequest *request) { - PluginObject *plugin_object = static_cast(plugin_data); - StreamManager *stream_manager = plugin_object->stream_manager(); - bool result = false; - - if (request->done()) { - request->set_success(false); - return; // ArchiveRequests can't be reused. - } - if (request->ready_state() != 1) { // Forgot to call open, or other error. - request->set_success(false); - return; - } - CHECK(request->pack()); - - ArchiveNewStreamCallback *new_stream_callback = - new ArchiveNewStreamCallback(request); - - ArchiveWriteReadyCallback *writeready_callback = - new ArchiveWriteReadyCallback(request); - - ArchiveWriteCallback *write_callback = - new ArchiveWriteCallback(request); - - ArchiveFinishedCallback *finished_callback = - new ArchiveFinishedCallback(request); - - if (finished_callback) { - DownloadStream *stream = stream_manager->LoadURL(request->uri(), - new_stream_callback, - writeready_callback, - write_callback, - finished_callback, - NP_NORMAL); - if (!stream) { - // We don't call O3D_ERROR here because the URI may be user set - // so we don't want to cause an error callback when the developer - // may not be able to know the URI is correct. - request->set_error("could not create download stream"); - - // We need to call the callback to report failure. Because it's async, the - // code making the request can't know that once it has called send() that - // the request still exists since send() may have called the callback and - // the callback may have deleted the request. - request->FinishedCallback(NULL, false, request->uri(), std::string("")); - } - - // If stream is not NULL request may not exist as LoadURL may already have - // completed and therefore called the callback which may have freed the - // request so we can't set anything on the request here. - } -} - -} // namespace class_ArchiveRequest -} // namespace namespace_o3d -} // namespace glue diff --git a/o3d/plugin/cross/archive_request_glue.h b/o3d/plugin/cross/archive_request_glue.h deleted file mode 100644 index f9f1384..0000000 --- a/o3d/plugin/cross/archive_request_glue.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2009, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -// This file declares the glue for FileRequest actions. - -#ifndef O3D_PLUGIN_ARCHIVE_REQUEST_GLUE_H_ -#define O3D_PLUGIN_ARCHIVE_REQUEST_GLUE_H_ - -#include "core/cross/callback.h" -#include "core/cross/types.h" - -namespace o3d { -class ArchiveRequest; -} // namespace o3d - -namespace glue { -namespace namespace_o3d { -namespace class_ArchiveRequest { - -using o3d::ArchiveRequest; -using o3d::String; - -// Sets up the parameters required for all FileRequests. -void userglue_method_open(void *plugin_data, - ArchiveRequest *request, - const String &method, - const String &uri); - -// Starts downloading or reading the requested file, passing in a callback that -// will parse and incorporate the file upon success. -void userglue_method_send(void *plugin_data, - ArchiveRequest *request); -} // namespace class_FileRequest -} // namespace namespace_o3d -} // namespace glue - -#endif // O3D_PLUGIN_ARCHIVE_REQUEST_GLUE_H_ diff --git a/o3d/plugin/cross/archive_request_static_glue.cc b/o3d/plugin/cross/archive_request_static_glue.cc new file mode 100644 index 0000000..c11fd1c --- /dev/null +++ b/o3d/plugin/cross/archive_request_static_glue.cc @@ -0,0 +1,214 @@ +/* + * Copyright 2009, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "plugin/cross/archive_request_static_glue.h" + +#include "base/basictypes.h" +#include "plugin/cross/stream_manager.h" +#include "plugin/cross/o3d_glue.h" +#include "import/cross/archive_request.h" + +namespace glue { +namespace namespace_o3d { +namespace class_ArchiveRequest { + +using _o3d::PluginObject; +using o3d::Pack; +using o3d::ArchiveRequest; + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Callbacks +// +// TODO : get rid of these horrible callback objects which end up just +// dispatching to the ArchiveRequest object. +// Need to change the StreamManager class to implement an interface: +// WriteReadyCallback +// WriteCallback +// FinishedCallback +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class ArchiveNewStreamCallback : public StreamManager::NewStreamCallback { + public: + explicit ArchiveNewStreamCallback(ArchiveRequest *request) + : request_(request) { } + + virtual void Run(DownloadStream *stream) { + request_->NewStreamCallback(stream); + } + + private: + ArchiveRequest::Ref request_; + DISALLOW_COPY_AND_ASSIGN(ArchiveNewStreamCallback); +}; + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class ArchiveWriteReadyCallback : public StreamManager::WriteReadyCallback { + public: + explicit ArchiveWriteReadyCallback(ArchiveRequest *request) + : request_(request) { } + + virtual int32 Run(DownloadStream *stream) { + return request_->WriteReadyCallback(stream); + } + + private: + ArchiveRequest::Ref request_; + DISALLOW_COPY_AND_ASSIGN(ArchiveWriteReadyCallback); +}; + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class ArchiveWriteCallback : public StreamManager::WriteCallback { + public: + explicit ArchiveWriteCallback(ArchiveRequest *request) : request_(request) { + } + + virtual int32 Run(DownloadStream *stream, + int32 offset, + int32 length, + void *data) { + return request_->WriteCallback(stream, offset, length, data); + } + + private: + ArchiveRequest::Ref request_; + DISALLOW_COPY_AND_ASSIGN(ArchiveWriteCallback); +}; + +class ArchiveFinishedCallback : public StreamManager::FinishedCallback { + public: + explicit ArchiveFinishedCallback(ArchiveRequest *request) + : request_(request) { + } + + virtual ~ArchiveFinishedCallback() { + // If the file request was interrupted (for example we moved to a new page + // before the file transfer was completed) then we tell the FileRequest + // object that the request failed. It's important to call this here since + // set_success() will release the pack reference that the FileRequest holds + // which will allow the pack to be garbage collected. + if (!request_->done()) { + request_->set_success(false); + } + } + + // Loads the Archive file, calls the JS callback to notify success. + virtual void Run(DownloadStream *stream, + bool success, + const std::string &filename, + const std::string &mime_type) { + request_->FinishedCallback(stream, success, filename, mime_type); + } + + private: + ArchiveRequest::Ref request_; + DISALLOW_COPY_AND_ASSIGN(ArchiveFinishedCallback); +}; + +// Sets up the parameters required for all ArchiveRequests. +void userglue_method_open(void *plugin_data, + ArchiveRequest *request, + const String &method, + const String &uri) { + if (request->done()) { + request->set_success(false); + request->set_ready_state(ArchiveRequest::STATE_INIT); // not ready + return; // We don't yet support reusing ArchiveRequests. + } + + String method_lower(method); + std::transform(method.begin(), method.end(), method_lower.begin(), ::tolower); + if (method_lower != "get") { + request->set_success(false); + return; // We don't yet support fetching files via POST. + } + request->set_uri(uri); + request->set_ready_state(ArchiveRequest::STATE_OPEN); +} + +// Starts progressively downloading the requested file +// The ArchiveRequest object will get callbacks as bytes stream in +void userglue_method_send(void *plugin_data, + ArchiveRequest *request) { + PluginObject *plugin_object = static_cast(plugin_data); + StreamManager *stream_manager = plugin_object->stream_manager(); + bool result = false; + + if (request->done()) { + request->set_success(false); + return; // ArchiveRequests can't be reused. + } + if (request->ready_state() != 1) { // Forgot to call open, or other error. + request->set_success(false); + return; + } + CHECK(request->pack()); + + ArchiveNewStreamCallback *new_stream_callback = + new ArchiveNewStreamCallback(request); + + ArchiveWriteReadyCallback *writeready_callback = + new ArchiveWriteReadyCallback(request); + + ArchiveWriteCallback *write_callback = + new ArchiveWriteCallback(request); + + ArchiveFinishedCallback *finished_callback = + new ArchiveFinishedCallback(request); + + if (finished_callback) { + DownloadStream *stream = stream_manager->LoadURL(request->uri(), + new_stream_callback, + writeready_callback, + write_callback, + finished_callback, + NP_NORMAL); + if (!stream) { + // We don't call O3D_ERROR here because the URI may be user set + // so we don't want to cause an error callback when the developer + // may not be able to know the URI is correct. + request->set_error("could not create download stream"); + + // We need to call the callback to report failure. Because it's async, the + // code making the request can't know that once it has called send() that + // the request still exists since send() may have called the callback and + // the callback may have deleted the request. + request->FinishedCallback(NULL, false, request->uri(), std::string("")); + } + + // If stream is not NULL request may not exist as LoadURL may already have + // completed and therefore called the callback which may have freed the + // request so we can't set anything on the request here. + } +} + +} // namespace class_ArchiveRequest +} // namespace namespace_o3d +} // namespace glue diff --git a/o3d/plugin/cross/archive_request_static_glue.h b/o3d/plugin/cross/archive_request_static_glue.h new file mode 100644 index 0000000..199de08 --- /dev/null +++ b/o3d/plugin/cross/archive_request_static_glue.h @@ -0,0 +1,66 @@ +/* + * Copyright 2009, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +// This file declares the glue for FileRequest actions. + +#ifndef O3D_PLUGIN_ARCHIVE_REQUEST_STATIC_GLUE_H_ +#define O3D_PLUGIN_ARCHIVE_REQUEST_STATIC_GLUE_H_ + +#include "core/cross/callback.h" +#include "core/cross/types.h" + +namespace o3d { +class ArchiveRequest; +} // namespace o3d + +namespace glue { +namespace namespace_o3d { +namespace class_ArchiveRequest { + +using o3d::ArchiveRequest; +using o3d::String; + +// Sets up the parameters required for all FileRequests. +void userglue_method_open(void *plugin_data, + ArchiveRequest *request, + const String &method, + const String &uri); + +// Starts downloading or reading the requested file, passing in a callback that +// will parse and incorporate the file upon success. +void userglue_method_send(void *plugin_data, + ArchiveRequest *request); +} // namespace class_FileRequest +} // namespace namespace_o3d +} // namespace glue + +#endif // O3D_PLUGIN_ARCHIVE_REQUEST_STATIC_GLUE_H_ diff --git a/o3d/plugin/cross/np_v8_bridge.h b/o3d/plugin/cross/np_v8_bridge.h index 779a5a3..150a3c2 100644 --- a/o3d/plugin/cross/np_v8_bridge.h +++ b/o3d/plugin/cross/np_v8_bridge.h @@ -62,7 +62,7 @@ #undef Value #endif -#include "third_party/v8/include/v8.h" +#include "v8/include/v8.h" namespace o3d { diff --git a/o3d/plugin/idl/bounding_box.idl b/o3d/plugin/idl/bounding_box.idl index b8ac932..1904f59 100644 --- a/o3d/plugin/idl/bounding_box.idl +++ b/o3d/plugin/idl/bounding_box.idl @@ -143,7 +143,7 @@ class BoundingBox { O3D_ERROR(service_locator) << "BoundingBox: expected 2 values, got " << values.size(); } else { - for (int i = 0; i < values.size(); ++i) { + for (std::vector::size_type i = 0; i < values.size(); ++i) { if (values[i].size() != 3) { o3d::ServiceLocator* service_locator = static_cast( diff --git a/o3d/plugin/idl/texture.idl b/o3d/plugin/idl/texture.idl index cc470c0..7039a9e 100644 --- a/o3d/plugin/idl/texture.idl +++ b/o3d/plugin/idl/texture.idl @@ -268,7 +268,7 @@ namespace o3d { source_x -= destination_x; destination_x = 0; } - if (destination_x + copy_width > texture_width) { + if (destination_x + copy_width > static_cast(texture_width)) { copy_width -= destination_x + copy_width - texture_width; } @@ -277,7 +277,7 @@ namespace o3d { source_y -= destination_y; destination_y = 0; } - if (destination_y + copy_height > texture_height) { + if (destination_y + copy_height > static_cast(texture_height)) { copy_height -= destination_y + copy_height - texture_height; } @@ -303,7 +303,7 @@ namespace o3d { (destination_y * texture_width + destination_x) * num_components; while (copy_height > 0) { for (int xx = 0; xx < copy_width; ++xx) { - for (int element = 0; element < num_components; ++element) { + for (unsigned element = 0; element < num_components; ++element) { destination[element] = Vectormath::Aos::FloatToHalf( source[swizzle[element]]); } @@ -323,7 +323,7 @@ namespace o3d { (destination_y * texture_width + destination_x) * num_components; while (copy_height > 0) { for (int xx = 0; xx < copy_width; ++xx) { - for (int element = 0; element < num_components; ++element) { + for (unsigned element = 0; element < num_components; ++element) { destination[element] = source[swizzle[element]]; } destination += num_components; diff --git a/o3d/plugin/win/main_win.cc b/o3d/plugin/win/main_win.cc index 1f1b14d..6107067 100644 --- a/o3d/plugin/win/main_win.cc +++ b/o3d/plugin/win/main_win.cc @@ -442,7 +442,7 @@ static LRESULT HandleDragAndDrop(PluginObject *obj, WPARAM wParam) { path_to_use = path.get(); #endif - for (int i = 0; i < num_chars; ++i) { + for (UINT i = 0; i < num_chars; ++i) { if (path_to_use[i] == '\\') { path_to_use[i] = '/'; } diff --git a/o3d/serializer/cross/serializer.cc b/o3d/serializer/cross/serializer.cc index f9266af..066ce30 100644 --- a/o3d/serializer/cross/serializer.cc +++ b/o3d/serializer/cross/serializer.cc @@ -756,7 +756,7 @@ void Serializer::SerializePack(Pack* pack) { void Serializer::SerializePackBinary(Pack* pack) { std::vector objects = pack->GetByClass(); - for (int i = 0; i < objects.size(); ++i) { + for (std::vector::size_type i = 0; i < objects.size(); ++i) { binary_visitor_->Accept(objects[i]); } } diff --git a/o3d/serializer/cross/serializer_binary.cc b/o3d/serializer/cross/serializer_binary.cc index 9b7f523..56793c4 100644 --- a/o3d/serializer/cross/serializer_binary.cc +++ b/o3d/serializer/cross/serializer_binary.cc @@ -80,7 +80,7 @@ void SerializeBuffer(const Buffer &buffer, MemoryBuffer *output) { stream.WriteLittleEndianInt32(static_cast(num_fields)); // Write out the specification for the fields - for (int i = 0; i < num_fields; ++i) { + for (size_t i = 0; i < num_fields; ++i) { const Field &field = *buffer.fields()[i]; // Determine the FIELDID code we need to write out @@ -110,7 +110,7 @@ void SerializeBuffer(const Buffer &buffer, MemoryBuffer *output) { // Write out the data for each field // Write out the specification for the fields - for (int i = 0; i < num_fields; ++i) { + for (size_t i = 0; i < num_fields; ++i) { const Field &field = *buffer.fields()[i]; MemoryBuffer field_data(field.size() * num_elements); @@ -127,7 +127,7 @@ void SerializeBuffer(const Buffer &buffer, MemoryBuffer *output) { field.num_components(), num_elements); // Write out as little endian float32 - for (int i = 0; i < nitems; ++i) { + for (size_t i = 0; i < nitems; ++i) { stream.WriteLittleEndianFloat32(float_destination[i]); } } else if (field.IsA(UInt32Field::GetApparentClass())) { @@ -138,7 +138,7 @@ void SerializeBuffer(const Buffer &buffer, MemoryBuffer *output) { field.num_components(), num_elements); // Write out as little endian int32 - for (int i = 0; i < nitems; ++i) { + for (size_t i = 0; i < nitems; ++i) { stream.WriteLittleEndianInt32(int_destination[i]); } } else if (field.IsA(UByteNField::GetApparentClass())) { @@ -186,7 +186,7 @@ void SerializeCurve(const Curve &curve, MemoryBuffer *output) { stream.WriteLittleEndianInt32(1); - for (int i = 0; i < num_keys; ++i) { + for (size_t i = 0; i < num_keys; ++i) { const CurveKey &key = *curve.GetKey(i); // determine the KeyType based on the key's class @@ -227,7 +227,7 @@ void SerializeSkin(const Skin &skin, MemoryBuffer *output) { // Count up total number of individual influences size_t total_influence_count = 0; - for (int i = 0; i < influences_array_size; ++i) { + for (size_t i = 0; i < influences_array_size; ++i) { total_influence_count += influences_array[i].size(); } @@ -248,14 +248,14 @@ void SerializeSkin(const Skin &skin, MemoryBuffer *output) { // write out version stream.WriteLittleEndianInt32(1); - for (int i = 0; i < influences_array_size; ++i) { + for (size_t i = 0; i < influences_array_size; ++i) { const Skin::Influences &influences = influences_array[i]; // Write the influence count for this Influences object size_t influence_count = influences.size(); stream.WriteLittleEndianInt32(static_cast(influence_count)); - for (int j = 0; j < influence_count; ++j) { + for (size_t j = 0; j < influence_count; ++j) { const Skin::Influence &influence = influences[j]; stream.WriteLittleEndianInt32(influence.matrix_index); stream.WriteLittleEndianFloat32(influence.weight); diff --git a/o3d/svn_paths.scons b/o3d/svn_paths.scons index ad3957c..019a618 100644 --- a/o3d/svn_paths.scons +++ b/o3d/svn_paths.scons @@ -74,7 +74,7 @@ env.Replace( SELENIUM_JAVA_DIR = '$THIRD_PARTY/java/selenium/rev2478_mod', SELENIUM_PYTHON_DIR = '$THIRD_PARTY/py/selenium', # TODO: pull from SVN with gclient ? - SKIA_DIR = '$THIRD_PARTY/skia/files', + SKIA_DIR = '$THIRD_PARTY/skia', # TODO: pull from SVN with gclient ? V8_SRC_DIR = '$THIRD_PARTY/v8', WIX_DIR = '$THIRD_PARTY/wix_2_0_4221/files', -- cgit v1.1