diff options
author | Android Chromium Automerger <chromium-automerger@android> | 2013-12-12 13:40:05 +0000 |
---|---|---|
committer | Android Chromium Automerger <chromium-automerger@android> | 2013-12-12 13:40:05 +0000 |
commit | c7b485d522cbbc645a353daaeebc05b3f0561f87 (patch) | |
tree | 30a293e4715323cbfc79a42f2e1474955d81e1d6 | |
parent | 24df3e66d89fff6e91ba76a9fe1a4f1e7c413402 (diff) | |
parent | a040d0e00417f765cd9d25b9c70694e4b818d77c (diff) | |
download | src-c7b485d522cbbc645a353daaeebc05b3f0561f87.tar.gz |
Merge third_party/skia/src from https://chromium.googlesource.com/external/skia/src.git at a040d0e00417f765cd9d25b9c70694e4b818d77c
This commit was generated by merge_from_chromium.py.
Change-Id: I76c06b9e74405376804c3b9e2936fcccc264fe49
-rw-r--r-- | core/SkBitmapFilter.cpp | 8 | ||||
-rw-r--r-- | core/SkBitmapProcState.cpp | 2 | ||||
-rw-r--r-- | core/SkPictureStateTree.cpp | 21 | ||||
-rw-r--r-- | core/SkPictureStateTree.h | 4 | ||||
-rw-r--r-- | core/SkScaledImageCache.cpp | 12 | ||||
-rw-r--r-- | lazy/SkDiscardableMemoryPool.h | 16 | ||||
-rw-r--r-- | pdf/SkPDFFont.cpp | 37 | ||||
-rw-r--r-- | ports/SkDiscardableMemory_ashmem.cpp | 1 |
8 files changed, 63 insertions, 38 deletions
diff --git a/core/SkBitmapFilter.cpp b/core/SkBitmapFilter.cpp index f0666254..8c11f7c4 100644 --- a/core/SkBitmapFilter.cpp +++ b/core/SkBitmapFilter.cpp @@ -40,14 +40,14 @@ void highQualityFilter(ColorPacker pack, const SkBitmapProcState& s, int x, int SkScalar fr = 0, fg = 0, fb = 0, fa = 0; int y0 = SkClampMax(SkScalarCeilToInt(srcPt.fY-s.getBitmapFilter()->width()), maxY); - int y1 = SkClampMax(SkScalarFloorToInt(srcPt.fY+s.getBitmapFilter()->width()), maxY); + int y1 = SkClampMax(SkScalarFloorToInt(srcPt.fY+s.getBitmapFilter()->width()+1), maxY); int x0 = SkClampMax(SkScalarCeilToInt(srcPt.fX-s.getBitmapFilter()->width()), maxX); - int x1 = SkClampMax(SkScalarFloorToInt(srcPt.fX+s.getBitmapFilter()->width()), maxX); + int x1 = SkClampMax(SkScalarFloorToInt(srcPt.fX+s.getBitmapFilter()->width())+1, maxX); - for (int srcY = y0; srcY <= y1; srcY++) { + for (int srcY = y0; srcY < y1; srcY++) { SkScalar yWeight = s.getBitmapFilter()->lookupScalar((srcPt.fY - srcY)); - for (int srcX = x0; srcX <= x1 ; srcX++) { + for (int srcX = x0; srcX < x1 ; srcX++) { SkScalar xWeight = s.getBitmapFilter()->lookupScalar((srcPt.fX - srcX)); SkScalar combined_weight = SkScalarMul(xWeight, yWeight); diff --git a/core/SkBitmapProcState.cpp b/core/SkBitmapProcState.cpp index c93a2b5c..39f6a780 100644 --- a/core/SkBitmapProcState.cpp +++ b/core/SkBitmapProcState.cpp @@ -409,8 +409,6 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { // platform-specific one might succeed, so it might be premature here // to fall back to bilerp. This needs thought. - SkASSERT(fInvType > SkMatrix::kTranslate_Mask); - if (!this->setBitmapFilterProcs()) { fFilterLevel = SkPaint::kLow_FilterLevel; } diff --git a/core/SkPictureStateTree.cpp b/core/SkPictureStateTree.cpp index 5f4ed934..2f3b943c 100644 --- a/core/SkPictureStateTree.cpp +++ b/core/SkPictureStateTree.cpp @@ -11,19 +11,16 @@ SkPictureStateTree::SkPictureStateTree() : fAlloc(2048) - , fRoot(NULL) , fLastRestoredNode(NULL) , fStateStack(sizeof(Draw), 16) { - SkMatrix* identity = static_cast<SkMatrix*>(fAlloc.allocThrow(sizeof(SkMatrix))); - identity->reset(); - fRoot = static_cast<Node*>(fAlloc.allocThrow(sizeof(Node))); - fRoot->fParent = NULL; - fRoot->fMatrix = identity; - fRoot->fFlags = Node::kSave_Flag; - fRoot->fOffset = 0; - fRoot->fLevel = 0; - fCurrentState.fNode = fRoot; - fCurrentState.fMatrix = identity; + fRootMatrix.reset(); + fRoot.fParent = NULL; + fRoot.fMatrix = &fRootMatrix; + fRoot.fFlags = Node::kSave_Flag; + fRoot.fOffset = 0; + fRoot.fLevel = 0; + fCurrentState.fNode = &fRoot; + fCurrentState.fMatrix = &fRootMatrix; *static_cast<Draw*>(fStateStack.push_back()) = fCurrentState; } @@ -78,7 +75,7 @@ void SkPictureStateTree::appendClip(uint32_t offset) { SkPictureStateTree::Iterator SkPictureStateTree::getIterator(const SkTDArray<void*>& draws, SkCanvas* canvas) { - return Iterator(draws, canvas, fRoot); + return Iterator(draws, canvas, &fRoot); } void SkPictureStateTree::appendNode(uint32_t offset) { diff --git a/core/SkPictureStateTree.h b/core/SkPictureStateTree.h index 9d8bcf86..87529586 100644 --- a/core/SkPictureStateTree.h +++ b/core/SkPictureStateTree.h @@ -115,7 +115,6 @@ private: void appendNode(uint32_t offset); SkChunkAlloc fAlloc; - Node* fRoot; // Needed by saveCollapsed() because nodes do not currently store // references to their children. If they did, we could just retrieve the // last added child. @@ -140,6 +139,9 @@ private: }; }; + Node fRoot; + SkMatrix fRootMatrix; + typedef SkRefCnt INHERITED; }; diff --git a/core/SkScaledImageCache.cpp b/core/SkScaledImageCache.cpp index 5b166887..b3956f4a 100644 --- a/core/SkScaledImageCache.cpp +++ b/core/SkScaledImageCache.cpp @@ -209,6 +209,7 @@ private: SkDiscardableMemory* fDM; size_t fRB; bool fFirstTime; + bool fIsLocked; typedef SkPixelRef INHERITED; }; @@ -224,6 +225,7 @@ SkOneShotDiscardablePixelRef::SkOneShotDiscardablePixelRef(const SkImageInfo& in SkASSERT(dm->data()); fFirstTime = true; + fIsLocked = false; } SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() { @@ -236,12 +238,18 @@ void* SkOneShotDiscardablePixelRef::onLockPixels(SkColorTable** ctable) { fFirstTime = false; return fDM->data(); } - return fDM->lock() ? fDM->data() : NULL; + + SkASSERT(!fIsLocked); + fIsLocked = fDM->lock(); + return fIsLocked ? fDM->data() : NULL; } void SkOneShotDiscardablePixelRef::onUnlockPixels() { SkASSERT(!fFirstTime); - fDM->unlock(); + if (fIsLocked) { + fIsLocked = false; + fDM->unlock(); + } } size_t SkOneShotDiscardablePixelRef::getAllocatedSizeInBytes() const { diff --git a/lazy/SkDiscardableMemoryPool.h b/lazy/SkDiscardableMemoryPool.h index e9f3b04f..61bad701 100644 --- a/lazy/SkDiscardableMemoryPool.h +++ b/lazy/SkDiscardableMemoryPool.h @@ -12,6 +12,8 @@ #include "SkTInternalLList.h" #include "SkThread.h" +class SkPoolDiscardableMemory; + #ifdef SK_DEBUG #define LAZY_CACHE_STATS 1 #elif !defined(LAZY_CACHE_STATS) @@ -22,20 +24,22 @@ * This non-global pool can be used for unit tests to verify that the * pool works. */ -class SkPoolDiscardableMemory; class SkDiscardableMemoryPool : public SkDiscardableMemory::Factory { public: /** * Without mutex, will be not be thread safe. */ SkDiscardableMemoryPool(size_t budget, SkBaseMutex* mutex = NULL); - ~SkDiscardableMemoryPool(); - SkDiscardableMemory* create(size_t bytes) SK_OVERRIDE; + virtual ~SkDiscardableMemoryPool(); + + virtual SkDiscardableMemory* create(size_t bytes) SK_OVERRIDE; + size_t getRAMUsed(); void setRAMBudget(size_t budget); + /** purges all unlocked DMs */ void dumpPool(); - friend class SkPoolDiscardableMemory; + #if LAZY_CACHE_STATS int fCacheHits; int fCacheMisses; @@ -46,6 +50,7 @@ private: size_t fBudget; size_t fUsed; SkTInternalLList<SkPoolDiscardableMemory> fList; + /** Function called to free memory if needed */ void dumpDownTo(size_t budget); /** called by SkDiscardableMemoryPool upon destruction */ @@ -54,6 +59,9 @@ private: bool lock(SkPoolDiscardableMemory* dm); /** called by SkDiscardableMemoryPool::unlock() */ void unlock(SkPoolDiscardableMemory* dm); + + friend class SkPoolDiscardableMemory; + typedef SkDiscardableMemory::Factory INHERITED; }; diff --git a/pdf/SkPDFFont.cpp b/pdf/SkPDFFont.cpp index 1641a891..ef9c3bbc 100644 --- a/pdf/SkPDFFont.cpp +++ b/pdf/SkPDFFont.cpp @@ -460,7 +460,7 @@ static void append_bfrange_section(const SkTDArray<BFRange>& bfrange, // endbfchar endbfrange // // Adobe Technote 5014 said: "Code mappings (unlike codespace ranges) may -// overlap, but succeeding maps superceded preceding maps." +// overlap, but succeeding maps supersede preceding maps." // // In case of searching text in PDF, bfrange will have higher precedence so // typing char id 0x0014 in search box will get glyph id 0x0004 first. However, @@ -475,28 +475,35 @@ static void append_bfrange_section(const SkTDArray<BFRange>& bfrange, void append_cmap_sections(const SkTDArray<SkUnichar>& glyphToUnicode, const SkPDFGlyphSet* subset, SkDynamicMemoryWStream* cmap, + bool multiByteGlyphs, uint16_t firstGlyphID, uint16_t lastGlyphID); void append_cmap_sections(const SkTDArray<SkUnichar>& glyphToUnicode, const SkPDFGlyphSet* subset, SkDynamicMemoryWStream* cmap, + bool multiByteGlyphs, uint16_t firstGlyphID, uint16_t lastGlyphID) { if (glyphToUnicode.isEmpty()) { return; } + int glyphOffset = 0; + if (!multiByteGlyphs) { + glyphOffset = firstGlyphID - 1; + } SkTDArray<BFChar> bfcharEntries; SkTDArray<BFRange> bfrangeEntries; BFRange currentRangeEntry = {0, 0, 0}; bool rangeEmpty = true; - const int limit = SkMin32(lastGlyphID + 1, glyphToUnicode.count()); + const int limit = + SkMin32(lastGlyphID + 1, glyphToUnicode.count()) - glyphOffset; - for (int i = firstGlyphID; i < limit + 1; ++i) { + for (int i = firstGlyphID - glyphOffset; i < limit + 1; ++i) { bool inSubset = i < limit && - (subset == NULL || subset->has(i)); + (subset == NULL || subset->has(i + glyphOffset)); if (!rangeEmpty) { // PDF spec requires bfrange not changing the higher byte, // e.g. <1035> <10FF> <2222> is ok, but @@ -505,8 +512,8 @@ void append_cmap_sections(const SkTDArray<SkUnichar>& glyphToUnicode, i == currentRangeEntry.fEnd + 1 && i >> 8 == currentRangeEntry.fStart >> 8 && i < limit && - glyphToUnicode[i] == currentRangeEntry.fUnicode + i - - currentRangeEntry.fStart; + glyphToUnicode[i + glyphOffset] == + currentRangeEntry.fUnicode + i - currentRangeEntry.fStart; if (!inSubset || !inRange) { if (currentRangeEntry.fEnd > currentRangeEntry.fStart) { bfrangeEntries.push(currentRangeEntry); @@ -522,7 +529,7 @@ void append_cmap_sections(const SkTDArray<SkUnichar>& glyphToUnicode, currentRangeEntry.fEnd = i; if (rangeEmpty) { currentRangeEntry.fStart = i; - currentRangeEntry.fUnicode = glyphToUnicode[i]; + currentRangeEntry.fUnicode = glyphToUnicode[i + glyphOffset]; rangeEmpty = false; } } @@ -537,11 +544,16 @@ void append_cmap_sections(const SkTDArray<SkUnichar>& glyphToUnicode, static SkPDFStream* generate_tounicode_cmap( const SkTDArray<SkUnichar>& glyphToUnicode, const SkPDFGlyphSet* subset, + bool multiByteGlyphs, uint16_t firstGlyphID, uint16_t lastGlyphID) { SkDynamicMemoryWStream cmap; - append_tounicode_header(&cmap, firstGlyphID, lastGlyphID); - append_cmap_sections(glyphToUnicode, subset, &cmap, + if (multiByteGlyphs) { + append_tounicode_header(&cmap, firstGlyphID, lastGlyphID); + } else { + append_tounicode_header(&cmap, 1, lastGlyphID - firstGlyphID + 1); + } + append_cmap_sections(glyphToUnicode, subset, &cmap, multiByteGlyphs, firstGlyphID, lastGlyphID); append_cmap_footer(&cmap); SkAutoTUnref<SkMemoryStream> cmapStream(new SkMemoryStream()); @@ -1027,7 +1039,8 @@ void SkPDFFont::populateToUnicodeTable(const SkPDFGlyphSet* subset) { } SkAutoTUnref<SkPDFStream> pdfCmap( generate_tounicode_cmap(fFontInfo->fGlyphToUnicode, subset, - firstGlyphID(), lastGlyphID())); + multiByteGlyphs(), firstGlyphID(), + lastGlyphID())); addResource(pdfCmap.get()); insert("ToUnicode", new SkPDFObjRef(pdfCmap.get()))->unref(); } @@ -1420,8 +1433,8 @@ bool SkPDFType3Font::populate(int16_t glyphID) { } insert("FontBBox", makeFontBBox(bbox, 1000))->unref(); - insertInt("FirstChar", firstGlyphID()); - insertInt("LastChar", lastGlyphID()); + insertInt("FirstChar", 1); + insertInt("LastChar", lastGlyphID() - firstGlyphID() + 1); insert("Widths", widthArray.get()); insertName("CIDToGIDMap", "Identity"); diff --git a/ports/SkDiscardableMemory_ashmem.cpp b/ports/SkDiscardableMemory_ashmem.cpp index 6f8684e3..e5e5f539 100644 --- a/ports/SkDiscardableMemory_ashmem.cpp +++ b/ports/SkDiscardableMemory_ashmem.cpp @@ -111,4 +111,3 @@ SkDiscardableMemory* SkDiscardableMemory::Create(size_t bytes) { return SkNEW_ARGS(SkAshmemDiscardableMemory, (fd, addr, size)); } - |