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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
// Copyright (c) 2010 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 "remoting/client/plugin/pepper_view.h"
#include "base/message_loop.h"
#include "remoting/client/decoder_verbatim.h"
namespace remoting {
PepperView::PepperView(MessageLoop* message_loop, NPDevice* rendering_device,
NPP plugin_instance)
: message_loop_(message_loop),
rendering_device_(rendering_device),
plugin_instance_(plugin_instance),
backing_store_width_(0),
backing_store_height_(0),
viewport_x_(0),
viewport_y_(0),
viewport_width_(0),
viewport_height_(0),
is_static_fill_(false),
static_fill_color_(0) {
}
PepperView::~PepperView() {
}
void PepperView::Paint() {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &PepperView::DoPaint));
}
void PepperView::SetSolidFill(uint32 color) {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &PepperView::DoSetSolidFill, color));
}
void PepperView::UnsetSolidFill() {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &PepperView::DoUnsetSolidFill));
}
void PepperView::SetViewport(int x, int y, int width, int height) {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &PepperView::DoSetViewport,
x, y, width, height));
}
void PepperView::SetBackingStoreSize(int width, int height) {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &PepperView::DoSetBackingStoreSize,
width, height));
}
void PepperView::HandleBeginUpdateStream(HostMessage* msg) {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &PepperView::DoHandleBeginUpdateStream, msg));
}
void PepperView::HandleUpdateStreamPacket(HostMessage* msg) {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &PepperView::DoHandleUpdateStreamPacket, msg));
}
void PepperView::HandleEndUpdateStream(HostMessage* msg) {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &PepperView::DoHandleEndUpdateStream, msg));
}
void PepperView::DoPaint() {
DCHECK_EQ(message_loop_, MessageLoop::current());
LOG(INFO) << "Starting PepperView::DoPaint";
NPDeviceContext2D context;
NPDeviceContext2DConfig config;
rendering_device_->initializeContext(plugin_instance_, &config, &context);
uint32* output_bitmap = static_cast<uint32*>(context.region);
// TODO(ajwong): Remove debugging code and actually hook up real painting
// logic from the decoder.
LOG(INFO) << "Painting top: " << context.dirty.top
<< " bottom: " << context.dirty.bottom
<< " left: " << context.dirty.left
<< " right: " << context.dirty.right;
for (int i = context.dirty.top; i < context.dirty.bottom; ++i) {
for (int j = context.dirty.left; j < context.dirty.right; ++j) {
*output_bitmap++ = static_fill_color_;
}
}
rendering_device_->flushContext(plugin_instance_, &context, NULL, NULL);
LOG(INFO) << "Finishing PepperView::DoPaint";
}
void PepperView::DoSetSolidFill(uint32 color) {
DCHECK_EQ(message_loop_, MessageLoop::current());
is_static_fill_ = true;
static_fill_color_ = color;
}
void PepperView::DoUnsetSolidFill() {
DCHECK_EQ(message_loop_, MessageLoop::current());
is_static_fill_ = false;
}
void PepperView::DoSetViewport(int x, int y, int width, int height) {
DCHECK_EQ(message_loop_, MessageLoop::current());
viewport_x_ = x;
viewport_y_ = y;
viewport_width_ = width;
viewport_height_ = height;
}
void PepperView::DoSetBackingStoreSize(int width, int height) {
DCHECK_EQ(message_loop_, MessageLoop::current());
backing_store_width_ = width;
backing_store_height_ = height;
}
void PepperView::DoHandleBeginUpdateStream(HostMessage* msg) {
DCHECK_EQ(message_loop_, MessageLoop::current());
NOTIMPLEMENTED();
}
void PepperView::DoHandleUpdateStreamPacket(HostMessage* msg) {
DCHECK_EQ(message_loop_, MessageLoop::current());
NOTIMPLEMENTED();
}
void PepperView::DoHandleEndUpdateStream(HostMessage* msg) {
DCHECK_EQ(message_loop_, MessageLoop::current());
NOTIMPLEMENTED();
}
} // namespace remoting
|