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
3 // found in the LICENSE file.
5 #include "content/test/mock_render_process.h"
7 #include "ui/gfx/rect.h"
8 #include "ui/surface/transport_dib.h"
12 MockRenderProcess::MockRenderProcess()
13 : transport_dib_next_sequence_number_(0),
14 enabled_bindings_(0) {
17 MockRenderProcess::~MockRenderProcess() {
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();
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_
++);
32 return (*memory
)->GetPlatformCanvas(rect
.width(), rect
.height());
35 void MockRenderProcess::ReleaseTransportDIB(TransportDIB
* memory
) {
39 bool MockRenderProcess::UseInProcessPlugins() const {
43 void MockRenderProcess::AddBindings(int bindings
) {
44 enabled_bindings_
|= bindings
;
47 int MockRenderProcess::GetEnabledBindings() const {
48 return enabled_bindings_
;
51 TransportDIB
* MockRenderProcess::CreateTransportDIB(size_t size
) {
52 return TransportDIB::Create(size
, transport_dib_next_sequence_number_
++);
55 void MockRenderProcess::FreeTransportDIB(TransportDIB
* dib
) {
59 } // namespace content