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