blob: af443b825afae148068973a97f6f34857a33c72b (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*
*
* Copyright 2006, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "config.h"
#include "Node.h"
#include "PlatformGraphicsContext.h"
#include "SkCanvas.h"
namespace WebCore {
PlatformGraphicsContext::PlatformGraphicsContext(SkCanvas* canvas) : mCanvas(canvas), m_deleteCanvas(false)
{
// This is useful only if this Canvas is part of an SkPicture object.
m_buttons = new SkTDArray<Container*>;
}
PlatformGraphicsContext::PlatformGraphicsContext() : m_deleteCanvas(true)
{
mCanvas = new SkCanvas;
// Since this is our own private SkCanvas, and has no relation to a picture
// storing button references would be meaningless.
m_buttons = NULL;
}
PlatformGraphicsContext::~PlatformGraphicsContext()
{
if (m_deleteCanvas) {
// printf("-------------------- deleting offscreen canvas\n");
delete mCanvas;
}
if (m_buttons != NULL) {
m_buttons->deleteAll();
delete m_buttons;
}
}
SkTDArray<Container*>* PlatformGraphicsContext::getAndClearButtonInfo()
{
// The caller is now responsible for deleting the array
SkTDArray<Container*>* buttons = m_buttons;
m_buttons = NULL;
return buttons;
}
void PlatformGraphicsContext::storeButtonInfo(Node* node, const IntRect& r)
{
if (m_buttons == NULL)
return;
// Initialize all of the nodes to have disabled state, so that we guarantee
// that we paint all of them the first time.
RenderSkinAndroid::State state = RenderSkinAndroid::kDisabled;
Container* container = new Container(node, r, state);
// Place a reference to our subpicture in the Picture.
mCanvas->drawPicture(*(container->picture()));
// Keep track of the information about the button.
*m_buttons->append() = container;
}
} // WebCore
|