コード例 #1
0
const ScaledImageFragment* ImageFrameGenerator::tryToScale(const ScaledImageFragment* fullSizeImage, const SkISize& scaledSize)
{
    // If the requested scaled size is the same as the full size then exit
    // early. This saves a cache lookup.
    if (scaledSize == m_fullSize)
        return 0;

    if (!fullSizeImage && !ImageDecodingStore::instance()->lockCache(this, m_fullSize, ImageDecodingStore::CacheMustBeComplete, &fullSizeImage))
        return 0;

    DiscardablePixelRefAllocator allocator;
    // This call allocates the DiscardablePixelRef and lock/unlocks it
    // afterwards. So the memory allocated to the scaledBitmap can be
    // discarded after this call. Need to lock the scaledBitmap and
    // check the pixels before using it next time.
    SkBitmap scaledBitmap = skia::ImageOperations::Resize(fullSizeImage->bitmap(), resizeMethod(), scaledSize.width(), scaledSize.height(), &allocator);

    OwnPtr<ScaledImageFragment> scaledImage = ScaledImageFragment::create(scaledSize, scaledBitmap, fullSizeImage->isComplete());

    ImageDecodingStore::instance()->unlockCache(this, fullSizeImage);

    const ScaledImageFragment* cachedImage = 0;

    // If a cache lookup is successful then the cache entry must be incomplete
    // therefore it is safe to overwrite.
    if (ImageDecodingStore::instance()->lockCache(this, scaledSize, ImageDecodingStore::CacheCanBeIncomplete, &cachedImage))
        return ImageDecodingStore::instance()->overwriteAndLockCache(this, cachedImage, scaledImage.release());
    return ImageDecodingStore::instance()->insertAndLockCache(this, scaledImage.release());
}
コード例 #2
0
const ScaledImageFragment* ImageFrameGenerator::tryToScale(const ScaledImageFragment* fullSizeImage, const SkISize& scaledSize, size_t index)
{
    TRACE_EVENT0("webkit", "ImageFrameGenerator::tryToScale");

    // If the requested scaled size is the same as the full size then exit
    // early. This saves a cache lookup.
    if (scaledSize == m_fullSize)
        return 0;

    if (!fullSizeImage && !ImageDecodingStore::instance()->lockCache(this, m_fullSize, index, &fullSizeImage))
        return 0;

    // This call allocates the DiscardablePixelRef and lock/unlocks it
    // afterwards. So the memory allocated to the scaledBitmap can be
    // discarded after this call. Need to lock the scaledBitmap and
    // check the pixels before using it next time.
    SkBitmap scaledBitmap = skia::ImageOperations::Resize(fullSizeImage->bitmap(), resizeMethod(), scaledSize.width(), scaledSize.height(), &m_allocator);

    OwnPtr<ScaledImageFragment> scaledImage;
    if (fullSizeImage->isComplete())
        scaledImage = ScaledImageFragment::createComplete(scaledSize, fullSizeImage->index(), scaledBitmap);
    else
        scaledImage = ScaledImageFragment::createPartial(scaledSize, fullSizeImage->index(), nextGenerationId(), scaledBitmap);
    ImageDecodingStore::instance()->unlockCache(this, fullSizeImage);
    return ImageDecodingStore::instance()->insertAndLockCache(this, scaledImage.release());
}
コード例 #3
0
const ScaledImageFragment* ImageFrameGenerator::tryToScale(const ScaledImageFragment* fullSizeImage, const SkISize& scaledSize)
{
    // If the requested scaled size is the same as the full size then exit
    // early. This saves a cache lookup.
    if (scaledSize == m_fullSize)
        return 0;

    if (!fullSizeImage)
        fullSizeImage = ImageDecodingStore::instance()->lockCompleteCache(this, m_fullSize);

    if (!fullSizeImage)
        return 0;

    SkBitmap scaledBitmap = skia::ImageOperations::Resize(
        fullSizeImage->bitmap(), resizeMethod(), scaledSize.width(), scaledSize.height());
    OwnPtr<ScaledImageFragment> scaledImage = ScaledImageFragment::create(scaledSize, scaledBitmap, fullSizeImage->isComplete());

    ImageDecodingStore::instance()->unlockCache(this, fullSizeImage);
    return ImageDecodingStore::instance()->insertAndLockCache(this, scaledImage.release());
}
コード例 #4
0
ファイル: prefinterface.cpp プロジェクト: rdp/smplayer-svn
void PrefInterface::getData(Preferences * pref) {
	requires_restart = false;
	language_changed = false;
	iconset_changed = false;
	gui_changed = false;
	style_changed = false;
	recents_changed = false;

	if (pref->language != language()) {
		pref->language = language();
		language_changed = true;
		qDebug("PrefInterface::getData: chosen language: '%s'", pref->language.toUtf8().data());
	}

	if (pref->iconset != iconSet()) {
		pref->iconset = iconSet();
		iconset_changed = true;
	}

	if (pref->gui != GUI()) {
		pref->gui = GUI();
		gui_changed = true;
	}

	pref->resize_method = resizeMethod();
	pref->save_window_size_on_exit = saveSize();

#ifdef SINGLE_INSTANCE
	pref->use_single_instance = useSingleInstance();
#endif

	if (pref->history_recents->maxItems() != recentsMaxItems()) {
		pref->history_recents->setMaxItems( recentsMaxItems() );
		recents_changed = true;
	}

	pref->seeking1 = seeking1();
	pref->seeking2 = seeking2();
	pref->seeking3 = seeking3();
	pref->seeking4 = seeking4();

	pref->update_while_seeking = updateWhileDragging();
	pref->relative_seeking= relativeSeeking();
	pref->precise_seeking = preciseSeeking();

	pref->default_font = defaultFont();

	pref->hide_video_window_on_audio_files = hideVideoOnAudioFiles();

#if STYLE_SWITCHING
    if ( pref->style != style() ) {
        pref->style = style();
		style_changed = true;
	}
#endif

	pref->floating_control_animated = floatingAnimated();
	pref->floating_control_width = floatingWidth();
	pref->floating_control_margin = floatingMargin();
	pref->floating_display_in_compact_mode = displayFloatingInCompactMode();
#ifndef Q_OS_WIN
	pref->bypass_window_manager = floatingBypassWindowManager();
#endif
}
コード例 #5
0
void FieldGenerator::generateRepeatedProperty(
    google::protobuf::io::Printer& p) {
  p.Print(variables_,
          "$i$  // Replacement setter\n"
          "$i$$type$.prototype.set$capital_name$ = function(values) {\n");
  if (is_typed_array_) {
    p.Print(variables_,
            // Omit type checks for performance
            // "$i$  if (values instanceof $typed_array$ || values "
            // "instanceof Array "
            // "|| values instanceof ArrayBuffer) {\n"
            "$i$    if (!values.BYTES_PER_ELEMENT) {\n"
            "$i$      values = new $typed_array$(values);;\n"
            "$i$    }\n"
            "$i$    var newArray = this._ensureLength(this._fields[$index$], "
            "values.length);\n"
            "$i$    if (newArray) {\n"
            "$i$      this._fields[$index$] = newArray;\n"
            "$i$    }\n"
            "$i$    this._fields[$index$].set(values);\n"
            // "$i$  } else {\n"
            // "$i$    throw new TypeError();\n"
            // "$i$  }\n"
            );
  } else {
    p.Print(variables_,
            "$i$  if (!(values instanceof Array)) {\n"
            "$i$    throw new TypeError();\n"
            "$i$  }\n");
    if (is_message_) {
      p.Print(variables_,
              "$i$  this._fields[$index$].length = values.length;\n"
              "$i$   this._$name$.length = values.length;\n"
              "$i$   for (var i = 0; i < values.length; ++i) {\n"
              "$i$     var msg = new "
              "$message_scope$$message_type$(values[i]);\n"
              "$i$     this._$name$[i] = msg;\n"
              "$i$     this._fields[$index$][i] = msg._raw;\n"
              "$i$   }\n");
    } else {
      p.Print(variables_, "$i$    this._fields[$index$] = values.slice();\n");
    }
  }
  p.Print(variables_,
          "$i$};\n"
          "$i$// Single value setter\n"
          "$i$$type$.prototype.set$capital_name$At = function(index, value) "
          "{\n"
          // Type checks are expensive for V4 engine.
          //"$i$  if (typeof index != 'number') {\n"
          //"$i$    throw new TypeError('Index should be a number: ' + typeof "
          //"index);\n"
          //"$i$  }\n"
          //"$i$  if(this._fields[$index$].length <= index) {\n"
          //"$i$    throw new RangeError();\n"
          //"$i$  }\n");
          );
  if (is_message_) {
    p.Print(variables_,
            "$i$  var msg = "
            "this._maybeConvertToMessage($message_scope$$message_type$, "
            "value);\n"
            "$i$  this._$name$[index] = msg;\n"
            "$i$  this._fields[$index$][index] = msg._raw;\n");
  } else if (is_typed_array_) {
    p.Print(variables_, "$i$  this._fields[$index$][index] = value;\n");
  } else {
    p.Print(variables_, "$i$  this._fields[$index$][index] = value;\n");
  }
  p.Print(variables_,
          "$i$};\n"
          "$i$// Getter\n"
          "$i$$type$.prototype.get$capital_name$At = function(index) {\n"
          "$i$  if (typeof index != 'number') {\n"
          "$i$    throw new TypeError('Index should be a number: ' + typeof "
          "index);\n"
          "$i$  }\n"
          "$i$  if(this._fields[$index$].length < index) {\n"
          "$i$    throw new RangeError();\n"
          "$i$  }\n");
  if (is_message_) {
    p.Print(variables_, "$i$  return this._$name$[index];\n");
  } else {
    p.Print(variables_, "$i$  return this._fields[$index$][index];\n");
  }
  p.Print(variables_,
          "$i$};\n"
          "$i$$type$.prototype.get$capital_name$AsArray = function() {\n");
  if (is_message_) {
    p.Print(variables_, "$i$  return this._$name$.slice();\n");
  } else if (is_typed_array_) {
    p.Print(variables_,
            "$i$  var array = [];\n"
            "$i$  for (var i = 0; i < this._fields[$index$].length; ++i) {\n"
            "$i$    array.push(this._fields[$index$][i]);\n"
            "$i$  }\n"
            "$i$  return array;\n");
  } else {
    p.Print(variables_, "$i$  return this._fields[$index$].slice();\n");
  }
  p.Print(variables_, "$i$};\n");

  p.Print(variables_,
          "$i$$type$.prototype.$name$ = function(indexOrValues, value) {\n"
          "$i$  if (typeof indexOrValues == 'undefined') {\n"
          "$i$    throw new TypeError('Not enough arguments');\n"
          "$i$  } else if (typeof indexOrValues == 'number') {\n"
          "$i$    if (typeof value == 'undefined') {\n"
          "$i$      return this.get$capital_name$At(indexOrValues);\n"
          "$i$    } else {\n"
          "$i$      this.set$capital_name$At(indexOrValues, value);\n"
          "$i$    }\n"
          "$i$  } else {\n"
          "$i$    this.set$capital_name$(indexOrValues);\n"
          "$i$  }\n"
          "$i$};\n");

  countMethod(p);
  addMethod(p);
  if (is_typed_array_) {
    reserveMethod(p);
  }
  if (!is_message_) {
    resizeMethod(p);
  }

  p.Print(variables_,
          "$i$$type$.prototype.remove$capital_name$ = function(index) {\n"
          "$i$  if (typeof index != 'number') {\n"
          "$i$    throw new TypeError('Index should be a number: ' + typeof "
          "index);\n"
          "$i$  }\n"
          "$i$  this._fields[$index$].splice(index, 1);\n");

  if (is_message_) {
    p.Print(variables_, "$i$  this._$name$.splice(index, 1);\n");
    messageAssertLength(p);
  }

  p.Print(variables_,
          "$i$};\n"
          "$i$$type$.prototype.clear$capital_name$ = function() {\n");

  if (is_typed_array_) {
    p.Print(variables_,
            "$i$  this._fields[$index$] = new "
            "$typed_array$(this._fields[$index$].buffer, 0, 0);\n");
  } else {
    p.Print(variables_, "$i$  this._fields[$index$].length = 0;\n");

    if (is_message_) {
      p.Print(variables_, "$i$  this._$name$.length = 0;\n");
      messageAssertLength(p);
    }
  }

  p.Print(variables_, "$i$};\n");
}