2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkImage_Gpu_DEFINED
9 #define SkImage_Gpu_DEFINED
11 #include "GrTexture.h"
12 #include "GrGpuResourcePriv.h"
14 #include "SkImage_Base.h"
15 #include "SkImagePriv.h"
16 #include "SkSurface.h"
18 class SkImage_Gpu : public SkImage_Base {
20 SK_DECLARE_INST_COUNT(SkImage_Gpu)
22 SkImage_Gpu(const SkBitmap&, int sampleCountForNewSurfaces, SkSurface::Budgeted);
24 void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const SK_OVERRIDE;
25 void onDrawRect(SkCanvas*, const SkRect* src, const SkRect& dst,
26 const SkPaint*) const SK_OVERRIDE;
27 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const SK_OVERRIDE;
28 GrTexture* onGetTexture() const SK_OVERRIDE;
29 bool getROPixels(SkBitmap*) const SK_OVERRIDE;
31 GrTexture* getTexture() const { return fBitmap.getTexture(); }
33 SkShader* onNewShader(SkShader::TileMode,
35 const SkMatrix* localMatrix) const SK_OVERRIDE;
37 bool isOpaque() const SK_OVERRIDE;
39 void applyBudgetDecision() const {
41 fBitmap.getTexture()->resourcePriv().makeBudgeted();
43 fBitmap.getTexture()->resourcePriv().makeUnbudgeted();
49 const int fSampleCountForNewSurfaces; // 0 if we don't know
50 SkSurface::Budgeted fBudgeted;
52 typedef SkImage_Base INHERITED;