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

Unified Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp

Issue 2764633002: cc/paint: Remove cc::PaintSurface. (Closed)
Patch Set: fix for relanding Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp
index 131c29af807d31bd6c51a3791869e33014b35a1c..26e846c95eeef3a277f0f84b7f09433fcb5ba7a9 100644
--- a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp
@@ -34,7 +34,6 @@
#include "platform/graphics/paint/PaintCanvas.h"
#include "platform/graphics/paint/PaintRecord.h"
#include "platform/graphics/paint/PaintRecorder.h"
-#include "platform/graphics/paint/PaintSurface.h"
#include "platform/graphics/test/MockImageDecoder.h"
#include "public/platform/Platform.h"
#include "public/platform/WebThread.h"
@@ -109,8 +108,8 @@ class DeferredImageDecoderTest : public ::testing::Test,
m_actualDecoder = decoder.get();
m_actualDecoder->setSize(1, 1);
m_lazyDecoder = DeferredImageDecoder::createForTesting(std::move(decoder));
- m_surface = PaintSurface::MakeRasterN32Premul(100, 100);
- ASSERT_TRUE(m_surface.get());
+ m_bitmap.allocPixels(SkImageInfo::MakeN32Premul(100, 100));
+ m_canvas = base::MakeUnique<cc::SkiaPaintCanvas>(m_bitmap);
m_decodeRequestCount = 0;
m_repetitionCount = cAnimationNone;
m_status = ImageFrame::FrameComplete;
@@ -143,7 +142,8 @@ class DeferredImageDecoderTest : public ::testing::Test,
// Don't own this but saves the pointer to query states.
MockImageDecoder* m_actualDecoder;
std::unique_ptr<DeferredImageDecoder> m_lazyDecoder;
- sk_sp<PaintSurface> m_surface;
+ SkBitmap m_bitmap;
+ std::unique_ptr<cc::PaintCanvas> m_canvas;
int m_decodeRequestCount;
RefPtr<SharedBuffer> m_data;
size_t m_frameCount;
@@ -166,14 +166,11 @@ TEST_F(DeferredImageDecoderTest, drawIntoPaintRecord) {
sk_sp<PaintRecord> record = recorder.finishRecordingAsPicture();
EXPECT_EQ(0, m_decodeRequestCount);
- m_surface->getCanvas()->drawPicture(record);
+ m_canvas->drawPicture(record);
EXPECT_EQ(0, m_decodeRequestCount);
- SkBitmap canvasBitmap;
- canvasBitmap.allocN32Pixels(100, 100);
- ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0));
- SkAutoLockPixels autoLock(canvasBitmap);
- EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0));
+ SkAutoLockPixels autoLock(m_bitmap);
+ EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), m_bitmap.getColor(0, 0));
}
TEST_F(DeferredImageDecoderTest, drawIntoPaintRecordProgressive) {
@@ -187,7 +184,7 @@ TEST_F(DeferredImageDecoderTest, drawIntoPaintRecordProgressive) {
PaintRecorder recorder;
PaintCanvas* tempCanvas = recorder.beginRecording(100, 100);
tempCanvas->drawImage(std::move(image), 0, 0);
- m_surface->getCanvas()->drawPicture(recorder.finishRecordingAsPicture());
+ m_canvas->drawPicture(recorder.finishRecordingAsPicture());
// Fully received the file and draw the PaintRecord again.
m_lazyDecoder->setData(m_data, true);
@@ -195,13 +192,10 @@ TEST_F(DeferredImageDecoderTest, drawIntoPaintRecordProgressive) {
ASSERT_TRUE(image);
tempCanvas = recorder.beginRecording(100, 100);
tempCanvas->drawImage(std::move(image), 0, 0);
- m_surface->getCanvas()->drawPicture(recorder.finishRecordingAsPicture());
+ m_canvas->drawPicture(recorder.finishRecordingAsPicture());
- SkBitmap canvasBitmap;
- canvasBitmap.allocN32Pixels(100, 100);
- ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0));
- SkAutoLockPixels autoLock(canvasBitmap);
- EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0));
+ SkAutoLockPixels autoLock(m_bitmap);
+ EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), m_bitmap.getColor(0, 0));
}
static void rasterizeMain(PaintCanvas* canvas, sk_sp<PaintRecord> record) {
@@ -226,16 +220,13 @@ TEST_F(DeferredImageDecoderTest, decodeOnOtherThread) {
WTF::wrapUnique(Platform::current()->createThread("RasterThread"));
thread->getWebTaskRunner()->postTask(
BLINK_FROM_HERE,
- crossThreadBind(&rasterizeMain,
- crossThreadUnretained(m_surface->getCanvas()), record));
+ crossThreadBind(&rasterizeMain, crossThreadUnretained(m_canvas.get()),
+ record));
thread.reset();
EXPECT_EQ(0, m_decodeRequestCount);
- SkBitmap canvasBitmap;
- canvasBitmap.allocN32Pixels(100, 100);
- ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0));
- SkAutoLockPixels autoLock(canvasBitmap);
- EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0));
+ SkAutoLockPixels autoLock(m_bitmap);
+ EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), m_bitmap.getColor(0, 0));
}
TEST_F(DeferredImageDecoderTest, singleFrameImageLoading) {
@@ -319,7 +310,7 @@ TEST_F(DeferredImageDecoderTest, decodedSize) {
tempCanvas->drawImage(std::move(image), 0, 0);
sk_sp<PaintRecord> record = recorder.finishRecordingAsPicture();
EXPECT_EQ(0, m_decodeRequestCount);
- m_surface->getCanvas()->drawPicture(record);
+ m_canvas->drawPicture(record);
EXPECT_EQ(1, m_decodeRequestCount);
}

Powered by Google App Engine
This is Rietveld 408576698