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

Side by Side Diff: sky/engine/core/frame/ImageBitmapTest.cpp

Issue 1001913003: Remove <canvas> (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « sky/engine/core/frame/ImageBitmap.cpp ('k') | sky/engine/core/html/HTMLCanvasElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "sky/engine/config.h" 31 #include "sky/engine/config.h"
32 #include "sky/engine/core/frame/ImageBitmap.h" 32 #include "sky/engine/core/frame/ImageBitmap.h"
33 33
34 #include "sky/engine/core/dom/Document.h" 34 #include "sky/engine/core/dom/Document.h"
35 #include "sky/engine/core/fetch/ImageResource.h" 35 #include "sky/engine/core/fetch/ImageResource.h"
36 #include "sky/engine/core/fetch/MemoryCache.h" 36 #include "sky/engine/core/fetch/MemoryCache.h"
37 #include "sky/engine/core/fetch/MockImageResourceClient.h" 37 #include "sky/engine/core/fetch/MockImageResourceClient.h"
38 #include "sky/engine/core/fetch/ResourcePtr.h" 38 #include "sky/engine/core/fetch/ResourcePtr.h"
39 #include "sky/engine/core/html/HTMLCanvasElement.h"
40 #include "sky/engine/core/html/HTMLImageElement.h" 39 #include "sky/engine/core/html/HTMLImageElement.h"
41 #include "sky/engine/core/html/canvas/CanvasRenderingContext2D.h"
42 #include "sky/engine/platform/graphics/BitmapImage.h" 40 #include "sky/engine/platform/graphics/BitmapImage.h"
43 #include "sky/engine/platform/graphics/skia/NativeImageSkia.h" 41 #include "sky/engine/platform/graphics/skia/NativeImageSkia.h"
44 #include "sky/engine/platform/heap/Handle.h" 42 #include "sky/engine/platform/heap/Handle.h"
45 #include "sky/engine/platform/network/ResourceRequest.h" 43 #include "sky/engine/platform/network/ResourceRequest.h"
46 #include "sky/engine/wtf/OwnPtr.h" 44 #include "sky/engine/wtf/OwnPtr.h"
47 #include "third_party/skia/include/core/SkPixelRef.h" 45 #include "third_party/skia/include/core/SkPixelRef.h"
48 46
49 #include <gtest/gtest.h> 47 #include <gtest/gtest.h>
50 48
51 namespace blink { 49 namespace blink {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // The ImageBitmap should contain the same data as the original cached image but should no longer hold a reference. 177 // The ImageBitmap should contain the same data as the original cached image but should no longer hold a reference.
180 ASSERT_NE(imageBitmap->bitmapImage().get(), originalImageResource->image()); 178 ASSERT_NE(imageBitmap->bitmapImage().get(), originalImageResource->image());
181 ASSERT_EQ(imageBitmap->bitmapImage()->nativeImageForCurrentFrame()->bitmap() .pixelRef()->pixels(), 179 ASSERT_EQ(imageBitmap->bitmapImage()->nativeImageForCurrentFrame()->bitmap() .pixelRef()->pixels(),
182 originalImageResource->image()->nativeImageForCurrentFrame()->bitmap().p ixelRef()->pixels()); 180 originalImageResource->image()->nativeImageForCurrentFrame()->bitmap().p ixelRef()->pixels());
183 181
184 ASSERT_NE(imageBitmap->bitmapImage().get(), newImageResource->image()); 182 ASSERT_NE(imageBitmap->bitmapImage().get(), newImageResource->image());
185 ASSERT_NE(imageBitmap->bitmapImage()->nativeImageForCurrentFrame()->bitmap() .pixelRef()->pixels(), 183 ASSERT_NE(imageBitmap->bitmapImage()->nativeImageForCurrentFrame()->bitmap() .pixelRef()->pixels(),
186 newImageResource->image()->nativeImageForCurrentFrame()->bitmap().pixelR ef()->pixels()); 184 newImageResource->image()->nativeImageForCurrentFrame()->bitmap().pixelR ef()->pixels());
187 } 185 }
188 186
189 // Verifies that ImageBitmaps constructed from ImageBitmaps hold onto their own Image.
190 TEST_F(ImageBitmapTest, ImageResourceLifetime)
191 {
192 RefPtr<HTMLCanvasElement> canvasElement = HTMLCanvasElement::create(*Documen t::create().get());
193 canvasElement->setHeight(40);
194 canvasElement->setWidth(40);
195 RefPtr<ImageBitmap> imageBitmapDerived = nullptr;
196 {
197 RefPtr<ImageBitmap> imageBitmapFromCanvas = ImageBitmap::create(canvasEl ement.get(), IntRect(0, 0, canvasElement->width(), canvasElement->height()));
198 imageBitmapDerived = ImageBitmap::create(imageBitmapFromCanvas.get(), In tRect(0, 0, 20, 20));
199 }
200 CanvasRenderingContext* context = canvasElement->getContext("2d");
201 TrackExceptionState exceptionState;
202 toCanvasRenderingContext2D(context)->drawImage(imageBitmapDerived.get(), 0, 0, exceptionState);
203 }
204
205 } // namespace 187 } // namespace
OLDNEW
« no previous file with comments | « sky/engine/core/frame/ImageBitmap.cpp ('k') | sky/engine/core/html/HTMLCanvasElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698