Bug 1421655 - Renaming imgITools::decodeImageBuffer to imgITools::decodeImageFromBuffer, r=aosmond
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 30 Nov 2017 14:48:47 +0100
changeset 446146 75d2ae4d07c4a88a1fa5d695278c7e106a2e20c1
parent 446145 807297ac24456964acc0efcba2d642c28191109a
child 446147 99667f7d7386bb2445f45bf88faad3c73e1cac1b
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond
bugs1421655
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1421655 - Renaming imgITools::decodeImageBuffer to imgITools::decodeImageFromBuffer, r=aosmond
devtools/client/inspector/test/browser_inspector_menu-01-sensitivity.js
image/imgITools.idl
image/imgTools.cpp
image/test/unit/test_imgtools.js
toolkit/components/places/nsFaviconService.cpp
widget/windows/WinUtils.cpp
--- a/devtools/client/inspector/test/browser_inspector_menu-01-sensitivity.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-01-sensitivity.js
@@ -305,17 +305,17 @@ function copyImageToClipboard(data) {
   let imageTools = Cc["@mozilla.org/image/tools;1"]
                      .getService(Ci.imgITools);
 
   // Image data is stored as base64 in the test.
   let image = atob(data);
 
   let imgPtr = Cc["@mozilla.org/supports-interface-pointer;1"]
                  .createInstance(Ci.nsISupportsInterfacePointer);
-  imgPtr.data = imageTools.decodeImageBuffer(image, image.length, "image/png");
+  imgPtr.data = imageTools.decodeImageFromBuffer(image, image.length, "image/png");
 
   let xferable = Cc["@mozilla.org/widget/transferable;1"]
                    .createInstance(Ci.nsITransferable);
   xferable.init(null);
   xferable.addDataFlavor("image/png");
   xferable.setTransferData("image/png", imgPtr, -1);
 
   clipboardService.setData(xferable, null, clipboardService.kGlobalClipboard);
--- a/image/imgITools.idl
+++ b/image/imgITools.idl
@@ -15,31 +15,31 @@ interface nsIDOMDocument;
 interface imgIScriptedNotificationObserver;
 interface imgINotificationObserver;
 interface imgIContainerCallback;
 
 [scriptable, builtinclass, uuid(4c2383a4-931c-484d-8c4a-973590f66e3f)]
 interface imgITools : nsISupports
 {
     /**
-     * decodeImageBuffer
+     * decodeImageFromBuffer
      * Caller provides an buffer, a buffer size and a mimetype. We read from
      * the stream and decompress it (according to the specified mime type) and
      * return the resulting imgIContainer.
      *
      * @param aBuffer
      *        Data in memory.
      * @param aSize
      *        Buffer size.
      * @param aMimeType
      *        Type of image in the stream.
      */
-    imgIContainer decodeImageBuffer(in string aBuffer,
-                                    in unsigned long aSize,
-                                    in ACString aMimeType);
+    imgIContainer decodeImageFromBuffer(in string aBuffer,
+                                        in unsigned long aSize,
+                                        in ACString aMimeType);
 
     /**
      * decodeImageFromArrayBuffer
      * Caller provides an ArrayBuffer and a mimetype. We read from
      * the stream and decompress it (according to the specified mime type) and
      * return the resulting imgIContainer.
      *
      * @param aArrayBuffer
--- a/image/imgTools.cpp
+++ b/image/imgTools.cpp
@@ -198,24 +198,24 @@ imgTools::DecodeImageFromArrayBuffer(JS:
   }
 
   uint8_t* bufferData = nullptr;
   uint32_t bufferLength = 0;
   bool isSharedMemory = false;
 
   js::GetArrayBufferLengthAndData(obj, &bufferLength, &isSharedMemory,
                                   &bufferData);
-  return DecodeImageBuffer((char*)bufferData, bufferLength, aMimeType,
-                           aContainer);
+  return DecodeImageFromBuffer((char*)bufferData, bufferLength, aMimeType,
+                               aContainer);
 }
 
 NS_IMETHODIMP
-imgTools::DecodeImageBuffer(const char* aBuffer, uint32_t aSize,
-                            const nsACString& aMimeType,
-                            imgIContainer** aContainer)
+imgTools::DecodeImageFromBuffer(const char* aBuffer, uint32_t aSize,
+                                const nsACString& aMimeType,
+                                imgIContainer** aContainer)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   NS_ENSURE_ARG_POINTER(aBuffer);
 
   // Create a new image container to hold the decoded data.
   nsAutoCString mimeType(aMimeType);
   RefPtr<image::Image> image =
--- a/image/test/unit/test_imgtools.js
+++ b/image/test/unit/test_imgtools.js
@@ -143,17 +143,18 @@ testdesc = "test decoding a PNG";
 var imgName = "image1.png";
 var inMimeType = "image/png";
 var imgFile = do_get_file(imgName);
 
 var istream = getFileInputStream(imgFile);
 do_check_eq(istream.available(), 8415);
 
 var buffer = NetUtil.readInputStreamToString(istream, istream.available());
-var container = imgTools.decodeImageBuffer(buffer, buffer.length, inMimeType);
+var container = imgTools.decodeImageFromBuffer(buffer, buffer.length,
+                                               inMimeType);
 
 // It's not easy to look at the pixel values from JS, so just
 // check the container's size.
 do_check_eq(container.width,  64);
 do_check_eq(container.height, 64);
 
 
 /* ========== 2 ========== */
@@ -202,17 +203,17 @@ testdesc = "test decoding a JPEG";
 imgName = "image2.jpg";
 inMimeType = "image/jpeg";
 imgFile = do_get_file(imgName);
 
 istream = getFileInputStream(imgFile);
 do_check_eq(istream.available(), 3494);
 
 buffer = NetUtil.readInputStreamToString(istream, istream.available());
-container = imgTools.decodeImageBuffer(buffer, buffer.length, inMimeType);
+container = imgTools.decodeImageFromBuffer(buffer, buffer.length, inMimeType);
 
 // It's not easy to look at the pixel values from JS, so just
 // check the container's size.
 do_check_eq(container.width,  32);
 do_check_eq(container.height, 32);
 
 
 /* ========== 5 ========== */
@@ -265,17 +266,17 @@ testdesc = "test decoding a ICO";
 imgName = "image3.ico";
 inMimeType = "image/x-icon";
 imgFile = do_get_file(imgName);
 
 istream = getFileInputStream(imgFile);
 do_check_eq(istream.available(), 1406);
 
 buffer = NetUtil.readInputStreamToString(istream, istream.available());
-container = imgTools.decodeImageBuffer(buffer, buffer.length, inMimeType);
+container = imgTools.decodeImageFromBuffer(buffer, buffer.length, inMimeType);
 
 // It's not easy to look at the pixel values from JS, so just
 // check the container's size.
 do_check_eq(container.width,  16);
 do_check_eq(container.height, 16);
 
 
 /* ========== 8 ========== */
@@ -324,17 +325,17 @@ testdesc = "test decoding a GIF";
 imgName = "image4.gif";
 inMimeType = "image/gif";
 imgFile = do_get_file(imgName);
 
 istream = getFileInputStream(imgFile);
 do_check_eq(istream.available(), 1809);
 
 buffer = NetUtil.readInputStreamToString(istream, istream.available());
-container = imgTools.decodeImageBuffer(buffer, buffer.length, inMimeType);
+container = imgTools.decodeImageFromBuffer(buffer, buffer.length, inMimeType);
 
 // It's not easy to look at the pixel values from JS, so just
 // check the container's size.
 do_check_eq(container.width, 32);
 do_check_eq(container.height, 32);
 
 /* ========== 11 ========== */
 testnum++;
@@ -433,17 +434,17 @@ testdesc = "test cropping a JPG";
 imgName = "image2.jpg";
 inMimeType = "image/jpeg";
 imgFile = do_get_file(imgName);
 
 istream = getFileInputStream(imgFile);
 do_check_eq(istream.available(), 3494);
 
 buffer = NetUtil.readInputStreamToString(istream, istream.available());
-container = imgTools.decodeImageBuffer(buffer, buffer.length, inMimeType);
+container = imgTools.decodeImageFromBuffer(buffer, buffer.length, inMimeType);
 
 // It's not easy to look at the pixel values from JS, so just
 // check the container's size.
 do_check_eq(container.width,  32);
 do_check_eq(container.height, 32);
 
 // encode a cropped image
 istream = imgTools.encodeCroppedImage(container, "image/jpeg", 0, 0, 16, 16);
@@ -652,18 +653,18 @@ for(var i=0; i<testData.length; ++i) {
     var imgFile = do_get_file(dict["refImage"]);
     var istream = getFileInputStream(imgFile);
     var refBytes = streamToArray(istream);
 
     imgFile = do_get_file(dict["preImage"]);
     istream = getFileInputStream(imgFile);
 
     var buffer = NetUtil.readInputStreamToString(istream, istream.available());
-    var container = imgTools.decodeImageBuffer(buffer, buffer.length,
-                                               dict["preImageMimeType"]);
+    var container = imgTools.decodeImageFromBuffer(buffer, buffer.length,
+                                                   dict["preImageMimeType"]);
 
     istream = imgTools.encodeImage(container, dict["refImageMimeType"]);
 
     var sstream = Cc["@mozilla.org/storagestream;1"].
 	          createInstance(Ci.nsIStorageStream);
     sstream.init(4096, 4294967295, null);
     var ostream = sstream.getOutputStream(0);
     var bostream = Cc["@mozilla.org/network/buffered-output-stream;1"].
@@ -690,23 +691,23 @@ inMimeType = "image/x-icon";
 imgFile = do_get_file(imgName);
 
 istream = getFileInputStream(imgFile);
 do_check_eq(istream.available(), 17759);
 var errsrc = "none";
 
 try {
   buffer = NetUtil.readInputStreamToString(istream, istream.available());
-  container = imgTools.decodeImageBuffer(buffer, buffer.length, inMimeType);
+  container = imgTools.decodeImageFromBuffer(buffer, buffer.length, inMimeType);
 
   // We expect to hit an error during encoding because the ICO header of the
   // image is fine, but the actual resources are corrupt. Since
-  // decodeImageBuffer() only performs a metadata decode, it doesn't decode far
-  // enough to realize this, but we'll find out when we do a full decode during
-  // encodeImage().
+  // decodeImageFromBuffer() only performs a metadata decode, it doesn't decode
+  // far enough to realize this, but we'll find out when we do a full decode
+  // during encodeImage().
   try {
       istream = imgTools.encodeImage(container, "image/png");
   } catch (e) {
       err = e;
       errsrc = "encode";
   }
 } catch (e) {
   err = e;
@@ -724,17 +725,17 @@ testdesc = "test correct ico hotspots (b
 imgName = "bug815359.ico";
 inMimeType = "image/x-icon";
 imgFile = do_get_file(imgName);
 
 istream = getFileInputStream(imgFile);
 do_check_eq(istream.available(), 4286);
 
 buffer = NetUtil.readInputStreamToString(istream, istream.available());
-container = imgTools.decodeImageBuffer(buffer, buffer.length, inMimeType);
+container = imgTools.decodeImageFromBuffer(buffer, buffer.length, inMimeType);
 
 var props = container.QueryInterface(Ci.nsIProperties);
 
 do_check_eq(props.get("hotspotX", Ci.nsISupportsPRUint32).data, 10);
 do_check_eq(props.get("hotspotY", Ci.nsISupportsPRUint32).data, 9);
 
 
 /* ========== end ========== */
--- a/toolkit/components/places/nsFaviconService.cpp
+++ b/toolkit/components/places/nsFaviconService.cpp
@@ -815,20 +815,20 @@ nsFaviconService::OptimizeIconSizes(Icon
     return NS_OK;
   }
 
   // Make space for the optimized payloads.
   aIcon.payloads.Clear();
 
   // decode image
   nsCOMPtr<imgIContainer> container;
-  nsresult rv = GetImgTools()->DecodeImageBuffer(payload.data.get(),
-                                                 payload.data.Length(),
-                                                 payload.mimeType,
-                                                 getter_AddRefs(container));
+  nsresult rv = GetImgTools()->DecodeImageFromBuffer(payload.data.get(),
+                                                     payload.data.Length(),
+                                                     payload.mimeType,
+                                                     getter_AddRefs(container));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // For ICO files, we must evaluate each of the frames we care about.
   nsTArray<FrameData> framesInfo;
   rv = GetFramesInfoForContainer(container, framesInfo);
   NS_ENSURE_SUCCESS(rv, rv);
 
   for (const auto& frameInfo : framesInfo) {
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -1263,19 +1263,19 @@ AsyncFaviconDataReady::OnComplete(nsIURI
   
   nsAutoString path;
   rv = icoFile->GetPath(path);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Decode the image from the format it was returned to us in (probably PNG)
   nsCOMPtr<imgIContainer> container;
   nsCOMPtr<imgITools> imgtool = do_CreateInstance("@mozilla.org/image/tools;1");
-  rv = imgtool->DecodeImageBuffer(reinterpret_cast<const char*>(aData),
-                                  aDataLen, aMimeType,
-                                  getter_AddRefs(container));
+  rv = imgtool->DecodeImageFromBuffer(reinterpret_cast<const char*>(aData),
+                                      aDataLen, aMimeType,
+                                      getter_AddRefs(container));
   NS_ENSURE_SUCCESS(rv, rv);
 
   RefPtr<SourceSurface> surface =
     container->GetFrame(imgIContainer::FRAME_FIRST,
                         imgIContainer::FLAG_SYNC_DECODE |
                         imgIContainer::FLAG_ASYNC_NOTIFY);
   NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);