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

Side by Side Diff: Source/WebKit/chromium/tests/Canvas2DLayerManagerTest.cpp

Issue 16032003: Fixing Canvas2DLayerBridge to handle lost graphics contexts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed unit tests Created 7 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 25 matching lines...) Expand all
36 36
37 using namespace WebCore; 37 using namespace WebCore;
38 using testing::InSequence; 38 using testing::InSequence;
39 using testing::Return; 39 using testing::Return;
40 using testing::Test; 40 using testing::Test;
41 41
42 42
43 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge { 43 class FakeCanvas2DLayerBridge : public Canvas2DLayerBridge {
44 public: 44 public:
45 FakeCanvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, SkDeferredCan vas* canvas) 45 FakeCanvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, SkDeferredCan vas* canvas)
46 : Canvas2DLayerBridge(context, canvas, NonOpaque, SingleThread) 46 : Canvas2DLayerBridge(context, canvas)
47 , m_freeableBytes(0) 47 , m_freeableBytes(0)
48 , m_freeMemoryIfPossibleCount(0) 48 , m_freeMemoryIfPossibleCount(0)
49 , m_flushCount(0) 49 , m_flushCount(0)
50 { 50 {
51 init(NonOpaque, SingleThread);
51 } 52 }
52 53
53 virtual size_t storageAllocatedForRecording() OVERRIDE 54 virtual size_t storageAllocatedForRecording() OVERRIDE
54 { 55 {
55 // Because the fake layer has no canvas to query, just 56 // Because the fake layer has no canvas to query, just
56 // return status quo. Allocation changes that would normally be 57 // return status quo. Allocation changes that would normally be
57 // initiated by the canvas can be faked by invoking 58 // initiated by the canvas can be faked by invoking
58 // storageAllocatedForRecordingChanged directly from the test code. 59 // storageAllocatedForRecordingChanged directly from the test code.
59 return m_bytesAllocated; 60 return m_bytesAllocated;
60 } 61 }
(...skipping 13 matching lines...) Expand all
74 m_bytesAllocated -= bytesFreed; 75 m_bytesAllocated -= bytesFreed;
75 return bytesFreed; 76 return bytesFreed;
76 } 77 }
77 78
78 virtual void flush() OVERRIDE 79 virtual void flush() OVERRIDE
79 { 80 {
80 flushedDrawCommands(); 81 flushedDrawCommands();
81 m_flushCount++; 82 m_flushCount++;
82 } 83 }
83 84
85 virtual bool isValid() OVERRIDE
86 {
87 return true;
88 }
84 public: 89 public:
85 size_t m_freeableBytes; 90 size_t m_freeableBytes;
86 int m_freeMemoryIfPossibleCount; 91 int m_freeMemoryIfPossibleCount;
87 int m_flushCount; 92 int m_flushCount;
88 }; 93 };
89 94
90 static PassOwnPtr<SkDeferredCanvas> createCanvas(GraphicsContext3D* context) { 95 static PassOwnPtr<SkDeferredCanvas> createCanvas(GraphicsContext3D* context) {
91 SkAutoTUnref<SkDevice> device(new SkDevice(SkBitmap::kARGB_8888_Config, 1, 1 )); 96 SkAutoTUnref<SkDevice> device(new SkDevice(SkBitmap::kARGB_8888_Config, 1, 1 ));
92 return adoptPtr(new SkDeferredCanvas(device.get())); 97 return adoptPtr(new SkDeferredCanvas(device.get()));
93 } 98 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 flushEvictionTest(); 261 flushEvictionTest();
257 } 262 }
258 263
259 TEST_F(Canvas2DLayerManagerTest, testDeferredFrame) 264 TEST_F(Canvas2DLayerManagerTest, testDeferredFrame)
260 { 265 {
261 deferredFrameTest(); 266 deferredFrameTest();
262 } 267 }
263 268
264 } // namespace 269 } // namespace
265 270
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698