| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "platform/graphics/LoggingCanvas.h" | 32 #include "platform/graphics/LoggingCanvas.h" |
| 33 | 33 |
| 34 #include "platform/image-encoders/skia/PNGImageEncoder.h" | 34 #include "platform/image-encoders/skia/PNGImageEncoder.h" |
| 35 #include "third_party/skia/include/core/SkPicture.h" | 35 #include "third_party/skia/include/core/SkPicture.h" |
| 36 #include "wtf/HexNumber.h" | 36 #include "wtf/HexNumber.h" |
| 37 #include "wtf/text/Base64.h" | 37 #include "wtf/text/Base64.h" |
| 38 #include "wtf/text/TextEncoding.h" | 38 #include "wtf/text/TextEncoding.h" |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace blink { |
| 41 | 41 |
| 42 class AutoLogger { | 42 class AutoLogger { |
| 43 public: | 43 public: |
| 44 AutoLogger(LoggingCanvas*); | 44 AutoLogger(LoggingCanvas*); |
| 45 PassRefPtr<JSONObject> logItem(const String& name); | 45 PassRefPtr<JSONObject> logItem(const String& name); |
| 46 PassRefPtr<JSONObject> logItemWithParams(const String& name); | 46 PassRefPtr<JSONObject> logItemWithParams(const String& name); |
| 47 ~AutoLogger(); | 47 ~AutoLogger(); |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 LoggingCanvas* m_canvas; | 50 LoggingCanvas* m_canvas; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 blink::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()); |
| (...skipping 251 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 |