diff options
author | 2009-04-03 14:26:10 +0000 | |
---|---|---|
committer | 2009-04-03 14:26:10 +0000 | |
commit | 9c970453fd1cb6e9618e37c61507465772deca80 (patch) | |
tree | 5dfbc59e5cfd9283bf5e6b10b640fa28ea95326b /src | |
parent | 41bccf55b56d75ab0c0b3726dd64baba80ba7e90 (diff) |
import portability fixes from Chrome around floats
move porting functions for SkDebugf into /ports directory
git-svn-id: http://skia.googlecode.com/svn/trunk@147 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkDrawing.cpp | 36 | ||||
-rw-r--r-- | src/core/SkFP.h | 2 | ||||
-rw-r--r-- | src/core/core_files.mk | 1 | ||||
-rw-r--r-- | src/effects/SkEmbossMask.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkDebug_android.cpp (renamed from src/core/SkDebug_stdio.cpp) | 18 | ||||
-rw-r--r-- | src/ports/SkDebug_stdio.cpp | 33 | ||||
-rw-r--r-- | src/ports/ports_files.mk | 1 |
7 files changed, 54 insertions, 39 deletions
diff --git a/src/core/SkDrawing.cpp b/src/core/SkDrawing.cpp index 85f3175bdb..f54afcc1f4 100644 --- a/src/core/SkDrawing.cpp +++ b/src/core/SkDrawing.cpp @@ -1,28 +1,28 @@ -#include "SkDrawable.h" +#include "SkDrawing.h" #include "SkCanvas.h" -SkDrawable::SkDrawable() { +SkDrawing::SkDrawing() { fMatrix.reset(); fParent = fFirstChild = fNextSibling = fPrevSibling = NULL; } -SkDrawable::~SkDrawable() { +SkDrawing::~SkDrawing() { this->detachAllChildren(); } /////////////////////////////////////////////////////////////////////////////// -void SkDrawable::resetMatrix() { +void SkDrawing::resetMatrix() { fMatrix.reset(); } -void SkDrawable::getMatrix(SkMatrix* matrix) const { +void SkDrawing::getMatrix(SkMatrix* matrix) const { if (matrix) { *matrix = fMatrix; } } -void SkDrawable::setMatrix(const SkMatrix& matrix) { +void SkDrawing::setMatrix(const SkMatrix& matrix) { if (fMatrix != matrix) { this->inval(); fMatrix = matrix; @@ -30,7 +30,7 @@ void SkDrawable::setMatrix(const SkMatrix& matrix) { } } -void SkDrawable::draw(SkCanvas* canvas) { +void SkDrawing::draw(SkCanvas* canvas) { SkAutoCanvasRestore ar(canvas, false); canvas->save(SkCanvas::kMatrix_SaveFlag); canvas->concat(fMatrix); @@ -38,7 +38,7 @@ void SkDrawable::draw(SkCanvas* canvas) { this->onDraw(canvas); B2FIter iter(this); - SkDrawable* child; + SkDrawing* child; while ((child = iter.next()) != NULL) { child->draw(canvas); } @@ -46,8 +46,8 @@ void SkDrawable::draw(SkCanvas* canvas) { /////////////////////////////////////////////////////////////////////////////// -void SkDrawable::detachFromParent() { - SkDrawable* parent = fParent; +void SkDrawing::detachFromParent() { + SkDrawing* parent = fParent; if (NULL == parent) { return; @@ -55,7 +55,7 @@ void SkDrawable::detachFromParent() { this->inval(); - SkDrawable* next = NULL; + SkDrawing* next = NULL; if (fNextSibling != this) { // do we have any siblings fNextSibling->fPrevSibling = fPrevSibling; @@ -71,7 +71,7 @@ void SkDrawable::detachFromParent() { this->unref(); } -SkDrawable* SkDrawable::attachChildToBack(SkDrawable* child) { +SkDrawing* SkDrawing::attachChildToBack(SkDrawing* child) { SkASSERT(child != this); if (child == NULL || fFirstChild == child) { @@ -97,7 +97,7 @@ SkDrawable* SkDrawable::attachChildToBack(SkDrawable* child) { return child; } -SkDrawable* SkDrawable::attachChildToFront(SkDrawable* child) { +SkDrawing* SkDrawing::attachChildToFront(SkDrawing* child) { SkASSERT(child != this); if (child == NULL || fFirstChild && fFirstChild->fPrevSibling == child) { @@ -123,7 +123,7 @@ SkDrawable* SkDrawable::attachChildToFront(SkDrawable* child) { return child; } -void SkDrawable::detachAllChildren() { +void SkDrawing::detachAllChildren() { while (fFirstChild) { fFirstChild->detachFromParent(); } @@ -131,16 +131,16 @@ void SkDrawable::detachAllChildren() { /////////////////////////////////////////////////////////////////////////////// -SkDrawable::B2FIter::B2FIter(const SkDrawable* parent) { +SkDrawing::B2FIter::B2FIter(const SkDrawing* parent) { fFirstChild = parent ? parent->fFirstChild : NULL; fChild = fFirstChild; } -SkDrawable* SkDrawable::B2FIter::next() { - SkDrawable* curr = fChild; +SkDrawing* SkDrawing::B2FIter::next() { + SkDrawing* curr = fChild; if (fChild) { - SkDrawable* next = fChild->fNextSibling; + SkDrawing* next = fChild->fNextSibling; if (next == fFirstChild) { next = NULL; } diff --git a/src/core/SkFP.h b/src/core/SkFP.h index 5e25d22372..3aab411ace 100644 --- a/src/core/SkFP.h +++ b/src/core/SkFP.h @@ -41,7 +41,7 @@ #define SkFPDivInt(a, n) ((a) / (n)) #define SkFPInvert(x) SkScalarInvert(x) #define SkFPSqrt(x) SkScalarSqrt(x) - #define SkFPCubeRoot(x) static_cast<float>(pow(x, 0.33333333333)) + #define SkFPCubeRoot(x) sk_float_pow(x, 0.3333333f) #define SkFPLT(a, b) ((a) < (b)) #define SkFPLE(a, b) ((a) <= (b)) diff --git a/src/core/core_files.mk b/src/core/core_files.mk index 37c55e1800..27849e7021 100644 --- a/src/core/core_files.mk +++ b/src/core/core_files.mk @@ -27,7 +27,6 @@ SOURCE := \ SkCordic.cpp \ SkCubicClipper.cpp \ SkDebug.cpp \ - SkDebug_stdio.cpp \ SkDeque.cpp \ SkDevice.cpp \ SkDither.cpp \ diff --git a/src/effects/SkEmbossMask.cpp b/src/effects/SkEmbossMask.cpp index 28e38a142f..fd11f543b0 100644 --- a/src/effects/SkEmbossMask.cpp +++ b/src/effects/SkEmbossMask.cpp @@ -75,7 +75,7 @@ void SkEmbossMask_BuildTable() if ((dy & 15) == 0) ::fprintf(file, "\t"); - U16 value = SkToU16((1 << 15) / SkSqrt32(dx * dx + dy * dy + kDelta*kDelta/4)); + uint16_t value = SkToU16((1 << 15) / SkSqrt32(dx * dx + dy * dy + kDelta*kDelta/4)); ::fprintf(file, "0x%04X", value); if (dx * 128 + dy < 128*128-1) diff --git a/src/core/SkDebug_stdio.cpp b/src/ports/SkDebug_android.cpp index c8a0d8123e..f1fd34f004 100644 --- a/src/core/SkDebug_stdio.cpp +++ b/src/ports/SkDebug_android.cpp @@ -19,8 +19,6 @@ static const size_t kBufferSize = 256; -#ifdef ANDROID - #define LOG_TAG "skia" #include <utils/Log.h> @@ -42,20 +40,4 @@ void Android_SkDebugf(const char* file, int line, const char* function, va_end(args); } -#else - -#include <stdarg.h> -#include <stdio.h> - -void SkDebugf(const char format[], ...) -{ - char buffer[kBufferSize + 1]; - va_list args; - va_start(args, format); - vsnprintf(buffer, kBufferSize, format, args); - va_end(args); - fprintf(stderr, buffer); -} - -#endif diff --git a/src/ports/SkDebug_stdio.cpp b/src/ports/SkDebug_stdio.cpp new file mode 100644 index 0000000000..f5bf687644 --- /dev/null +++ b/src/ports/SkDebug_stdio.cpp @@ -0,0 +1,33 @@ +/* libs/corecg/SkDebug_stdio.cpp +** +** Copyright 2006, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#include "SkTypes.h" + +static const size_t kBufferSize = 256; + +#include <stdarg.h> +#include <stdio.h> + +void SkDebugf(const char format[], ...) { + char buffer[kBufferSize + 1]; + va_list args; + va_start(args, format); + vsnprintf(buffer, kBufferSize, format, args); + va_end(args); + fprintf(stderr, buffer); +} + diff --git a/src/ports/ports_files.mk b/src/ports/ports_files.mk index 07dacfa244..8760ae11f5 100644 --- a/src/ports/ports_files.mk +++ b/src/ports/ports_files.mk @@ -1,4 +1,5 @@ SOURCE := \ + SkDebug_stdio.cpp \ SkFontHost_none.cpp \ SkGlobals_global.cpp \ SkOSFile_stdio.cpp \ |