LCOV - code coverage report
Current view: top level - gfx/sfntly/cpp/src/sfntly/table/bitmap - bitmap_size_table.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 306 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 74 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2011 Google Inc. All Rights Reserved.
       3             :  *
       4             :  * Licensed under the Apache License, Version 2.0  = the "License");
       5             :  * you may not use this file except in compliance with the License.
       6             :  * You may obtain a copy of the License at
       7             :  *
       8             :  *      http://www.apache.org/licenses/LICENSE-2.0
       9             :  *
      10             :  * Unless required by applicable law or agreed to in writing, software
      11             :  * distributed under the License is distributed on an "AS IS" BASIS,
      12             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13             :  * See the License for the specific language governing permissions and
      14             :  * limitations under the License.
      15             :  */
      16             : 
      17             : #include "sfntly/table/bitmap/bitmap_size_table.h"
      18             : 
      19             : #include <stdio.h>
      20             : #include <stdlib.h>
      21             : 
      22             : #include "sfntly/math/font_math.h"
      23             : #include "sfntly/table/bitmap/eblc_table.h"
      24             : #include "sfntly/table/bitmap/index_sub_table_format1.h"
      25             : #include "sfntly/table/bitmap/index_sub_table_format2.h"
      26             : #include "sfntly/table/bitmap/index_sub_table_format3.h"
      27             : #include "sfntly/table/bitmap/index_sub_table_format4.h"
      28             : #include "sfntly/table/bitmap/index_sub_table_format5.h"
      29             : 
      30             : namespace sfntly {
      31             : /******************************************************************************
      32             :  * BitmapSizeTable class
      33             :  ******************************************************************************/
      34           0 : BitmapSizeTable::~BitmapSizeTable() {
      35           0 : }
      36             : 
      37           0 : int32_t BitmapSizeTable::IndexSubTableArrayOffset() {
      38           0 :   return data_->ReadULongAsInt(
      39           0 :       EblcTable::Offset::kBitmapSizeTable_indexSubTableArrayOffset);
      40             : }
      41             : 
      42           0 : int32_t BitmapSizeTable::IndexTableSize() {
      43           0 :   return data_->ReadULongAsInt(
      44           0 :       EblcTable::Offset::kBitmapSizeTable_indexTableSize);
      45             : }
      46             : 
      47           0 : int32_t BitmapSizeTable::NumberOfIndexSubTables() {
      48           0 :   return NumberOfIndexSubTables(data_, 0);
      49             : }
      50             : 
      51           0 : int32_t BitmapSizeTable::ColorRef() {
      52           0 :   return data_->ReadULongAsInt(EblcTable::Offset::kBitmapSizeTable_colorRef);
      53             : }
      54             : 
      55           0 : int32_t BitmapSizeTable::StartGlyphIndex() {
      56           0 :   return data_->ReadUShort(EblcTable::Offset::kBitmapSizeTable_startGlyphIndex);
      57             : }
      58             : 
      59           0 : int32_t BitmapSizeTable::EndGlyphIndex() {
      60           0 :   return data_->ReadUShort(EblcTable::Offset::kBitmapSizeTable_endGlyphIndex);
      61             : }
      62             : 
      63           0 : int32_t BitmapSizeTable::PpemX() {
      64           0 :   return data_->ReadByte(EblcTable::Offset::kBitmapSizeTable_ppemX);
      65             : }
      66             : 
      67           0 : int32_t BitmapSizeTable::PpemY() {
      68           0 :   return data_->ReadByte(EblcTable::Offset::kBitmapSizeTable_ppemY);
      69             : }
      70             : 
      71           0 : int32_t BitmapSizeTable::BitDepth() {
      72           0 :   return data_->ReadByte(EblcTable::Offset::kBitmapSizeTable_bitDepth);
      73             : }
      74             : 
      75           0 : int32_t BitmapSizeTable::FlagsAsInt() {
      76           0 :   return data_->ReadChar(EblcTable::Offset::kBitmapSizeTable_flags);
      77             : }
      78             : 
      79           0 : IndexSubTable* BitmapSizeTable::GetIndexSubTable(int32_t index) {
      80           0 :   IndexSubTableList* subtable_list = GetIndexSubTableList();
      81           0 :   if (index >= 0 && (size_t)index < subtable_list->size()) {
      82           0 :     return (*subtable_list)[index];
      83             :   }
      84           0 :   return NULL;
      85             : }
      86             : 
      87           0 : int32_t BitmapSizeTable::GlyphOffset(int32_t glyph_id) {
      88           0 :   IndexSubTable* subtable = SearchIndexSubTables(glyph_id);
      89           0 :   if (subtable == NULL) {
      90           0 :     return -1;
      91             :   }
      92           0 :   return subtable->GlyphOffset(glyph_id);
      93             : }
      94             : 
      95           0 : int32_t BitmapSizeTable::GlyphLength(int32_t glyph_id) {
      96           0 :   IndexSubTable* subtable = SearchIndexSubTables(glyph_id);
      97           0 :   if (subtable == NULL) {
      98           0 :     return -1;
      99             :   }
     100           0 :   return subtable->GlyphLength(glyph_id);
     101             : }
     102             : 
     103           0 : CALLER_ATTACH BitmapGlyphInfo* BitmapSizeTable::GlyphInfo(int32_t glyph_id) {
     104           0 :   IndexSubTable* sub_table = SearchIndexSubTables(glyph_id);
     105           0 :   if (sub_table == NULL) {
     106           0 :     return NULL;
     107             :   }
     108           0 :   return sub_table->GlyphInfo(glyph_id);
     109             : }
     110             : 
     111           0 : int32_t BitmapSizeTable::GlyphFormat(int32_t glyph_id) {
     112           0 :   IndexSubTable* subtable = SearchIndexSubTables(glyph_id);
     113           0 :   if (subtable == NULL) {
     114           0 :     return -1;
     115             :   }
     116           0 :   return subtable->image_format();
     117             : }
     118             : 
     119           0 : BitmapSizeTable::BitmapSizeTable(ReadableFontData* data,
     120           0 :                                  ReadableFontData* master_data)
     121           0 :     : SubTable(data, master_data) {
     122           0 : }
     123             : 
     124             : // static
     125           0 : int32_t BitmapSizeTable::NumberOfIndexSubTables(ReadableFontData* data,
     126             :                                                 int32_t table_offset) {
     127           0 :   return data->ReadULongAsInt(table_offset +
     128           0 :       EblcTable::Offset::kBitmapSizeTable_numberOfIndexSubTables);
     129             : }
     130             : 
     131           0 : IndexSubTable* BitmapSizeTable::SearchIndexSubTables(int32_t glyph_id) {
     132             :   // would be faster to binary search but too many size tables don't have
     133             :   // sorted subtables
     134             : #if (SFNTLY_BITMAPSIZE_USE_BINARY_SEARCH)
     135             :   return BinarySearchIndexSubTables(glyph_id);
     136             : #else
     137           0 :   return LinearSearchIndexSubTables(glyph_id);
     138             : #endif
     139             : }
     140             : 
     141           0 : IndexSubTable* BitmapSizeTable::LinearSearchIndexSubTables(int32_t glyph_id) {
     142           0 :   IndexSubTableList* subtable_list = GetIndexSubTableList();
     143           0 :   for (IndexSubTableList::iterator b = subtable_list->begin(),
     144           0 :                                    e = subtable_list->end(); b != e; b++) {
     145           0 :     if ((*b)->first_glyph_index() <= glyph_id &&
     146           0 :         (*b)->last_glyph_index() >= glyph_id) {
     147           0 :       return *b;
     148             :     }
     149             :   }
     150           0 :   return NULL;
     151             : }
     152             : 
     153           0 : IndexSubTable* BitmapSizeTable::BinarySearchIndexSubTables(int32_t glyph_id) {
     154           0 :   IndexSubTableList* subtable_list = GetIndexSubTableList();
     155           0 :   int32_t index = 0;
     156           0 :   int32_t bottom = 0;
     157           0 :   int32_t top = subtable_list->size();
     158           0 :   while (top != bottom) {
     159           0 :     index = (top + bottom) / 2;
     160           0 :     IndexSubTable* subtable = (*subtable_list)[index];
     161           0 :     if (glyph_id < subtable->first_glyph_index()) {
     162             :       // Location beow current location
     163           0 :       top = index;
     164             :     } else {
     165           0 :       if (glyph_id <= subtable->last_glyph_index()) {
     166           0 :         return subtable;
     167             :       } else {
     168           0 :         bottom = index + 1;
     169             :       }
     170             :     }
     171             :   }
     172           0 :   return NULL;
     173             : }
     174             : 
     175             : CALLER_ATTACH
     176           0 : IndexSubTable* BitmapSizeTable::CreateIndexSubTable(int32_t index) {
     177           0 :   return IndexSubTable::CreateIndexSubTable(master_read_data(),
     178             :                                             IndexSubTableArrayOffset(),
     179           0 :                                             index);
     180             : }
     181             : 
     182           0 : IndexSubTableList* BitmapSizeTable::GetIndexSubTableList() {
     183           0 :   AutoLock lock(index_subtables_lock_);
     184           0 :   if (index_subtables_.empty()) {
     185           0 :     for (int32_t i = 0; i < NumberOfIndexSubTables(); ++i) {
     186           0 :       IndexSubTablePtr table;
     187           0 :       table.Attach(CreateIndexSubTable(i));
     188           0 :       index_subtables_.push_back(table);
     189             :     }
     190             :   }
     191           0 :   return &index_subtables_;
     192             : }
     193             : 
     194             : /******************************************************************************
     195             :  * BitmapSizeTable::Builder class
     196             :  ******************************************************************************/
     197           0 : BitmapSizeTable::Builder::~Builder() {
     198           0 : }
     199             : 
     200             : CALLER_ATTACH
     201           0 : FontDataTable* BitmapSizeTable::Builder::SubBuildTable(ReadableFontData* data) {
     202           0 :   BitmapSizeTablePtr output = new BitmapSizeTable(data, master_read_data());
     203           0 :   return output.Detach();
     204             : }
     205             : 
     206           0 : void BitmapSizeTable::Builder::SubDataSet() {
     207           0 :   Revert();
     208           0 : }
     209             : 
     210           0 : int32_t BitmapSizeTable::Builder::SubDataSizeToSerialize() {
     211           0 :   IndexSubTableBuilderList* builders = IndexSubTableBuilders();
     212           0 :   if (builders->empty()) {
     213           0 :     return 0;
     214             :   }
     215           0 :   int32_t size = EblcTable::Offset::kBitmapSizeTableLength;
     216           0 :   bool variable = false;
     217           0 :   for (IndexSubTableBuilderList::iterator b = builders->begin(),
     218           0 :                                           e = builders->end(); b != e; b++) {
     219           0 :     size += EblcTable::Offset::kIndexSubTableEntryLength;
     220           0 :     int32_t sub_table_size = (*b)->SubDataSizeToSerialize();
     221           0 :     int32_t padding = FontMath::PaddingRequired(abs(sub_table_size),
     222           0 :                                                 DataSize::kULONG);
     223             : #if defined (SFNTLY_DEBUG_BITMAP)
     224             :     fprintf(stderr, "subtable size=%d\n", sub_table_size);
     225             : #endif
     226           0 :     variable = (sub_table_size > 0) ? variable : true;
     227           0 :     size += abs(sub_table_size) + padding;
     228             :   }
     229             : #if defined (SFNTLY_DEBUG_BITMAP)
     230             :   fprintf(stderr, "bitmap table size=%d\n", variable ? -size : size);
     231             : #endif
     232           0 :   return variable ? -size : size;
     233             : }
     234             : 
     235           0 : bool BitmapSizeTable::Builder::SubReadyToSerialize() {
     236           0 :   if (IndexSubTableBuilders()->empty()) {
     237           0 :     return false;
     238             :   }
     239           0 :   return true;
     240             : }
     241             : 
     242           0 : int32_t BitmapSizeTable::Builder::SubSerialize(WritableFontData* new_data) {
     243           0 :   SetNumberOfIndexSubTables(IndexSubTableBuilders()->size());
     244           0 :   int32_t size = InternalReadData()->CopyTo(new_data);
     245           0 :   return size;
     246             : }
     247             : 
     248             : CALLER_ATTACH BitmapSizeTable::Builder*
     249           0 : BitmapSizeTable::Builder::CreateBuilder(WritableFontData* data,
     250             :                                         ReadableFontData* master_data) {
     251             :   BitmapSizeTableBuilderPtr output =
     252           0 :       new BitmapSizeTable::Builder(data, master_data);
     253           0 :   return output.Detach();
     254             : }
     255             : 
     256             : CALLER_ATTACH BitmapSizeTable::Builder*
     257           0 : BitmapSizeTable::Builder::CreateBuilder(ReadableFontData* data,
     258             :                                         ReadableFontData* master_data) {
     259             :   BitmapSizeTableBuilderPtr output =
     260           0 :       new BitmapSizeTable::Builder(data, master_data);
     261           0 :   return output.Detach();
     262             : }
     263             : 
     264           0 : int32_t BitmapSizeTable::Builder::IndexSubTableArrayOffset() {
     265           0 :   return InternalReadData()->ReadULongAsInt(
     266           0 :       EblcTable::Offset::kBitmapSizeTable_indexSubTableArrayOffset);
     267             : }
     268             : 
     269           0 : void BitmapSizeTable::Builder::SetIndexSubTableArrayOffset(int32_t offset) {
     270           0 :   InternalWriteData()->WriteULong(
     271           0 :       EblcTable::Offset::kBitmapSizeTable_indexSubTableArrayOffset, offset);
     272           0 : }
     273             : 
     274           0 : int32_t BitmapSizeTable::Builder::IndexTableSize() {
     275           0 :   return InternalReadData()->ReadULongAsInt(
     276           0 :       EblcTable::Offset::kBitmapSizeTable_indexTableSize);
     277             : }
     278             : 
     279           0 : void BitmapSizeTable::Builder::SetIndexTableSize(int32_t size) {
     280           0 :   InternalWriteData()->WriteULong(
     281           0 :       EblcTable::Offset::kBitmapSizeTable_indexTableSize, size);
     282           0 : }
     283             : 
     284           0 : int32_t BitmapSizeTable::Builder::NumberOfIndexSubTables() {
     285           0 :   return GetIndexSubTableBuilders()->size();
     286             : }
     287             : 
     288           0 : int32_t BitmapSizeTable::Builder::ColorRef() {
     289           0 :   return InternalReadData()->ReadULongAsInt(
     290           0 :       EblcTable::Offset::kBitmapSizeTable_colorRef);
     291             : }
     292             : 
     293           0 : int32_t BitmapSizeTable::Builder::StartGlyphIndex() {
     294           0 :   return InternalReadData()->ReadUShort(
     295           0 :       EblcTable::Offset::kBitmapSizeTable_startGlyphIndex);
     296             : }
     297             : 
     298           0 : int32_t BitmapSizeTable::Builder::EndGlyphIndex() {
     299           0 :   return InternalReadData()->ReadUShort(
     300           0 :       EblcTable::Offset::kBitmapSizeTable_endGlyphIndex);
     301             : }
     302             : 
     303           0 : int32_t BitmapSizeTable::Builder::PpemX() {
     304           0 :   return InternalReadData()->ReadByte(
     305           0 :       EblcTable::Offset::kBitmapSizeTable_ppemX);
     306             : }
     307             : 
     308           0 : int32_t BitmapSizeTable::Builder::PpemY() {
     309           0 :   return InternalReadData()->ReadByte(
     310           0 :       EblcTable::Offset::kBitmapSizeTable_ppemY);
     311             : }
     312             : 
     313           0 : int32_t BitmapSizeTable::Builder::BitDepth() {
     314           0 :   return InternalReadData()->ReadByte(
     315           0 :       EblcTable::Offset::kBitmapSizeTable_bitDepth);
     316             : }
     317             : 
     318           0 : int32_t BitmapSizeTable::Builder::FlagsAsInt() {
     319           0 :   return InternalReadData()->ReadChar(
     320           0 :       EblcTable::Offset::kBitmapSizeTable_flags);
     321             : }
     322             : 
     323           0 : IndexSubTable::Builder* BitmapSizeTable::Builder::IndexSubTableBuilder(
     324             :     int32_t index) {
     325           0 :   IndexSubTableBuilderList* sub_table_list = GetIndexSubTableBuilders();
     326           0 :   return sub_table_list->at(index);
     327             : }
     328             : 
     329           0 : CALLER_ATTACH BitmapGlyphInfo* BitmapSizeTable::Builder::GlyphInfo(
     330             :     int32_t glyph_id) {
     331           0 :   IndexSubTable::Builder* sub_table = SearchIndexSubTables(glyph_id);
     332           0 :   if (sub_table == NULL) {
     333           0 :     return NULL;
     334             :   }
     335           0 :   return sub_table->GlyphInfo(glyph_id);
     336             : }
     337             : 
     338           0 : int32_t BitmapSizeTable::Builder::GlyphOffset(int32_t glyph_id) {
     339           0 :   IndexSubTable::Builder* subtable = SearchIndexSubTables(glyph_id);
     340           0 :   if (subtable == NULL) {
     341           0 :     return -1;
     342             :   }
     343           0 :   return subtable->GlyphOffset(glyph_id);
     344             : }
     345             : 
     346           0 : int32_t BitmapSizeTable::Builder::GlyphLength(int32_t glyph_id) {
     347           0 :   IndexSubTable::Builder* subtable = SearchIndexSubTables(glyph_id);
     348           0 :   if (subtable == NULL) {
     349           0 :     return -1;
     350             :   }
     351           0 :   return subtable->GlyphLength(glyph_id);
     352             : }
     353             : 
     354           0 : int32_t BitmapSizeTable::Builder::GlyphFormat(int32_t glyph_id) {
     355           0 :   IndexSubTable::Builder* subtable = SearchIndexSubTables(glyph_id);
     356           0 :   if (subtable == NULL) {
     357           0 :     return -1;
     358             :   }
     359           0 :   return subtable->image_format();
     360             : }
     361             : 
     362           0 : IndexSubTableBuilderList* BitmapSizeTable::Builder::IndexSubTableBuilders() {
     363           0 :   return GetIndexSubTableBuilders();
     364             : }
     365             : 
     366             : CALLER_ATTACH BitmapSizeTable::Builder::BitmapGlyphInfoIterator*
     367           0 : BitmapSizeTable::Builder::GetIterator() {
     368             :   Ptr<BitmapSizeTable::Builder::BitmapGlyphInfoIterator> output =
     369           0 :       new BitmapSizeTable::Builder::BitmapGlyphInfoIterator(this);
     370           0 :   return output.Detach();
     371             : }
     372             : 
     373           0 : void BitmapSizeTable::Builder::GenerateLocaMap(BitmapGlyphInfoMap* output) {
     374           0 :   assert(output);
     375           0 :   Ptr<BitmapSizeTable::Builder::BitmapGlyphInfoIterator> it;
     376           0 :   it.Attach(GetIterator());
     377           0 :   while (it->HasNext()) {
     378           0 :     BitmapGlyphInfoPtr info;
     379           0 :     info.Attach(it->Next());
     380           0 :     (*output)[info->glyph_id()] = info;
     381             :   }
     382           0 : }
     383             : 
     384           0 : void BitmapSizeTable::Builder::Revert() {
     385           0 :   index_sub_tables_.clear();
     386           0 :   set_model_changed(false);
     387           0 : }
     388             : 
     389           0 : BitmapSizeTable::Builder::Builder(WritableFontData* data,
     390           0 :                                   ReadableFontData* master_data)
     391           0 :     : SubTable::Builder(data, master_data) {
     392           0 : }
     393             : 
     394           0 : BitmapSizeTable::Builder::Builder(ReadableFontData* data,
     395           0 :                                   ReadableFontData* master_data)
     396           0 :     : SubTable::Builder(data, master_data) {
     397           0 : }
     398             : 
     399           0 : void BitmapSizeTable::Builder::SetNumberOfIndexSubTables(int32_t count) {
     400           0 :   InternalWriteData()->WriteULong(
     401           0 :       EblcTable::Offset::kBitmapSizeTable_numberOfIndexSubTables, count);
     402           0 : }
     403             : 
     404           0 : IndexSubTable::Builder* BitmapSizeTable::Builder::SearchIndexSubTables(
     405             :     int32_t glyph_id) {
     406             :   // would be faster to binary search but too many size tables don't have
     407             :   // sorted subtables
     408             : #if (SFNTLY_BITMAPSIZE_USE_BINARY_SEARCH)
     409             :   return BinarySearchIndexSubTables(glyph_id);
     410             : #else
     411           0 :   return LinearSearchIndexSubTables(glyph_id);
     412             : #endif
     413             : }
     414             : 
     415           0 : IndexSubTable::Builder* BitmapSizeTable::Builder::LinearSearchIndexSubTables(
     416             :     int32_t glyph_id) {
     417           0 :   IndexSubTableBuilderList* subtable_list = GetIndexSubTableBuilders();
     418           0 :   for (IndexSubTableBuilderList::iterator b = subtable_list->begin(),
     419           0 :                                           e = subtable_list->end();
     420             :                                           b != e; b++) {
     421           0 :     if ((*b)->first_glyph_index() <= glyph_id &&
     422           0 :         (*b)->last_glyph_index() >= glyph_id) {
     423           0 :       return *b;
     424             :     }
     425             :   }
     426           0 :   return NULL;
     427             : }
     428             : 
     429           0 : IndexSubTable::Builder* BitmapSizeTable::Builder::BinarySearchIndexSubTables(
     430             :     int32_t glyph_id) {
     431           0 :   IndexSubTableBuilderList* subtable_list = GetIndexSubTableBuilders();
     432           0 :   int32_t index = 0;
     433           0 :   int32_t bottom = 0;
     434           0 :   int32_t top = subtable_list->size();
     435           0 :   while (top != bottom) {
     436           0 :     index = (top + bottom) / 2;
     437           0 :     IndexSubTable::Builder* subtable = subtable_list->at(index);
     438           0 :     if (glyph_id < subtable->first_glyph_index()) {
     439             :       // Location beow current location
     440           0 :       top = index;
     441             :     } else {
     442           0 :       if (glyph_id <= subtable->last_glyph_index()) {
     443           0 :         return subtable;
     444             :       } else {
     445           0 :         bottom = index + 1;
     446             :       }
     447             :     }
     448             :   }
     449           0 :   return NULL;
     450             : }
     451             : 
     452           0 : IndexSubTableBuilderList* BitmapSizeTable::Builder::GetIndexSubTableBuilders() {
     453           0 :   if (index_sub_tables_.empty()) {
     454           0 :     Initialize(InternalReadData());
     455           0 :     set_model_changed();
     456             :   }
     457           0 :   return &index_sub_tables_;
     458             : }
     459             : 
     460           0 : void BitmapSizeTable::Builder::Initialize(ReadableFontData* data) {
     461           0 :   index_sub_tables_.clear();
     462           0 :   if (data) {
     463             :     int32_t number_of_index_subtables =
     464           0 :         BitmapSizeTable::NumberOfIndexSubTables(data, 0);
     465           0 :     index_sub_tables_.resize(number_of_index_subtables);
     466           0 :     for (int32_t i = 0; i < number_of_index_subtables; ++i) {
     467           0 :       index_sub_tables_[i].Attach(CreateIndexSubTableBuilder(i));
     468             :     }
     469             :   }
     470           0 : }
     471             : 
     472             : CALLER_ATTACH IndexSubTable::Builder*
     473           0 : BitmapSizeTable::Builder::CreateIndexSubTableBuilder(int32_t index) {
     474           0 :   return IndexSubTable::Builder::CreateBuilder(master_read_data(),
     475             :                                                IndexSubTableArrayOffset(),
     476           0 :                                                index);
     477             : }
     478             : 
     479             : /******************************************************************************
     480             :  * BitmapSizeTable::Builder::BitmapGlyphInfoIterator class
     481             :  ******************************************************************************/
     482           0 : BitmapSizeTable::Builder::BitmapGlyphInfoIterator::BitmapGlyphInfoIterator(
     483           0 :     BitmapSizeTable::Builder* container)
     484           0 :     : RefIterator<BitmapGlyphInfo, BitmapSizeTable::Builder>(container) {
     485           0 :   sub_table_iter_ = container->IndexSubTableBuilders()->begin();
     486           0 :   sub_table_glyph_info_iter_.Attach((*sub_table_iter_)->GetIterator());
     487           0 : }
     488             : 
     489           0 : bool BitmapSizeTable::Builder::BitmapGlyphInfoIterator::HasNext() {
     490           0 :   if (sub_table_glyph_info_iter_ && HasNext(sub_table_glyph_info_iter_)) {
     491           0 :     return true;
     492             :   }
     493           0 :   while (++sub_table_iter_ != container()->IndexSubTableBuilders()->end()) {
     494           0 :     sub_table_glyph_info_iter_.Attach((*sub_table_iter_)->GetIterator());
     495           0 :     if (HasNext(sub_table_glyph_info_iter_)) {
     496           0 :       return true;
     497             :     }
     498             :   }
     499           0 :   return false;
     500             : }
     501             : 
     502             : CALLER_ATTACH
     503           0 : BitmapGlyphInfo* BitmapSizeTable::Builder::BitmapGlyphInfoIterator::Next() {
     504           0 :   if (!HasNext()) {
     505             :     // Note: In C++, we do not throw exception when there's no element.
     506           0 :     return NULL;
     507             :   }
     508           0 :   return Next(sub_table_glyph_info_iter_);
     509             : }
     510             : 
     511           0 : bool BitmapSizeTable::Builder::BitmapGlyphInfoIterator::HasNext(
     512             :     BitmapGlyphInfoIter* iterator_base) {
     513           0 :   if (iterator_base) {
     514           0 :     switch (iterator_base->container_base()->index_format()) {
     515             :       case 1: {
     516             :         IndexSubTableFormat1::Builder::BitmapGlyphInfoIterator* it =
     517             :             down_cast<IndexSubTableFormat1::Builder::BitmapGlyphInfoIterator*>(
     518           0 :                 iterator_base);
     519           0 :         return it->HasNext();
     520             :       }
     521             : 
     522             :       case 2: {
     523             :         IndexSubTableFormat2::Builder::BitmapGlyphInfoIterator* it =
     524             :             down_cast<IndexSubTableFormat2::Builder::BitmapGlyphInfoIterator*>(
     525           0 :                 iterator_base);
     526           0 :         return it->HasNext();
     527             :       }
     528             : 
     529             :       case 3: {
     530             :         IndexSubTableFormat3::Builder::BitmapGlyphInfoIterator* it =
     531             :             down_cast<IndexSubTableFormat3::Builder::BitmapGlyphInfoIterator*>(
     532           0 :                 iterator_base);
     533           0 :         return it->HasNext();
     534             :       }
     535             : 
     536             :       case 4: {
     537             :         IndexSubTableFormat4::Builder::BitmapGlyphInfoIterator* it =
     538             :             down_cast<IndexSubTableFormat4::Builder::BitmapGlyphInfoIterator*>(
     539           0 :                 iterator_base);
     540           0 :         return it->HasNext();
     541             :       }
     542             : 
     543             :       case 5: {
     544             :         IndexSubTableFormat5::Builder::BitmapGlyphInfoIterator* it =
     545             :             down_cast<IndexSubTableFormat5::Builder::BitmapGlyphInfoIterator*>(
     546           0 :                 iterator_base);
     547           0 :         return it->HasNext();
     548             :       }
     549             : 
     550             :       default:
     551           0 :         break;
     552             :     }
     553             :   }
     554           0 :   return false;
     555             : }
     556             : 
     557             : CALLER_ATTACH
     558           0 : BitmapGlyphInfo* BitmapSizeTable::Builder::BitmapGlyphInfoIterator::Next(
     559             :     BitmapGlyphInfoIter* iterator_base) {
     560           0 :   if (iterator_base) {
     561           0 :     switch (iterator_base->container_base()->index_format()) {
     562             :       case 1: {
     563             :         IndexSubTableFormat1::Builder::BitmapGlyphInfoIterator* it =
     564             :             down_cast<IndexSubTableFormat1::Builder::BitmapGlyphInfoIterator*>(
     565           0 :                 iterator_base);
     566           0 :         return it->Next();
     567             :       }
     568             : 
     569             :       case 2: {
     570             :         IndexSubTableFormat2::Builder::BitmapGlyphInfoIterator* it =
     571             :             down_cast<IndexSubTableFormat2::Builder::BitmapGlyphInfoIterator*>(
     572           0 :                 iterator_base);
     573           0 :         return it->Next();
     574             :       }
     575             : 
     576             :       case 3: {
     577             :         IndexSubTableFormat3::Builder::BitmapGlyphInfoIterator* it =
     578             :             down_cast<IndexSubTableFormat3::Builder::BitmapGlyphInfoIterator*>(
     579           0 :                 iterator_base);
     580           0 :         return it->Next();
     581             :       }
     582             : 
     583             :       case 4: {
     584             :         IndexSubTableFormat4::Builder::BitmapGlyphInfoIterator* it =
     585             :             down_cast<IndexSubTableFormat4::Builder::BitmapGlyphInfoIterator*>(
     586           0 :                 iterator_base);
     587           0 :         return it->Next();
     588             :       }
     589             : 
     590             :       case 5: {
     591             :         IndexSubTableFormat5::Builder::BitmapGlyphInfoIterator* it =
     592             :             down_cast<IndexSubTableFormat5::Builder::BitmapGlyphInfoIterator*>(
     593           0 :                 iterator_base);
     594           0 :         return it->Next();
     595             :       }
     596             : 
     597             :       default:
     598           0 :         break;
     599             :     }
     600             :   }
     601           0 :   return NULL;
     602             : }
     603             : 
     604             : }  // namespace sfntly

Generated by: LCOV version 1.13