| 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 : enabled_bindings_(0) { |
| 14 enabled_bindings_(0) { | |
| 15 } | 14 } |
| 16 | 15 |
| 17 MockRenderProcess::~MockRenderProcess() { | 16 MockRenderProcess::~MockRenderProcess() { |
| 18 } | 17 } |
| 19 | 18 |
| 20 skia::PlatformCanvas* MockRenderProcess::GetDrawingCanvas( | |
| 21 TransportDIB** memory, | |
| 22 const gfx::Rect& rect) { | |
| 23 size_t stride = skia::PlatformCanvasStrideForWidth(rect.width()); | |
| 24 size_t size = stride * rect.height(); | |
| 25 | |
| 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 | |
| 28 // no browser process to ask for one in any case). | |
| 29 *memory = TransportDIB::Create(size, transport_dib_next_sequence_number_++); | |
| 30 if (!*memory) | |
| 31 return NULL; | |
| 32 return (*memory)->GetPlatformCanvas(rect.width(), rect.height()); | |
| 33 } | |
| 34 | |
| 35 void MockRenderProcess::ReleaseTransportDIB(TransportDIB* memory) { | |
| 36 delete memory; | |
| 37 } | |
| 38 | |
| 39 void MockRenderProcess::AddBindings(int bindings) { | 19 void MockRenderProcess::AddBindings(int bindings) { |
| 40 enabled_bindings_ |= bindings; | 20 enabled_bindings_ |= bindings; |
| 41 } | 21 } |
| 42 | 22 |
| 43 int MockRenderProcess::GetEnabledBindings() const { | 23 int MockRenderProcess::GetEnabledBindings() const { |
| 44 return enabled_bindings_; | 24 return enabled_bindings_; |
| 45 } | 25 } |
| 46 | 26 |
| 47 TransportDIB* MockRenderProcess::CreateTransportDIB(size_t size) { | |
| 48 return TransportDIB::Create(size, transport_dib_next_sequence_number_++); | |
| 49 } | |
| 50 | |
| 51 void MockRenderProcess::FreeTransportDIB(TransportDIB* dib) { | |
| 52 delete dib; | |
| 53 } | |
| 54 | |
| 55 } // namespace content | 27 } // namespace content |
| OLD | NEW |