1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_TEST_SKIA_COMMON_H_
6 #define CC_TEST_SKIA_COMMON_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "skia/ext/lazy_pixel_ref.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "third_party/skia/include/core/SkFlattenable.h"
22 class TestPixelRef
: public SkPixelRef
{
24 TestPixelRef(int width
, int height
);
25 virtual ~TestPixelRef();
27 virtual SkFlattenable::Factory
getFactory() OVERRIDE
;
28 virtual void* onLockPixels(SkColorTable
** color_table
) OVERRIDE
;
29 virtual void onUnlockPixels() OVERRIDE
{}
30 virtual SkPixelRef
* deepCopy(
31 SkBitmap::Config config
,
32 const SkIRect
* subset
) OVERRIDE
;
34 scoped_ptr
<char[]> pixels_
;
37 class TestLazyPixelRef
: public skia::LazyPixelRef
{
39 TestLazyPixelRef(int width
, int height
);
40 virtual ~TestLazyPixelRef();
42 virtual SkFlattenable::Factory
getFactory() OVERRIDE
;
43 virtual void* onLockPixels(SkColorTable
** color_table
) OVERRIDE
;
44 virtual void onUnlockPixels() OVERRIDE
{}
45 virtual bool PrepareToDecode(const PrepareParams
& params
) OVERRIDE
;
46 virtual bool MaybeDecoded() OVERRIDE
;
47 virtual SkPixelRef
* deepCopy(
48 SkBitmap::Config config
,
49 const SkIRect
* subset
) OVERRIDE
;
50 virtual void Decode() OVERRIDE
{}
52 scoped_ptr
<char[]> pixels_
;
55 void DrawPicture(unsigned char* buffer
,
57 scoped_refptr
<Picture
> picture
);
59 void CreateBitmap(gfx::Size size
, const char* uri
, SkBitmap
* bitmap
);
63 #endif // CC_TEST_SKIA_COMMON_H_