summaryrefslogtreecommitdiffstats
path: root/android_webview/common/renderer_picture_map.cc
blob: f5e9e036fbd831ce165cf3614bccd6838522df6a (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
// 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 "android_webview/common/renderer_picture_map.h"

using base::AutoLock;

namespace android_webview {

static RendererPictureMap* g_renderer_picture_map = NULL;

// static
void RendererPictureMap::CreateInstance() {
  if (!g_renderer_picture_map)
    g_renderer_picture_map = new RendererPictureMap();
}

// static
RendererPictureMap* RendererPictureMap::GetInstance() {
  DCHECK(g_renderer_picture_map);
  return g_renderer_picture_map;
}

RendererPictureMap::RendererPictureMap() {
}

RendererPictureMap::~RendererPictureMap() {
}

scoped_refptr<cc::PicturePileImpl> RendererPictureMap::GetRendererPicture(
    int id) {
  AutoLock lock(lock_);
  return picture_map_[id];
}

void RendererPictureMap::SetRendererPicture(int id,
    scoped_refptr<cc::PicturePileImpl> picture) {
  AutoLock lock(lock_);
  picture_map_[id] = picture;
}

void RendererPictureMap::ClearRendererPicture(int id) {
  AutoLock lock(lock_);
  picture_map_.erase(id);
}

}  // android_webview