OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/test/mock_render_process.h" | 5 #include "content/test/mock_render_process.h" |
6 | 6 |
7 #include "ui/gfx/rect.h" | 7 #include "ui/gfx/rect.h" |
8 #include "ui/surface/transport_dib.h" | 8 #include "ui/surface/transport_dib.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 MockRenderProcess::MockRenderProcess() | 12 MockRenderProcess::MockRenderProcess() |
13 : transport_dib_next_sequence_number_(0), | 13 : transport_dib_next_sequence_number_(0), |
14 enabled_bindings_(0) { | 14 enabled_bindings_(0) { |
15 } | 15 } |
16 | 16 |
17 MockRenderProcess::~MockRenderProcess() { | 17 MockRenderProcess::~MockRenderProcess() { |
18 } | 18 } |
19 | 19 |
20 skia::PlatformCanvas* MockRenderProcess::GetDrawingCanvas( | 20 skia::PlatformCanvas* MockRenderProcess::GetDrawingCanvas( |
21 TransportDIB** memory, | 21 TransportDIB** memory, |
22 const gfx::Rect& rect) { | 22 const gfx::Rect& rect) { |
23 size_t stride = skia::PlatformCanvas::StrideForWidth(rect.width()); | 23 size_t stride = skia::PlatformCanvasStrideForWidth(rect.width()); |
24 size_t size = stride * rect.height(); | 24 size_t size = stride * rect.height(); |
25 | 25 |
26 // Unlike RenderProcessImpl, when we're a test, we can just create transport | 26 // Unlike RenderProcessImpl, when we're a test, we can just create transport |
27 // DIBs in the current process, since there is no sandbox protecting us (and | 27 // DIBs in the current process, since there is no sandbox protecting us (and |
28 // no browser process to ask for one in any case). | 28 // no browser process to ask for one in any case). |
29 *memory = TransportDIB::Create(size, transport_dib_next_sequence_number_++); | 29 *memory = TransportDIB::Create(size, transport_dib_next_sequence_number_++); |
30 if (!*memory) | 30 if (!*memory) |
31 return NULL; | 31 return NULL; |
32 return (*memory)->GetPlatformCanvas(rect.width(), rect.height()); | 32 return (*memory)->GetPlatformCanvas(rect.width(), rect.height()); |
33 } | 33 } |
(...skipping 16 matching lines...) Expand all Loading... |
50 | 50 |
51 TransportDIB* MockRenderProcess::CreateTransportDIB(size_t size) { | 51 TransportDIB* MockRenderProcess::CreateTransportDIB(size_t size) { |
52 return TransportDIB::Create(size, transport_dib_next_sequence_number_++); | 52 return TransportDIB::Create(size, transport_dib_next_sequence_number_++); |
53 } | 53 } |
54 | 54 |
55 void MockRenderProcess::FreeTransportDIB(TransportDIB* dib) { | 55 void MockRenderProcess::FreeTransportDIB(TransportDIB* dib) { |
56 delete dib; | 56 delete dib; |
57 } | 57 } |
58 | 58 |
59 } // namespace content | 59 } // namespace content |
OLD | NEW |