OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
588 pathPointItem->setArray("points", arrayForSkPoints(verbParams.pointCount , points + verbParams.pointOffset)); | 588 pathPointItem->setArray("points", arrayForSkPoints(verbParams.pointCount , points + verbParams.pointOffset)); |
589 if (SkPath::kConic_Verb == verb) | 589 if (SkPath::kConic_Verb == verb) |
590 pathPointItem->setNumber("conicWeight", iter.conicWeight()); | 590 pathPointItem->setNumber("conicWeight", iter.conicWeight()); |
591 pathPointsArray->pushObject(pathPointItem); | 591 pathPointsArray->pushObject(pathPointItem); |
592 } | 592 } |
593 pathItem->setArray("pathPoints", pathPointsArray); | 593 pathItem->setArray("pathPoints", pathPointsArray); |
594 pathItem->setObject("bounds", objectForSkRect(path.getBounds())); | 594 pathItem->setObject("bounds", objectForSkRect(path.getBounds())); |
595 return pathItem.release(); | 595 return pathItem.release(); |
596 } | 596 } |
597 | 597 |
598 String LoggingCanvas::configName(SkBitmap::Config config) | 598 String LoggingCanvas::colorTypeName(SkColorType colorType) |
599 { | 599 { |
600 switch (config) { | 600 switch (colorType) { |
601 case SkBitmap::kNo_Config: return "None"; | 601 case kUnknown_SkColorType: return "None"; |
602 case SkBitmap::kA8_Config: return "A8"; | 602 case kAlpha_8_SkColorType: return "A8"; |
603 case SkBitmap::kIndex8_Config: return "Index8"; | 603 case kIndex_8_SkColorType: return "Index8"; |
604 case SkBitmap::kRGB_565_Config: return "RGB565"; | 604 case kRGB_565_SkColorType: return "RGB565"; |
605 case SkBitmap::kARGB_4444_Config: return "ARGB4444"; | 605 case kARGB_4444_SkColorType: return "ARGB4444"; |
606 case SkBitmap::kARGB_8888_Config: return "ARGB8888"; | 606 case kN32_SkColorType: return "ARGB8888"; |
607 default: | 607 default: |
608 ASSERT_NOT_REACHED(); | 608 ASSERT_NOT_REACHED(); |
609 return "?"; | 609 return "?"; |
610 }; | 610 }; |
611 } | 611 } |
612 | 612 |
613 PassRefPtr<JSONObject> LoggingCanvas::objectForBitmapData(const SkBitmap& bitmap ) | 613 PassRefPtr<JSONObject> LoggingCanvas::objectForBitmapData(const SkBitmap& bitmap ) |
614 { | 614 { |
615 RefPtr<JSONObject> dataItem = JSONObject::create(); | 615 RefPtr<JSONObject> dataItem = JSONObject::create(); |
616 Vector<unsigned char> output; | 616 Vector<unsigned char> output; |
617 WebCore::PNGImageEncoder::encode(bitmap, &output); | 617 WebCore::PNGImageEncoder::encode(bitmap, &output); |
618 dataItem->setString("base64", WTF::base64Encode(reinterpret_cast<char*>(outp ut.data()), output.size())); | 618 dataItem->setString("base64", WTF::base64Encode(reinterpret_cast<char*>(outp ut.data()), output.size())); |
619 dataItem->setString("mimeType", "image/png"); | 619 dataItem->setString("mimeType", "image/png"); |
620 return dataItem.release(); | 620 return dataItem.release(); |
621 } | 621 } |
622 | 622 |
623 PassRefPtr<JSONObject> LoggingCanvas::objectForSkBitmap(const SkBitmap& bitmap) | 623 PassRefPtr<JSONObject> LoggingCanvas::objectForSkBitmap(const SkBitmap& bitmap) |
624 { | 624 { |
625 RefPtr<JSONObject> bitmapItem = JSONObject::create(); | 625 RefPtr<JSONObject> bitmapItem = JSONObject::create(); |
626 bitmapItem->setNumber("width", bitmap.width()); | 626 bitmapItem->setNumber("width", bitmap.width()); |
627 bitmapItem->setNumber("height", bitmap.height()); | 627 bitmapItem->setNumber("height", bitmap.height()); |
628 bitmapItem->setString("config", configName(bitmap.config())); | 628 bitmapItem->setString("colorType", colorTypeName(bitmap.colorType())); |
f(malita)
2014/07/09 13:56:51
Not sure whether it's safe to change the property
| |
629 bitmapItem->setBoolean("opaque", bitmap.isOpaque()); | 629 bitmapItem->setBoolean("opaque", bitmap.isOpaque()); |
630 bitmapItem->setBoolean("immutable", bitmap.isImmutable()); | 630 bitmapItem->setBoolean("immutable", bitmap.isImmutable()); |
631 bitmapItem->setBoolean("volatile", bitmap.isVolatile()); | 631 bitmapItem->setBoolean("volatile", bitmap.isVolatile()); |
632 bitmapItem->setNumber("genID", bitmap.getGenerationID()); | 632 bitmapItem->setNumber("genID", bitmap.getGenerationID()); |
633 bitmapItem->setObject("data", objectForBitmapData(bitmap)); | 633 bitmapItem->setObject("data", objectForBitmapData(bitmap)); |
634 return bitmapItem.release(); | 634 return bitmapItem.release(); |
635 } | 635 } |
636 | 636 |
637 PassRefPtr<JSONObject> LoggingCanvas::objectForSkShader(const SkShader& shader) | 637 PassRefPtr<JSONObject> LoggingCanvas::objectForSkShader(const SkShader& shader) |
638 { | 638 { |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
879 SkUnichar* textData = dataVector.data(); | 879 SkUnichar* textData = dataVector.data(); |
880 paint.glyphsToUnichars(static_cast<const uint16_t*>(text), byteLength / 2, textData); | 880 paint.glyphsToUnichars(static_cast<const uint16_t*>(text), byteLength / 2, textData); |
881 return WTF::UTF32LittleEndianEncoding().decode(reinterpret_cast<const ch ar*>(textData), byteLength * 2); | 881 return WTF::UTF32LittleEndianEncoding().decode(reinterpret_cast<const ch ar*>(textData), byteLength * 2); |
882 } | 882 } |
883 default: | 883 default: |
884 ASSERT_NOT_REACHED(); | 884 ASSERT_NOT_REACHED(); |
885 return "?"; | 885 return "?"; |
886 } | 886 } |
887 } | 887 } |
888 } | 888 } |
OLD | NEW |