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

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

Issue 2764633002: cc/paint: Remove cc::PaintSurface. (Closed)
Patch Set: more stuff 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..ee1aaef356c5cdb93662d448ca0d9bb6b6cc8f62 100644
--- a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp
@@ -26,6 +26,7 @@
#include "platform/graphics/DeferredImageDecoder.h"
#include <memory>
+#include "cc/paint/skia_paint_canvas.h"
#include "platform/CrossThreadFunctional.h"
#include "platform/SharedBuffer.h"
#include "platform/WebTaskRunner.h"
@@ -34,7 +35,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 +109,9 @@ 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_canvas = cc::SkiaPaintCanvas::CreateRasterZeroed(
+ SkImageInfo::MakeN32Premul(100, 100));
+ ASSERT_TRUE(m_canvas.get());
m_decodeRequestCount = 0;
m_repetitionCount = cAnimationNone;
m_status = ImageFrame::FrameComplete;
@@ -143,7 +144,7 @@ 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;
+ std::unique_ptr<cc::PaintCanvas> m_canvas;
int m_decodeRequestCount;
RefPtr<SharedBuffer> m_data;
size_t m_frameCount;
@@ -166,12 +167,12 @@ 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));
+ ASSERT_TRUE(m_canvas->readPixels(&canvasBitmap, 0, 0));
SkAutoLockPixels autoLock(canvasBitmap);
EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0));
}
@@ -187,7 +188,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,11 +196,11 @@ 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));
+ ASSERT_TRUE(m_canvas->readPixels(&canvasBitmap, 0, 0));
SkAutoLockPixels autoLock(canvasBitmap);
EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0));
}
@@ -226,14 +227,14 @@ 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));
+ ASSERT_TRUE(m_canvas->readPixels(&canvasBitmap, 0, 0));
SkAutoLockPixels autoLock(canvasBitmap);
EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0));
}
@@ -319,7 +320,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