hide deviceproperties, prepare the way for surfaceprops
BUG=skia: NOTRY=True R=bungeman@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/577023002
This commit is contained in:
parent
4e205b1079
commit
e010f1c2a0
@ -29,10 +29,6 @@ public:
|
||||
SkTrackDevice(const SkBitmap& bitmap) : SkBitmapDevice(bitmap)
|
||||
, fTracker(NULL) {}
|
||||
|
||||
SkTrackDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties)
|
||||
: SkBitmapDevice(bitmap, deviceProperties)
|
||||
, fTracker(NULL) {}
|
||||
|
||||
virtual ~SkTrackDevice() {}
|
||||
|
||||
// Install a tracker - we can reuse the tracker between multiple devices, and the state of the
|
||||
|
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "gm.h"
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkTypeface.h"
|
||||
|
||||
namespace skiagm {
|
||||
|
||||
class DevicePropertiesGM : public GM {
|
||||
public:
|
||||
DevicePropertiesGM() {
|
||||
this->setBGColor(0xFFFFFFFF);
|
||||
}
|
||||
|
||||
virtual ~DevicePropertiesGM() {
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual SkString onShortName() {
|
||||
return SkString("deviceproperties");
|
||||
}
|
||||
|
||||
virtual SkISize onISize() {
|
||||
return SkISize::Make(1450, 750);
|
||||
}
|
||||
|
||||
static void rotate_about(SkCanvas* canvas,
|
||||
SkScalar degrees,
|
||||
SkScalar px, SkScalar py) {
|
||||
canvas->translate(px, py);
|
||||
canvas->rotate(degrees);
|
||||
canvas->translate(-px, -py);
|
||||
}
|
||||
|
||||
virtual void onDraw(SkCanvas* originalCanvas) {
|
||||
SkISize size = this->getISize();
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocN32Pixels(size.width(), size.height());
|
||||
SkDeviceProperties properties = SkDeviceProperties::Make(
|
||||
SkDeviceProperties::Geometry::Make(SkDeviceProperties::Geometry::kVertical_Orientation,
|
||||
SkDeviceProperties::Geometry::kBGR_Layout),
|
||||
SK_Scalar1);
|
||||
SkBitmapDevice device(bitmap, properties);
|
||||
SkCanvas canvas(&device);
|
||||
canvas.drawColor(SK_ColorWHITE);
|
||||
|
||||
SkPaint paint;
|
||||
|
||||
paint.setAntiAlias(true);
|
||||
paint.setLCDRenderText(true);
|
||||
//With freetype the default (normal hinting) can be really ugly.
|
||||
//Most distros now set slight (vertical hinting only) in any event.
|
||||
paint.setHinting(SkPaint::kSlight_Hinting);
|
||||
sk_tool_utils::set_portable_typeface(&paint, "Times Roman", SkTypeface::kNormal);
|
||||
|
||||
const char* text = "Hamburgefons ooo mmm";
|
||||
const size_t textLen = strlen(text);
|
||||
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
SkScalar x = SkIntToScalar(10);
|
||||
SkScalar y = SkIntToScalar(20);
|
||||
|
||||
SkAutoCanvasRestore acr(&canvas, true);
|
||||
canvas.translate(SkIntToScalar(50 + i * 230),
|
||||
SkIntToScalar(20));
|
||||
rotate_about(&canvas, SkIntToScalar(i * 5), x, y * 10);
|
||||
|
||||
{
|
||||
SkPaint p;
|
||||
p.setAntiAlias(true);
|
||||
SkRect r;
|
||||
r.set(x - SkIntToScalar(3), SkIntToScalar(15),
|
||||
x - SkIntToScalar(1), SkIntToScalar(280));
|
||||
canvas.drawRect(r, p);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (int ps = 6; ps <= 22; ps++) {
|
||||
paint.setTextSize(SkIntToScalar(ps));
|
||||
canvas.drawText(text, textLen, x, y, paint);
|
||||
y += paint.getFontMetrics(NULL);
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
canvas.translate(0, SkIntToScalar(360));
|
||||
paint.setSubpixelText(true);
|
||||
}
|
||||
originalCanvas->drawBitmap(bitmap, 0, 0);
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
virtual uint32_t onGetFlags() const SK_OVERRIDE {
|
||||
// On android, we fail due to bad gpu drivers (it seems) by adding too
|
||||
// much to our text atlas (texture).
|
||||
return kSkipGPU_Flag;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef GM INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static GM* MyFactory(void*) { return new DevicePropertiesGM; }
|
||||
static GMRegistry reg(MyFactory);
|
||||
|
||||
}
|
@ -61,7 +61,6 @@
|
||||
'../gm/discard.cpp',
|
||||
'../gm/dashcubics.cpp',
|
||||
'../gm/dashing.cpp',
|
||||
'../gm/deviceproperties.cpp',
|
||||
'../gm/distantclip.cpp',
|
||||
'../gm/dftext.cpp',
|
||||
'../gm/displacement.cpp',
|
||||
|
@ -22,16 +22,18 @@ public:
|
||||
* any drawing to this device will have no effect.
|
||||
*/
|
||||
SkBitmapDevice(const SkBitmap& bitmap);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Construct a new device with the specified bitmap as its backend. It is
|
||||
* valid for the bitmap to have no pixels associated with it. In that case,
|
||||
* any drawing to this device will have no effect.
|
||||
*/
|
||||
SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties);
|
||||
|
||||
static SkBitmapDevice* Create(const SkImageInfo&,
|
||||
const SkDeviceProperties* = NULL);
|
||||
static SkBitmapDevice* Create(const SkImageInfo&, const SkDeviceProperties*);
|
||||
public:
|
||||
static SkBitmapDevice* Create(const SkImageInfo& info) {
|
||||
return Create(info, NULL);
|
||||
}
|
||||
|
||||
virtual SkImageInfo imageInfo() const SK_OVERRIDE;
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkDeviceProperties.h"
|
||||
#include "SkImageFilter.h"
|
||||
|
||||
class SkClipStack;
|
||||
@ -21,7 +20,7 @@ struct SkIRect;
|
||||
class SkMatrix;
|
||||
class SkMetaData;
|
||||
class SkRegion;
|
||||
|
||||
struct SkDeviceProperties;
|
||||
class GrRenderTarget;
|
||||
|
||||
class SK_API SkBaseDevice : public SkRefCnt {
|
||||
@ -32,24 +31,12 @@ public:
|
||||
* Construct a new device.
|
||||
*/
|
||||
SkBaseDevice();
|
||||
|
||||
/**
|
||||
* Construct a new device.
|
||||
*/
|
||||
SkBaseDevice(const SkDeviceProperties& deviceProperties);
|
||||
|
||||
virtual ~SkBaseDevice();
|
||||
|
||||
SkBaseDevice* createCompatibleDevice(const SkImageInfo&);
|
||||
|
||||
SkMetaData& getMetaData();
|
||||
|
||||
/** Return the image properties of the device. */
|
||||
virtual const SkDeviceProperties& getDeviceProperties() const {
|
||||
//Currently, all the properties are leaky.
|
||||
return fLeakyProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ImageInfo for this device. If the canvas is not backed by pixels
|
||||
* (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType.
|
||||
@ -333,7 +320,9 @@ protected:
|
||||
* If the device does handle a property, that property should be set to the identity value
|
||||
* for that property, effectively making it non-leaky.
|
||||
*/
|
||||
SkDeviceProperties fLeakyProperties;
|
||||
const SkDeviceProperties& getLeakyProperties() const {
|
||||
return *fLeakyProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* PRIVATE / EXPERIMENTAL -- do not call
|
||||
@ -390,6 +379,7 @@ private:
|
||||
|
||||
SkIPoint fOrigin;
|
||||
SkMetaData* fMetaData;
|
||||
SkDeviceProperties* fLeakyProperties; // will always exist.
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
bool fAttachedToCanvas;
|
||||
|
@ -61,12 +61,14 @@ SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) : fBitmap(bitmap) {
|
||||
SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
|
||||
}
|
||||
|
||||
#if 0
|
||||
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties)
|
||||
: SkBaseDevice(deviceProperties)
|
||||
, fBitmap(bitmap)
|
||||
{
|
||||
SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
|
||||
}
|
||||
#endif
|
||||
|
||||
SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
|
||||
const SkDeviceProperties* props) {
|
||||
@ -91,8 +93,8 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
|
||||
}
|
||||
}
|
||||
|
||||
if (props) {
|
||||
return SkNEW_ARGS(SkBitmapDevice, (bitmap, *props));
|
||||
if (props && false) {
|
||||
// return SkNEW_ARGS(SkBitmapDevice, (bitmap, *props));
|
||||
} else {
|
||||
return SkNEW_ARGS(SkBitmapDevice, (bitmap));
|
||||
}
|
||||
@ -110,7 +112,7 @@ void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
|
||||
}
|
||||
|
||||
SkBaseDevice* SkBitmapDevice::onCreateDevice(const SkImageInfo& info, Usage usage) {
|
||||
return SkBitmapDevice::Create(info, &this->getDeviceProperties());
|
||||
return SkBitmapDevice::Create(info);// &this->getDeviceProperties());
|
||||
}
|
||||
|
||||
void SkBitmapDevice::lockPixels() {
|
||||
|
@ -6,23 +6,14 @@
|
||||
*/
|
||||
|
||||
#include "SkDevice.h"
|
||||
#include "SkDeviceProperties.h"
|
||||
#include "SkDraw.h"
|
||||
#include "SkMetaData.h"
|
||||
#include "SkPatchUtils.h"
|
||||
#include "SkTextBlob.h"
|
||||
|
||||
SkBaseDevice::SkBaseDevice()
|
||||
: fLeakyProperties(SkDeviceProperties::MakeDefault())
|
||||
#ifdef SK_DEBUG
|
||||
, fAttachedToCanvas(false)
|
||||
#endif
|
||||
{
|
||||
fOrigin.setZero();
|
||||
fMetaData = NULL;
|
||||
}
|
||||
|
||||
SkBaseDevice::SkBaseDevice(const SkDeviceProperties& deviceProperties)
|
||||
: fLeakyProperties(deviceProperties)
|
||||
: fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::MakeDefault())))
|
||||
#ifdef SK_DEBUG
|
||||
, fAttachedToCanvas(false)
|
||||
#endif
|
||||
@ -32,7 +23,8 @@ SkBaseDevice::SkBaseDevice(const SkDeviceProperties& deviceProperties)
|
||||
}
|
||||
|
||||
SkBaseDevice::~SkBaseDevice() {
|
||||
delete fMetaData;
|
||||
SkDELETE(fLeakyProperties);
|
||||
SkDELETE(fMetaData);
|
||||
}
|
||||
|
||||
SkBaseDevice* SkBaseDevice::createCompatibleDevice(const SkImageInfo& info) {
|
||||
|
@ -1576,7 +1576,7 @@ void SkDraw::drawText(const char text[], size_t byteLength,
|
||||
|
||||
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
|
||||
|
||||
SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix);
|
||||
SkAutoGlyphCache autoCache(paint, &fDevice->getLeakyProperties(), fMatrix);
|
||||
SkGlyphCache* cache = autoCache.getCache();
|
||||
|
||||
// transform our starting point
|
||||
@ -1724,7 +1724,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
|
||||
}
|
||||
|
||||
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
|
||||
SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix);
|
||||
SkAutoGlyphCache autoCache(paint, &fDevice->getLeakyProperties(), fMatrix);
|
||||
SkGlyphCache* cache = autoCache.getCache();
|
||||
|
||||
SkAAClipBlitterWrapper wrapper;
|
||||
|
@ -157,8 +157,8 @@ SkGpuDevice::SkGpuDevice(GrSurface* surface, unsigned flags) {
|
||||
fLegacyBitmap.setPixelRef(pr)->unref();
|
||||
|
||||
bool useDFFonts = !!(flags & kDFFonts_Flag);
|
||||
fMainTextContext = fContext->createTextContext(fRenderTarget, fLeakyProperties, useDFFonts);
|
||||
fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProperties));
|
||||
fMainTextContext = fContext->createTextContext(fRenderTarget, this->getLeakyProperties(), useDFFonts);
|
||||
fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, this->getLeakyProperties()));
|
||||
}
|
||||
|
||||
SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo,
|
||||
|
Loading…
Reference in New Issue
Block a user