blob: b7eaf0d11aa59d80f01fe159716a9c1f07fe95ea [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
robertphillips@google.comd881bc12012-06-28 20:02:39 +000011#ifndef SkGrPixelRef_DEFINED
12#define SkGrPixelRef_DEFINED
reed@google.comac10a2d2010-12-22 21:39:39 +000013
reed@google.com9c49bc32011-07-07 13:42:37 +000014#include "SkBitmap.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015#include "SkPixelRef.h"
bsalomon@google.combbfa1002011-08-16 15:13:54 +000016#include "GrTexture.h"
17#include "GrRenderTarget.h"
18
reed@google.comac10a2d2010-12-22 21:39:39 +000019
reed@google.com9c49bc32011-07-07 13:42:37 +000020/**
21 * Common baseclass that implements onLockPixels() by calling onReadPixels().
22 * Since it has a copy, it always returns false for onLockPixelsAreWritable().
23 */
senorblanco@chromium.org29767652012-02-08 20:27:16 +000024class SK_API SkROLockPixelsPixelRef : public SkPixelRef {
reed@google.com9c49bc32011-07-07 13:42:37 +000025public:
26 SkROLockPixelsPixelRef();
27 virtual ~SkROLockPixelsPixelRef();
28
29protected:
30 // override from SkPixelRef
31 virtual void* onLockPixels(SkColorTable** ptr);
32 virtual void onUnlockPixels();
33 virtual bool onLockPixelsAreWritable() const; // return false;
34
35private:
36 SkBitmap fBitmap;
37 typedef SkPixelRef INHERITED;
38};
39
40/**
robertphillips@google.comd881bc12012-06-28 20:02:39 +000041 * PixelRef that wraps a GrSurface
reed@google.com9c49bc32011-07-07 13:42:37 +000042 */
robertphillips@google.comd881bc12012-06-28 20:02:39 +000043class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef {
reed@google.comac10a2d2010-12-22 21:39:39 +000044public:
robertphillips@google.comd881bc12012-06-28 20:02:39 +000045 SkGrPixelRef(GrSurface* surface);
46 virtual ~SkGrPixelRef();
reed@google.comac10a2d2010-12-22 21:39:39 +000047
48 // override from SkPixelRef
robertphillips@google.comd881bc12012-06-28 20:02:39 +000049 virtual SkGpuTexture* getTexture() SK_OVERRIDE;
reed@google.comac10a2d2010-12-22 21:39:39 +000050
djsollen@google.com5370cd92012-03-28 20:47:01 +000051 SK_DECLARE_UNFLATTENABLE_OBJECT()
52
reed@google.comac10a2d2010-12-22 21:39:39 +000053protected:
robertphillips@google.comd881bc12012-06-28 20:02:39 +000054 // overrides from SkPixelRef
55 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE;
senorblanco@chromium.orgef843cd2011-12-02 19:11:17 +000056 virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig) SK_OVERRIDE;
57
reed@google.comac10a2d2010-12-22 21:39:39 +000058private:
robertphillips@google.comd881bc12012-06-28 20:02:39 +000059 GrSurface* fSurface;
reed@google.com9c49bc32011-07-07 13:42:37 +000060 typedef SkROLockPixelsPixelRef INHERITED;
bsalomon@google.com669fdc42011-04-05 17:08:27 +000061};
62
reed@google.comac10a2d2010-12-22 21:39:39 +000063#endif
64