Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(885)

Side by Side Diff: Source/platform/graphics/GraphicsContextRecorder.cpp

Issue 290893002: [wip] Add canvas.toDataURL("image/png") compression control Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update after https://src.chromium.org/viewvc/blink?view=rev&revision=175387 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 default: 707 default:
708 ASSERT_NOT_REACHED(); 708 ASSERT_NOT_REACHED();
709 return "?"; 709 return "?";
710 }; 710 };
711 } 711 }
712 712
713 PassRefPtr<JSONObject> objectForBitmapData(const SkBitmap& bitmap) 713 PassRefPtr<JSONObject> objectForBitmapData(const SkBitmap& bitmap)
714 { 714 {
715 RefPtr<JSONObject> dataItem = JSONObject::create(); 715 RefPtr<JSONObject> dataItem = JSONObject::create();
716 Vector<unsigned char> output; 716 Vector<unsigned char> output;
717 WebCore::PNGImageEncoder::encode(bitmap, &output); 717 int compressionQuality = PNGImageEncoder::DefaultCompressionQuality;
718 WebCore::PNGImageEncoder::encode(bitmap, compressionQuality, &output);
718 dataItem->setString("base64", WTF::base64Encode(reinterpret_cast<char*>( output.data()), output.size())); 719 dataItem->setString("base64", WTF::base64Encode(reinterpret_cast<char*>( output.data()), output.size()));
719 dataItem->setString("mimeType", "image/png"); 720 dataItem->setString("mimeType", "image/png");
720 return dataItem.release(); 721 return dataItem.release();
721 } 722 }
722 723
723 PassRefPtr<JSONObject> objectForSkBitmap(const SkBitmap& bitmap) 724 PassRefPtr<JSONObject> objectForSkBitmap(const SkBitmap& bitmap)
724 { 725 {
725 RefPtr<JSONObject> bitmapItem = JSONObject::create(); 726 RefPtr<JSONObject> bitmapItem = JSONObject::create();
726 bitmapItem->setNumber("width", bitmap.width()); 727 bitmapItem->setNumber("width", bitmap.width());
727 bitmapItem->setNumber("height", bitmap.height()); 728 bitmapItem->setNumber("height", bitmap.height());
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 1036
1036 PassRefPtr<JSONArray> GraphicsContextSnapshot::snapshotCommandLog() const 1037 PassRefPtr<JSONArray> GraphicsContextSnapshot::snapshotCommandLog() const
1037 { 1038 {
1038 LoggingCanvas canvas; 1039 LoggingCanvas canvas;
1039 FragmentSnapshotPlayer player(m_picture, &canvas); 1040 FragmentSnapshotPlayer player(m_picture, &canvas);
1040 player.play(0, 0); 1041 player.play(0, 0);
1041 return canvas.log(); 1042 return canvas.log();
1042 } 1043 }
1043 1044
1044 } 1045 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/canvas/canvas-toDataURL-png-compression-expected.txt ('k') | Source/platform/graphics/ImageBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698