blob: 277a124e51c65c3f41c7e8b1eec6292414747cf3 (
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
|
// Copyright 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 "cc/test/skia_common.h"
#include "cc/resources/picture.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/skia_util.h"
namespace cc {
void DrawPicture(unsigned char* buffer,
const gfx::Rect& layer_rect,
scoped_refptr<Picture> picture) {
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config,
layer_rect.width(),
layer_rect.height());
bitmap.setPixels(buffer);
SkCanvas canvas(bitmap);
canvas.clipRect(gfx::RectToSkRect(layer_rect));
picture->Raster(&canvas, NULL, layer_rect, 1.0f);
}
void CreateBitmap(const gfx::Size& size, const char* uri, SkBitmap* bitmap) {
SkImageInfo info = {
size.width(),
size.height(),
kPMColor_SkColorType,
kPremul_SkAlphaType
};
bitmap->setConfig(info);
bitmap->allocPixels();
bitmap->pixelRef()->setImmutable();
bitmap->pixelRef()->setURI(uri);
}
} // namespace cc
|