diff options
author | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-23 21:35:54 +0000 |
---|---|---|
committer | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-23 21:35:54 +0000 |
commit | 840434d046cbaefb5a70875b7e364523c713c79b (patch) | |
tree | b55362ca094f48705624af7f6812964d1faeda1c /o3d/core | |
parent | f17863106dd6715f2c18b6fcccacd5f232f95831 (diff) | |
download | chromium_src-840434d046cbaefb5a70875b7e364523c713c79b.zip chromium_src-840434d046cbaefb5a70875b7e364523c713c79b.tar.gz chromium_src-840434d046cbaefb5a70875b7e364523c713c79b.tar.bz2 |
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
Diffstat (limited to 'o3d/core')
-rw-r--r-- | o3d/core/cross/canvas.cc | 2 | ||||
-rw-r--r-- | o3d/core/cross/canvas.h | 4 | ||||
-rw-r--r-- | o3d/core/cross/canvas_paint.cc | 125 | ||||
-rw-r--r-- | o3d/core/cross/canvas_paint.h | 2 | ||||
-rw-r--r-- | o3d/core/cross/canvas_shader.cc | 4 | ||||
-rw-r--r-- | o3d/core/cross/canvas_shader.h | 4 | ||||
-rw-r--r-- | o3d/core/cross/canvas_utils.h | 2 |
7 files changed, 127 insertions, 16 deletions
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) { |